Extract DESADV to CSV

139 views
Skip to first unread message

Tan Tran

unread,
Dec 8, 2020, 5:03:51 AM12/8/20
to Bots Open Source EDI Translator
Hi,

I'm extracting an DESADV into separate CSV files (one for header and one for lines)

CSV #1 - contain only header column:
1. 'RFF','C506.1153'
2. 'NAD','3035'
3. 'GIN','C208#1.7402#1

CSV #2 - contain lines column:
1. 'LIN','1082'
2. 'LIN','C212.7140'
3. 'QTY','C186.6060'

So far so good except when I ingest 2 csv to sql database into 2 separated tables called "Header" and "Lines", I can't figure out how to reference lines to header via GIN column.

For example,  each GIN can contains multiple Lines.

Can someone share idea how can I achieve this goal?

Thank you,

Tan.T


Eppye Bots

unread,
Dec 8, 2020, 5:32:01 AM12/8/20
to 'Chuck Turco' via Bots Open Source EDI Translator
what is the goal exactly?
a shipment contains ShippingUnits; each shipping unit can contain multiple items. (Some sectors use only one item per shipping unit)
what is the goal of the referencing?

kind regards, Henk-Jan Ebbers


--
You received this message because you are subscribed to the Google Groups "Bots Open Source EDI Translator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to botsmail+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/botsmail/4cecb40e-9df1-42b9-a3e6-fed5e5087f3en%40googlegroups.com.

Tan Tran

unread,
Dec 8, 2020, 6:22:01 AM12/8/20
to Bots Open Source EDI Translator
Hi Henk-Jan,

The goal is we're inserting each ASN into 2 tables (header and lines) and these records are inner join by GIN. We have an application that scan printed SSCC label and update certain columns in header / lines table.

So I'm hoping I can:

CSV #1 - header column:

1. GIN

CSV #2 - contain lines column:

1. GIN

CSV #1 inner join CSV #2 ON GIN

Thank you,

Tan.T

Eppye Bots

unread,
Dec 8, 2020, 6:28:53 AM12/8/20
to 'Chuck Turco' via Bots Open Source EDI Translator
not sure I understand.
header = message, message has an unique ID. Do not think a SSCC/ShippingUNitID is useful in the header?



but:
the unique key to your 'lines' table is

kind regards, Henk-Jan Ebbers


Tan Tran

unread,
Dec 8, 2020, 6:48:19 AM12/8/20
to Bots Open Source EDI Translator
Hi Henk-Jan,

It makes more sense when someone hold a scanner and scan a box with printed SSCC label in front.

Application pickups this SSCC and lookup up Header table and pull OrderID, InvoiceID and List of Items (barcode + quantity).

User perform some action (check-in etc...) on these records and submit. These will update header / lines table such as Check-in date etc...

Thank you

Tan.T

Eppye Bots

unread,
Dec 8, 2020, 6:49:55 AM12/8/20
to 'Chuck Turco' via Bots Open Source EDI Translator
what is the key to header table?
messageID or SSCC?

kind regards, Henk-Jan Ebbers


Tan Tran

unread,
Dec 8, 2020, 6:51:00 AM12/8/20
to Bots Open Source EDI Translator
SSCC

Eppye Bots

unread,
Dec 8, 2020, 6:53:55 AM12/8/20
to 'Chuck Turco' via Bots Open Source EDI Translator
than why do you call the table 'header'? ;=))))
so.... key of 'header' table is SSCC....
use SSCC in line table to refer to 'header' table.
does that make sense/help?


kind regards, Henk-Jan Ebbers


Tan Tran

unread,
Dec 8, 2020, 7:00:26 AM12/8/20
to Bots Open Source EDI Translator
Hi Henk-Jan,

That's exactly I'm aiming for. Joining 2 tables via SSCC

When I loop through LIN, it does not find GIN. GIN only appears in PCI

Can you shed me light how I can extract GIN at LIN loop? or other way to archieve the goal (SSCC on both table)

Thank you,

Tan.T

Eppye Bots

unread,
Dec 8, 2020, 7:03:01 AM12/8/20
to 'Chuck Turco' via Bots Open Source EDI Translator
loop over CPS.
- extra PAC-GIN
- extract LINs

kind regards, Henk-Jan Ebbers


Tan Tran

unread,
Dec 8, 2020, 7:04:39 AM12/8/20
to Bots Open Source EDI Translator
BTW, Header and Lines term I used is more related retail transaction, not EDI.

These table schema is designed by a retail sector. Hence, it's name Header and Lines of a sale transaction.

Tan Tran

unread,
Dec 8, 2020, 7:08:16 AM12/8/20
to Bots Open Source EDI Translator
In a single loop or 2 separated loop?

Eppye Bots

unread,
Dec 8, 2020, 7:11:32 AM12/8/20
to 'Chuck Turco' via Bots Open Source EDI Translator
yes, but in order we have ONE header, multiple lines.
in invoice: one header, multiple lines.

now DESADV has multiple headers, where one header represents a Shipping Unit.
I hope you understand the confusion.


kind regards, Henk-Jan Ebbers


Tan Tran

unread,
Dec 8, 2020, 7:23:19 AM12/8/20
to Bots Open Source EDI Translator
Hi Henk-Jan,

Loop CPS - total 3 iteration because only 3 GIN.
  Extract all GIN
  LIN - only 3 Lines because only 3 iteration.

How can i extract all lines belong to each GIN?

Eppye Bots

unread,
Dec 8, 2020, 7:28:00 AM12/8/20
to 'Chuck Turco' via Bots Open Source EDI Translator
something like:
for CPS in inn.getloop(UNH.CPS):
    SSCC = CPS.get(PAC.PCI.GIN)
    for LIN in CPS.getloop(CPS.LIN)

probably you will have to skip first CPS.

(assuming this is a fairly 'standard' retail DESADV)

kind regards, Henk-Jan Ebbers

Tan Tran

unread,
Dec 8, 2020, 7:30:05 AM12/8/20
to Bots Open Source EDI Translator
Thank you, Henk-Jan.

I'll give that a shot.

Tan Tran

unread,
Dec 9, 2020, 5:40:54 PM12/9/20
to Bots Open Source EDI Translator
Hi Henk-Jan,

Thank you very much for your guidance.

I'm able to include GIN in each LIN record when extracting into csv.

Tan.T
Reply all
Reply to author
Forward
0 new messages