IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: mbaile
About
User Name: mbaile
Forum Rank: Newbie
Real Name:
Location USA
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Monday, January 29, 2018
Last Visit: Tuesday, July 9, 2019 12:38:58 PM
Number of Posts: 6
[0.03% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: HL Hierarcy for EDI to XML Mapping
Posted: Tuesday, July 9, 2019 12:36:02 PM
I am working on mapping an edi 857 file to an XML file that is used internally. In the edi 857 file, I have multiple HL hierarchies that I'm having trouble associating with one another. The hierarchical structure is Shipment>Order>Item>Package. I've included a full example. In this case you can see that the HL*1**S~ is the top level with "S" standing for shipment, and inside of that we have an HL with an "O" for order, then an "I" for item, and finally a "P" for package. What I'm having trouble with is associating the shipping method in the "S" segment with the Order "O" segments below it (or the "O" segments with the "S" segments above it). When I only have a single "S", it works fine as I only have one shipping method, however when I have more than one, each order is split properly but I get any and all shipping methods listed with each order instead of only the shipping method that should be associated with it. I've included a sample of a single Shipment file and one with two shipments for reference.

SINGLE SHIPMENT SAMPLE where shipment method is UPSGSCNA
ISA*00* *00* *ZZ*LSI *ZZ*SHEBUS *190706*2109*U*00200*000000175*0*P*>~
GS*BS*LSI*SHEBUS*190706*2109*175*X*003060~
ST*857*1750001~
BHT*0002*00*475932*190706*210324~
HL*1**S~
G05*1*UN*1.52*LB***1*CT~
TD5**ZZ*Miscellanous**UPSGSCNA~
DTM*011*190708~
HL*2*1*O~
TDS*1150~
N9*VI*648184*****CO>787798~
N9*PK*5340295~
ISS*1*UN*1.52*LB*1*CT~
SAC*C*D240***1150~
HL*3*2*I~
IT1*1*1*EA*0******EN*2370009469381~
CTP**INV*5.93~
HL*4*3*P~
PAL*4***1*1.52*LB~
MAN*GM*00000388087172608260**CP*1ZW3985X0333289428~
SE*19*1750001~
GE*1*175~
IEA*1*000000175~

MULTIPLE SHIPMENT SAMPLE where shipment methods are DHL4PRI and UPSGSCNA
ISA*00* *00* *ZZ*LSI *ZZ*SHEBUS *190624*2126*U*00200*000000157*0*P*>~
GS*BS*LSI*SHEBUS*190624*2126*157*X*003060~
ST*857*1570001~
BHT*0002*00*474902*190624*210526~
HL*1**S~
G05*2*UN*3.02*LB***2*CT~
TD5**ZZ*Miscellanous**DHL4PRI~
DTM*011*190624~
HL*2*1*O~
TDS*275~
N9*VI*643880*****CO>779553~
N9*PK*5311599~
ISS*1*UN*0.96*LB*1*CT~
SAC*C*D240***275~
HL*3*2*I~
IT1*1*1*EA*0****IB*0871522896*EN*9780871522894~
CTP**INV*5.99~
HL*4*3*P~
PAL*4***1*0.96*LB~
MAN*GM*00000388087247691289**CP*92419999916655583007787883~
HL*5*1*O~
TDS*379~
N9*VI*644116*****CO>779904~
N9*PK*5312026~
ISS*1*UN*2.06*LB*1*CT~
SAC*C*D240***379~
HL*6*5*I~
IT1*1*1*EA*0****IB*0871521962*EN*9780871521965~
CTP**INV*10.28~
HL*7*6*P~
PAL*4***1*2.06*LB~
MAN*GM*00000388087247691258**CP*92419999916655583007787869~
HL*8**S~
G05*25*UN*54.88*LB***3*CT~
TD5**ZZ*Miscellanous**UPSGSCNA~
DTM*011*190624~
HL*9*8*O~
TDS*4196~
N9*VI*643620*****CO>778933~
N9*PK*5308739~
ISS*25*UN*54.88*LB*3*CT~
SAC*C*D240***4196~
HL*10*9*I~
IT1*1*25*EA*0****IB*0930233360*EN*9780930233365~
CTP**INV*8.58~
HL*11*10*P~
PAL*4***12*26.29*LB~
MAN*GM*00000388087247633319**CP*1Z4E0R320327082223~
HL*12*10*P~
PAL*4***12*26.29*LB~
MAN*GM*00000388087247633425**CP*1Z4E0R320327080154~
HL*13*10*P~
PAL*4***1*2.3*LB~
MAN*GM*00000388087247705979**CP*1Z4E0R320327078201~
SE*53*1570001~
GE*1*157~
IEA*1*000000157~
Topic: Using one value UNLESS you see another value,then use that?
Posted: Thursday, December 6, 2018 2:37:44 PM
That makes sense, thanks for the clarification. In the 27 sample orders provided to us, there are many that have multiple D1's (order lines) in some of the orders, but in the case where a D3 has been provided, we only have one D1 line. This is good as the ISBN in the D1 corresponds to the title from the D3. Even though there are only one of each, I still can't pull the title so I'll have to get the filter logic together to pull that data. This will be even more important if we ever get a file with multiple D1's and multiple D3's as we'll have to link them together somehow (I'll also confirm with our customer if this will ever happen).

Looking at the file, I'm not sure what to filter on and don't see anything that corresponds between the D1 and D3 elements...I thought something like that would be simple..shows what I know!

Thanks again for all of your help, much appreciated.
Topic: Using one value UNLESS you see another value,then use that?
Posted: Wednesday, December 5, 2018 6:22:07 PM
Brilliant...I struggled with that for hours and hours. Thank you!

I'm stuck on one last piece that I was hoping to figure out on my own, but I think there may be some conflict going on. Aside from the information that I mentioned earlier, I also have some other some other data which I've sampled below. Each time we see an H1, this signifies a new order. Each H1 will have at least one H2 and one D1. We could have two or three H2 values and multiple D1 values. The H2 values are address variants and the D1 values are products. Occassiaionlly, we'll also have a D3 entry. If we see the D3 value, then we want to pass along some data from within this field. For some reason, I'm not able to pull data out of this D3 and into where I want to.

I'm specifically looking at the order on lines 95-99. This is the 19th order in the file. I can map this to one area of the end xml file, but not to others. I've attached my files and mapping. Is there some reason that I can map the title field to one place in the file, but not another?



H1
H2
D1

H1
H2
D1

H1
H2
H2
D1
D3

On a side note, I used your earlier logic a little differently since I had all the fields already there, so I just added in the exists logic and drew my connections, it's working great!
Topic: Using one value UNLESS you see another value,then use that?
Posted: Wednesday, December 5, 2018 2:12:02 PM
I'm working with a flat file that has orders separated by a header line. I have the order separation working, but within each order I have an H2 line with address information. In all cases, I'll have one with a type of ST like this:

H2 ST ADD1 ADD2 ADD3 CITY STATE ZIP COUNTRY

In some cases, I'll have an address type of CS in addition to this:

H2 ST ADD1 ADD2 ADD3 CITY STATE ZIP COUNTRY
H2 CS ADD1 ADD2 ADD3 CITY STATE ZIP COUNTRY


What i need to do is say: "If you have an H2 with a type of CS, then use the address information from that line. Else, use the address information from the ST line".

Topic: Removing Leading Zero's
Posted: Wednesday, December 5, 2018 1:59:40 PM
That's perfect, thank you!
Topic: Removing Leading Zero's
Posted: Tuesday, December 4, 2018 9:38:43 PM
I'm trying to remove leading 0's at the beginning of a string. I found this post: https://www.altova.com/forum/default.aspx?g=posts&t=7 , but I can't seem to get it to work.

My function itself and what I have in the mapping look to just be the same which is likely why it's not working, but I cannot figure this one out. I'm sure it's something simple, but any input is appreciated. The first picture is the function itself, and the second is the function within the mapping.




Use of the Altova User Forum(s) is governed by the Altova Terms of Use.