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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex situation.... 1

Status
Not open for further replies.

vrs1008

Programmer
Sep 16, 2003
62
0
0
US
Hi,

I am using ansix12 x4010 std tree as input. DTP segment occurs (0:10) times in HD loop.

Input File has:-

DTP*301*D8*20010101**
DTP*348*D8*20020202**
DTP*303*D8*20030303**

Business says that i need to map 4th element of the DTP segment (date part) , if second element is 303. If 303 is not there then i need to do the mapping from DTP*348.

i have tried few cobinations using IF,Lookup functions, but could not find the result especially in above case, where both DTP*348 & DTP*303 are there in the file and DTP*348 occures before DTP*303.

It always maps the DTP*348 first in this case.


Regards,
Vibhav Shah

Regards,
Vibhav1008
 
Try sorting the data before you start by using SORTUP or SORTDOWN
 
hi vibhav,

happy new year, did u solve that sorting dtp, if u got could u explain me, how u did..
mu emial id is...looking forward for ur reply soon.
skumarp76@yahoo.com

thanks
sk

 
Hi Kumar,

What you can do in this case instead of sorting the data is create a functional map say F_DTP and pass 2 instances of the same segment i.e. DTP segment like :
F_DTP(DTP,DTP) and name the input cardes in the func map as DTP1 and DTP2

then you can use the command Either as shown below :

Either ( LookUp ( 4th element DTP1, 2nd element of DTP1="303") ,
LookUp ( 4th element DTP2, 2nd element of DTP2="348") )

This will give you the required result.
Hope this helps. Feel free to ask incase if you need further clarifications.

Please note LookUp most of the time gives unwanted results when you use this function more than once on the same segment that is why 2 DTP segs being passed to above functional map might not be always true.

cheers,
Shrini.
 
This may be late but I use Member statements... See if I can write this from mem...

If (member (loop:segment:dtp02), "303"), then DTP04,
If (member (loop:segment:dtp02), "348"), then DTP04,
.....

This will look at all the DTP segments at within the loop described for a member value of 303 in dtp02. If found grabs DTP04. If not it looks for a 348 in DTP02.

I check for dates in the 834 HD loop first, then move to the INS DTP segments based on how we defined our priority.

eyetry
 
Hi,

If you see the q? the data is :
DTP*301*D8*20010101**
DTP*348*D8*20020202**
DTP*303*D8*20030303**

so as u can see there are multiple DTP segements so you need to lookup for each occurance of DTP segment in which case LookUp can be used to find the particular value but as I explained earlier there is some problem with LookUp statement in Mercator if try to LookUp the same segment more than once.

And now coming to ur answer Member function doesn't scan thru all the occurance of any segment, rather it gives a facilty to find whether the value present in a particular field is either "a" or "b" or "c" and if at all it finds the option it gives u true if found and false if not found.
Its like case statement in C language if u know it.

Hope I am able to explain my points clearly.

cheers,
Shrini.
 
I like your use of the 'either' function. Believe I'm using that somewhere in conjunction with the member function as well.

I had a client that was using the DTP segments incorrectly but stated they'd use them in a consistent fashion (decision to use a non-compliant format was intentional). For example INS loop, DTP Segment occurrence 2 will always contain value 'X' in DTP02. One day they changed the DTP segment order. Upon reviewing other x12 files determined that other groups didn't always order their DTP segments the same way from loop to loop or file to file. The other group’s data processed successfully because we looked for values based on a hierarchy as opposed to an expected order.

With X12 data, when I can, I stay away from coding based on expecting data in a specific order. It usually ends up as custom code or something cumbersome to maintain.

eyetry


 
Shrini4u is correct, multiple lookups etc. on the same data element results in "data binding". Basically we found it already so why look again. Either is one of the functions that can be used.

BocaBurger
<===========================||////////|0
The pen is mightier than the sword, but the sword hurts more!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top