IBM Sterling Transformation Extender

Sterling Transformation Extender

Come for answers, stay for best practices. All we're missing is you.


#Sterling
#Supplychain
 View Only
Expand all | Collapse all

Lookup Table Map Rule

  • 1.  Lookup Table Map Rule

    Posted 04/02/09 05:39 PM

    Originally posted by: SystemAdmin


    Hello,

    I am in need of a better way to use the lookup function. I have a map rule that is currently not working correctly as it should. I have a PMR opened for this issue (possible bug) but wanted to try the forum to see if anyone can help me write a better map rule that may resolve my issue.

    I have a lookup table, that is called when a certain condition is met. Once this condition is met I want to call the lookup table to see if a value is present and if so, map a certain value. The rule I am using now is:

    =IF (TEXTTONUMBER (LocFunctCdQual'r Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = 87,

    IF (LOOKUP ( Country Field:.:AirportLookupFile ,

    Code Field IN AirportLookupFile =
    LocNameCd Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = "USA" , "E" , "P" ))

    Which is not really looking up so I have a PMR opened. I am trying to modify the map rule to remove the "USA" condition, because all I really want to do is check the table to see if the value is there. Does anyone have any suggestions? Please see the attached document that shows a print screen of what I am dealing with.

    Any help will be appreciated. Thanks.
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 2.  Re: Lookup Table Map Rule

    Posted 04/02/09 06:10 PM

    Originally posted by: phil2030


    Looks like you have a too few many "IN" keywords to me. Why are you doing a lookup for "Country Field:.:AirportLookupFile" and using "Code Field IN AirportLookupFile" as part of the expression? Why not "Code Field:.:AirportLookupFile"? At a guess, your probably losing the association between the objects... the software has never liked multiple operations on the same series of objects in a single rule.

    Try something like:

    =IF (TEXTTONUMBER (LocFunctCdQual'r Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = 87,
    myfunc( AirportLookupFile, PAXLST_FD05B_Inbound_Partner_Msg))

    then do your remaining part of the rule in "myfunc".

    IF (LOOKUP ( Country Field:.:AirportLookupFile ,
    Code Field:.:AirportLookupFile =
    LocNameCd Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = "USA" , "E" , "P" ))
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 3.  Re: Lookup Table Map Rule

    Posted 04/02/09 08:30 PM

    Originally posted by: SystemAdmin


    Phil,

    thanks for the suggestion, but I have tried passing the map rule into a functional map but rec'd the same results. This would have made more since if the type tree was attached, the "airportlookupfile" is just the name of the input card. Originally I had other country codes in the lookup table, so I had to verify that the result would be USA. So in trying to follow the syntax for the lookup function, my logic was:
    _LOOKUP ( series_to_search_ the country code field --this is what I wanted to verify whether it was USA , _condition_to_evaluate_ *2nd part of the map rule, when the airport code in the file = the code in the lookup table )when this condition is met, lookup the country code to see if it is USA, if so map X, if not map Y.

    I have removed all codes except the USA codes so now I just want to check the lookup table to see if the code exists.

    Thanks again.
    #DataExchange
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender


  • 4.  Re: Lookup Table Map Rule

    Posted 04/02/09 08:34 PM

    Originally posted by: SystemAdmin


    Sorry about the bold print, I was trying to underline the map rule and then explain the logic I was using so that it would make sense.

    _LOOKUP ( series_to_search__ the country code field --this is what I wanted to verify whether it was USA , __condition_to_evaluate__ 2nd part of the map rule, when the airport code in the file = the code in the lookup table )when this condition is met, lookup the country code to see if it is USA, if so map X, if not map Y.
    #DataExchange
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender


  • 5.  Re: Lookup Table Map Rule

    Posted 04/03/09 05:45 PM

    Originally posted by: repanzer


    First, and just making sure, when using Lookup or lookdown, the table must be sorted on that field. If it's not sorted, use EXTRACT.

    Also, as mentioned above, the IN function says "any where in".

    For example, if the field name/qualifier is;

    DTM segment: IT1 loop: 810 transaction: Interchange.

    and you try to extract it, it will only grab the DTM segment in the IT1 loop in the 810 Transaction.

    If you change it to;

    DTM segment IN 810 transaction; Interchange,

    it will grab any DTM segment in the transaction, not just in the IT1 loop.

    IF you change it to;

    DTM segment: IT1 loop IN Interchange.

    It will grab the first DTM in any of the IT1 loops in the interchange. (if there is more then one DTM and you don’t specify the index (DTM[3]: IT1), it will always grab the first one.

    Let me re-read your rule and see if I can come up with something.
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 6.  Re: Lookup Table Map Rule

    Posted 04/03/09 05:48 PM

    Originally posted by: repanzer


    Of course also, just for testing, you may want to just do the lookup without the;

    LocFunctCdQual'r Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = 87

    until you get the lookup working.

    still, I'll take a look.....
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 7.  Re: Lookup Table Map Rule

    Posted 04/03/09 06:10 PM

    Originally posted by: repanzer


    The code looks fine actually.

    Some different variants may be something like;

    =IF (LocFunctCdQual'r Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg = 87 &
    LOOKUP ( Country Field:.:AirportLookupFile , Code Field:AirportLookupFile = LocNameCd Element:.:Group3:PAXLST_FD05B_Inbound_Partner_Msg ) = "USA" , "E" , "P" ))

    But if you're not getting the expected results from the look up, I would probably comment out my rule, then just to be absolutely sure the basics are correct, use this statement;

    EXTRACT(Country Field:.:AirportLookupFile, Code Field:AirportLookupFile="abc") where abc is the code in the look up for USA. Don't use the data from the input.

    My assumption is that the look up table look like this;

    CODE FIELD, COUNTRY FIELD
    abc,USA

    If that returns USA, then I would keep changing the rule back to what you originally had, piece by piece, like;

    EXTRACT(Country Field:.:AirportLookupFile, Code Field:AirportLookupFile=LocNameCd Element:.:Group3:PAXLST_FD05B_Inbound_Partner_Msg )

    Then if that doesn’t return USA, it’s not using the correct LocNameCd Element:.:Group3:PAXLST_FD05B_Inbound_Partner_Msg you were expecting, but if it does return USA, the change the EXTRACT back to LOOKUP.

    Basically, make the rule as simple as possible and get it to work at that level, then keep changing the rule to what you want, and when you don’t get the results you expect, the last change is where you’re problem is.

    Know what I mean?
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 8.  Re: Lookup Table Map Rule

    Posted 04/03/09 06:18 PM

    Originally posted by: repanzer


    I just saw the attachment now. It looks like your look up table is not sorted, correct?

    Try the EXTRACT.
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 9.  Re: Lookup Table Map Rule

    Posted 04/05/09 12:01 PM

    Originally posted by: janhess


    No! Use SEARCHUP SEARCHDOWN for sorted tables. LOOKUP for unsorted tables and EXTRACT if you want to retrieve multiple values.
    #IBM-Websphere-Transformation-Extender
    #DataExchange
    #IBMSterlingTransformationExtender


  • 10.  Re: Lookup Table Map Rule

    Posted 04/06/09 08:46 AM

    Originally posted by: SystemAdmin


    ok thanks -- I don't want to return multiple values so I will continue with lookup.
    #DataExchange
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender


  • 11.  Re: Lookup Table Map Rule

    Posted 04/06/09 08:46 AM

    Originally posted by: SystemAdmin


    correct, I will try extract. thanks.
    #DataExchange
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender


  • 12.  Re: Lookup Table Map Rule

    Posted 04/05/09 12:08 PM

    Originally posted by: janhess


    {Quote}First, and just making sure, when using Lookup or lookdown, the table must be sorted on that field.{Quote}
    What's lookdown? Not in my function list. And lookup works on unsorted tables.
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 13.  Re: Lookup Table Map Rule

    Posted 04/06/09 09:17 AM

    Originally posted by: repanzer


    Whoops!

    It's literally been years since I had the need to use anything other then EXTRACT. I wasn't that far off though. :(
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 14.  Re: Lookup Table Map Rule

    Posted 04/06/09 09:23 AM

    Originally posted by: SystemAdmin


    no problem, at this point I'm willing to try anything!
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 15.  Re: Lookup Table Map Rule

    Posted 04/06/09 08:44 AM

    Originally posted by: SystemAdmin


    My table is not sorted on the airport code field. I will try moving the "IN" to see what happens. thanks.
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 16.  Re: Lookup Table Map Rule

    Posted 04/05/09 12:15 PM

    Originally posted by: janhess


    =IF (TEXTTONUMBER (LocFunctCdQual'r Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = 87,

    IF (LOOKUP ( Country Field:.:AirportLookupFile ,

    Code Field IN AirportLookupFile =
    LocNameCd Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = "USA" , "E" , "P" ))
    I think you need to use IF(PRESENT(LOOKUP as you are trying to check if the LOOKUP is returning a value.
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 17.  Re: Lookup Table Map Rule

    Posted 04/06/09 09:07 AM

    Originally posted by: SystemAdmin


    ok-I modified the table to only include USA codes, so I no longer want to lookup the value of the code, now I want to check to see if the code is present in the table. This is where I am running into a problem, when using IF(PRESENT (LOOKUP(Code Field IN Airportlookup = LocName..... I'm getting a syntax error on the rule, I'll keep working on it. thanks.
    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 18.  Re: Lookup Table Map Rule

    Posted 04/06/09 11:09 AM

    Originally posted by: janhess


    The problem is the structure of the rule is wrong.

    =IF (TEXTTONUMBER (LocFunctCdQual'r Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = 87,

    That bit is ok

    But this bit is wrong

    IF (LOOKUP ( Country Field:.:AirportLookupFile ,

    Code Field IN AirportLookupFile =
    Code Field IN AirportLookupFile ) = "USA" , "E" , "P" ))

    Do you want to match Code Field:AirportLookupFile to Code Field:AirportLookupFile(just drag the fields to get the correct name. Don't use IN)

    and if it is found output the value "USA"? What are the values "E2 and "P" for? You can only have 2 results for the lookup - found or not found. Or does the "P" relate to the 87 value? If you can explain it a bit more clearly I'll try to put it right.
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 19.  Re: Lookup Table Map Rule

    Posted 04/06/09 11:22 AM

    Originally posted by: janhess


    Is this something like what you're trying to achieve?

    =IF (TEXTTONUMBER (LocFunctCdQual'r Element:.:Group3:PAXLST_FD05B_Inbound_Partner_Msg ) = 87,

    IF(LOOKUP ( Country Field:.:AirportLookupFile ,

    Code Field:AirportLookupFile =
    LocNameCd Element:.:Group3:PAXLST_FD05B_Inbound_Partner_Msg ) = "USA" , "E"),"P" )
    #IBM-Websphere-Transformation-Extender
    #DataExchange
    #IBMSterlingTransformationExtender


  • 20.  Re: Lookup Table Map Rule

    Posted 04/06/09 11:36 AM

    Originally posted by: SystemAdmin


    Yes, that's correct. I'm trying to modify the type tree where I only have one field in the table which is the airport code. Currently my tree has the code,USA but I'm trying to make the rule simple since I know they are all USA I don't need to have that in the tree. Once thats done I think this should work:

    If(present(code, code=locname.....), "E" , "P" ) ..something like that.
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 21.  Re: Lookup Table Map Rule

    Posted 04/06/09 05:23 PM

    Originally posted by: SystemAdmin


    Thank you everyone,

    After modifying the type tree and lookup table I think I have a working solution. The new rule is:

    =IF (TEXTTONUMBER (LocFunctCdQual'r Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg ) = 87,

    IF (PRESENT (LOOKUP ( Code Field:.:AirportLookupFile ,

    LocNameCd Element:.:Group3 IN PAXLST_FD05B_Inbound_Partner_Msg =
    Code Field:.:AirportLookupFile )), "E" , "P" ))

    So far, I am getting the expected results. I want to run a few more test before I mark it answered. Thank you for the all of the ideas!
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange