Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help required with the LOOKUP function 1

Status
Not open for further replies.

mlapse

IS-IT--Management
Jun 30, 2005
82
US
Hi,

I have a LOOKUP function where I would like to examine an EDI X12 315 file and pickout the R4 segment when the location code in the R4 and the location name match the code and name in the B4 segment. In case there is no match found, i want to do the search only on the location code and finally if even that isnt found, just the location name. My function is as below:

=EITHER(LOOKUP(PortFunctionCd Element:R4 Segment:LoopR4 QO315:Inbound315, (StatusLoc Element:B4 Segment:Inbound315 = LocID Element:Loc MComposite:R4 Segment:LoopR4 QO315:Inbound315) & (LocID Element:LocID MComposite:B4 Segment:Inbound315) = (PortName Element:R4 Segment:LoopR4 QO315:Inbound315)),

LOOKUP(PortFunctionCd Element:R4 Segment:LoopR4 QO315:Inbound315, StatusLoc Element:B4 Segment:Inbound315 = LocID Element:Loc MComposite:R4 Segment:LoopR4 QO315:Inbound315),

LOOKUP(PortFunctionCd Element:R4 Segment:LoopR4 QO315:Inbound315, LocID Element:LocID MComposite:B4 Segment:Inbound315 = PortName Element:R4 Segment:LoopR4 QO315:Inbound315))

The function doesnt work when I have the following data in the input i.e. it should use the second R4. Instead it seems to pick up the first R4 even if one of the two conditions match. Ideally it should execute condition 1 through all the R4's and then move to condition 2 if nothing satisfies condition 1.

B4^^^I^20051010^1011^USSAV^MOFU^055790^L^4300^SAVANNAH^CI^6~
N9^BM^MOLU603934970A~
N9^4F^5156510~
N9^BN^603934970A~
Q2^9134672^^^^^^^^113S^^^L^ZIM SAO PAULO I~
R4^Z^UN^USSSV^SAVANNAH~
DTM^243^20051005^0741~
R4^L^UN^USSAV^SAVANNAH^US~
DTM^245^20051013^1700~
R4^D^UN^BRRIG^RIO GRANDE^BR~
DTM^245^20051031^2340^LT~
R4^M^UN^UYMVD^MONTEVIDEO^UY~

Any ideas would be helpful.
 
not familiar with your transaction but could you use a f_map. You'd have to play with this to make it work but....

if (r4=b4, f_map(PortFunctionCd Element:R4 Segment:LoopR4 QO315:Inbound315))
 
Eyetry,

How would a functional map help in this case? If the input has :

B4^^^I^20051010^1011^USSAV^MOFU^055790^L^4300^SAVANNAH^CI^6~
N9^BM^MOLU603934970A~
N9^4F^5156510~
N9^BN^603934970A~
Q2^9134672^^^^^^^^113S^^^L^ZIM SAO PAULO I~
R4^Z^UN^USSSV^SAVANNNNNAH~
DTM^243^20051005^0741~
R4^L^UN^USSAV^SAVANNAH^US~
DTM^245^20051013^1700~
R4^D^UN^BRRIG^RIO GRANDE^BR~
DTM^245^20051031^2340^LT~
R4^M^UN^UYMVD^MONTEVIDEO^UY~

the LOOKUP works just fine and brings the second R4. It seems that mercator evaluates each lookup against one R4 at a time instead of the other way around. It should evaluate the first lookup against all the R4's and if not found move to the next lookup against all R4's

Is it because the output is just one instance and the input is multiple instances which causes this ?
 
Mercator does not know that there are more R4's out there until it gets to them so yes it will evaluate each lookup on one R4 at a time. You could create a functional map to pull all of your R4's in that loop and then do your lookup.
Or in a case that I had I changed the typetree to seperate out the R4's and use the different qualifiers as the identifers in the tree. Then use the lookups according to the qualifiers.
 
Stella,

How can I extract all the R4's and send them to a functional map which has an output with a single instance. Since the output is going to be a single instance, mercator will just evaluate the first R4 and leave the rest.
 
Essentially, as your map reads each R4 segment it will evaluate it against the B4 value. if the condition is true it should execute the f_map. At that time you'll pass the values you need mapped and populate your output.

For example, we have a group that sends us an 834. Their TP refused to send us a REF*1L with the info we need (their TP doesn't want to fall under hipaa so won't send a HIPAA compliant file). What they do is send the value we want in an REF*17 segment. But just because they want to make things even more complicated they're sending 2 REF*17 segments.

They kept changing their file around until the group they processed for us understood the TP was playing a game so that we'd give in and let them send their preferred, propietary format.

First they consistently sent their data with <NL> after every 80 bytes, they didn't send and 04010X095 they sent a 4010 and the REF segment we wanted was always the second REF*17 of each INS loop. To move things along I wrote a map to deal with all conditions and it consistently took the second REF*17.

Later they changed it to randomly place the REF*17.

The good news was that the segments we needed and didn't want had some predicatability. I changed my map rule to look for the REF conditions I needed.... for example

if(member(ref02, {"17"}) &
REF03 = needed_conditions, ref03)

We also have other maps that use f_maps that might look like...

if(member(ref02, {"17"}) &
REF03 = needed_conditions, f_map(ref03, add'l_data_needed_to_process))

Anyway, might work for you.... might not.... give it a try.


 
Hi,

Since there are multiple Lookups in the same rule it might not be working correctly.
Please try using different cards for different LOOKUPS.

=EITHER(LOOKUP(PortFunctionCd Element:R4 Segment:LoopR4 QO315:Inbound315#1, (StatusLoc Element:B4 Segment:Inbound315#1 = LocID Element:Loc MComposite:R4 Segment:LoopR4 QO315:Inbound315#1) & (LocID Element:LocID MComposite:B4 Segment:Inbound315#1) = (PortName Element:R4 Segment:LoopR4 QO315:Inbound315#1)),

LOOKUP(PortFunctionCd Element:R4 Segment:LoopR4 QO315:Inbound315#2, StatusLoc Element:B4 Segment:Inbound315#2 = LocID Element:Loc MComposite:R4 Segment:LoopR4 QO315:Inbound315#2),

LOOKUP(PortFunctionCd Element:R4 Segment:LoopR4 QO315:Inbound315#3, LocID Element:LocID MComposite:B4 Segment:Inbound315#3 = PortName Element:R4 Segment:LoopR4 QO315:Inbound315#3))


 
You can't use multiple LOOKUPs in the same rule on the same data. There are several previous posts regarding LOOKUP describing this behaviour which cover the reason behind it.
 
I tried to use a function as follows :

=EITHER( f_getporttype_id(Inbound315), f_getporttype_name_and_id(Inbound315),f_getporttype_name(Inbound315), "I")

First it goes to one function and if that returns NONE it goes to the next and so on.

Each function has an EXTRACT in it to get the data based on the condition

However even this doesnt seem to work. If the conditions for the first function are not matched, it returns NONE.

Any ideas why ?
 
Samji,

I even tried creating a funcional map where I passed the data to three separate input cards. But it still doesnt seem to work.

This is frustrating. Can anybody help here?
 
Correction.

Samji's solution seems to work. I guess copying the input over and over again for each lookup does it.

Only thing is that if I have to evaluate 20 lookups in an either statement, does that mean I need to pass the inupt 20 times?

mlapse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top