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

Experts opinions needed - looping

Status
Not open for further replies.

mlapse

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

This is a pretty tough and interesting problem. Im stuck and am quite confused about how to proceed. Any help would be GREATLY appreciated.

I built a map which uses the input type tree as EDI. The type tree consists of ISA, GS, ST, UNA, UNB, UNH , SE, GE, IEA, UNT, UNG and UNZ segments. All of these are optional. Within the UNH and ST, I created something called a dummy segment. It consists of a segment with a segment type and then the data. Reason I did this was that when Mercator receives any data, it will be able to figure out the segment type from the delimiter in the ISA or UNA segments.

The output tree is a flat file which has Interchange details then the data elements within the EDI message. I have 20 data elements identified ex: BL_Number, Container_Number etc. which should take care of all the EDI messages we use.

The map using these type trees takes the EDI file as the input and based on a config file it populates the data eleents using the segment type and the position of the data in that segment. Just used a word function for this.

Problem:
--------
My problem is that I can parse out dat which occurs once using this method. However in case of an 856 message we could have the message organized based on formats like BL then Containers within the BL and then Orders within the containers. The order could be anything.

My question is, is there any way I could parse the data in loops within the EDI using a mercator map. This could be specific to 856's also. I want the map to be able to loop based on a config file and also to know that the data elements are related. Remember: I need the loops to be generic for any message so I cant hardcode the segment types since they would be different for diff messages.

It sounds complex. If you want me to send you the codes so far, let me know and I can send you the generic parser I have so far.

Thanks a lot in advance!
 
Can you replace the the rule with the WORD function by a functional map which should handle the multiple occurrences of the input data?
 
janhes,

thanks. but let me give you an example of the 856 we use:

format A:

ST
BSN
TD3
PRF
PRF
TD3
PRF
TD3
SE

format B:
ST
BSN
PRF
TD3
TD3
PRF
TD3
PRF
SE

so what seems to be happening is that the logical looping is that a BSN can have TD3's which in turn have PRF's. Or a BSN can have PRF's which have TD3's.

I need my output to be of the following format
BSN,TD3,PRF
BSN,TD3,PRF
i.e. for every PRF i need to be able to pull the TD3 above it and the BSN. However I cannot link all PRF's with all TD3's only the ones logically looped together.

I would like this to be genric whereby I can specify any kind of looping and use it.
 
I'm a bit confused by your 856 layout. It doesn't look like the example formats on the web. There the TD3 is part of the Shipment segment and PRF is part of the Order segment.
 
Not familiar with the 856, however, If the TD3 segments are conditional to a preceding PRF segment could you build your tree using groups like



ST
-BSN
-TD3 (0:n)
-PRF(group) (0:n)
--PRF (1:1)
--TD3 (0:1)
SE

 
janhes, eyetry,

Creating a type tree based on the segments means I have to either incorporate all possible segments into the type tree at all levels. However different partners may recieve diff segments based on their requirement. Also the segments may be in diff orders for each customer.

I need something generic. I can use the std mercator typre tree but again i wouldnt know the order of the HL loops. Logically the HL shipment loop could be before the BL loop or it could also be after the BL loop.

janhes,

if you look at the mercator type tree, the shipment, container and BL loops can all be separate and they would be just HL loops. However logically they may be related i.e. the shipment loop may be followed by a BL then all containers with that BL. Another format may have the shipment, then orders and then all containers.

Its all based on the partner's choice.

thanks
 
Aren't HLs linked by Hierarchical Parent ID Number?
 
yes they are but they are optional. most partners dont send them.
 
Again, not an expert but I looked at the 4030 856. In the 4030 I did not see a BL loop. Without the BL it looks like the proper structure is something like...

ST (SEG)
BSN (SEG)
DTM (SEG 0:10)
HL (LOOP 1:2k)
-HL (SEG)
-MISC (SEGS 0:1 EACH)
-PRF (SEG 0:1)
-MISC (SEGS 0:1 EACH)
-TD3 (LOOP 0:12)
--TD3 (SEG)
--AT3 (SEG 0:1)
-MISC (SEGS AND LOOPS)
SE (SEG)

I also didn't see the UN* segments but I did see the UCS. Other than that I'm not sure what to tell you.
 
eyetry,

Thanks for looking at this. ok now you see there are 1:2k HL loops correct?

Each HL loop indicates whether it is a shipment loop, a equipment loop an order loop or an item loop. This is done by the third element (it would be an S, E, O, I respectively) Based on the type of loop the corresponding segment would have data ex: when the HL loop has an E, the TD3 would have the container number. When it is O, the PRF would have the order number.

Now my issue it that I need to relate the loops together based on their occurrence which would be different for diff partners. ex one partner may want the Shipment loop followed by the equipment loops followed by the order loops. Howver another may want the shipment loop and then each equipment loop and immediately after one equipment loop and before the next they qould want the order loop for the order within the equipment.

Im trying to figure out how to relate these loops logically ex: this shipment contains 3 equipments; the first equipment has two orders ; the second 1 order and the third 2 orders

The EDI for the above would be
ST
BSN
...
HL*!*S
...
HL*2*E
...
HL*3*O
...
HL*4*O
...
HL*5*E
...
HL*6*O
...
HL*7*E
...
HL*8*O
...
HL*9*O
...
SE
 
So can't you just specify the loops as unordered with the loop type as the identifier?
 
Would this work?

HL01 = HL#
HL02 = PARENT HL#
HL03 = CODE
HL04 = CHILD HL#(0 = NO SUBORDINATE HL LOOPS, 1 = IS SUB HL)

ST
BSN
...
HL*1**S*1
...
HL*2*1*E*0
...
HL*3*1*O*0
...
HL*4**O*1
...
HL*5*4*E*0
...
HL*6**O*1
...
HL*7*6*E*0
...
HL*8**O*0
...
HL*9**O*0
...
SE

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top