x12 856 ASN output order

107 views
Skip to first unread message

Kevin Peroni

unread,
Dec 23, 2016, 5:49:40 PM12/23/16
to Bots Open Source EDI Translator
Hello,

I'm working on our outgoing 856 translation but I've run into an issue with the order of the segments. The PRF segment is supposed to appear between HL at the order level and the HL at the pack level. I'm using the standard 856004010 grammar. I've put the translation below. Any help would be greatly appreciated. Thanks, Kevin

BSN*00*123456*20161223*1730~
HL*1**S~
PRF*16103102***20150108~                                        <--- IT IS APPEARING HERE
TD1*PLT90*5****G*1150*LB~
TD5***PRLA*M*Purolator Freight~
REF*VR*G3YY~
REF*2I*xxxx~
PER*DI*MARTIN MARTIN*TE*888-888-8888 EXT 303~
DTM*011*20161223~
N1*MA**92*0428~
HL*10*1*O~
                                                                                  <--- IT SHOULD BE HERE
HL*100*10*P~
MAN*GM*XS400-3900-BND-BL~


TRANSLATION:

#mapping-script
import bots.transform as transform
import time


def main(inn,out):
    #sender, receiver is correct via QUERIES in grammar. 
    out.put({'BOTSID':'ST','ST01':'856','ST02':out.ta_info['reference'].zfill(4)})
    
    out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN01':'00'})
    out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN02':inn.get({'BOTSID':'message','bolnumber':None})})
    out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN03':time.strftime('%Y%m%d')})
    out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN04':time.strftime('%H%M')})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL','HL01':'1'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL','HL02':''})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL','HL03':'S'})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'TD1','TD101':'PLT90'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'TD1','TD102':inn.get({'BOTSID':'message','numpallets':None})})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'TD1','TD106':'G'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'TD1','TD107':inn.get({'BOTSID':'message','grossweight':None})})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'TD1','TD108':'LB'})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'TD5','TD503':'PRLA'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'TD5','TD504':'M'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'TD5','TD505':'Purolator Freight'})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'REF','REF01':'VR'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'REF','REF02':inn.get({'BOTSID':'message','vendorref':None})})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'REF','REF01':'2I'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'REF','REF02':'xxxx'})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'PER','PER01':'DI'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'PER','PER02':'MARTIN VASILEV'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'PER','PER03':'TE'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'PER','PER04':'888-602-7328 EXT 303'})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'DTM','DTM01':'011'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'DTM','DTM02':time.strftime('%Y%m%d')})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'N1','N101':'MA'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'N1','N103':'92'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'N1','N104':inn.get({'BOTSID':'message','storenum':None})})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL','HL01':'10'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL','HL02':'1'})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL','HL03':'O'})

    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'PRF','PRF01':inn.get({'BOTSID':'message','docnum':None})})
    out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'PRF','PRF04':transform.datemask(inn.get({'BOTSID':'message','docdtm':None}),'CCYY-MM-DD HH:mm','CCYYMMDD')})

    itemCnt = 100;
    for itm in inn.getloop({'BOTSID':'message'},{'BOTSID':'items'},{'BOTSID':'item'}):
        itmnode = out.putloop({'BOTSID':'ST'},{'BOTSID':'HL','HL01':itemCnt})
        itmnode.put({'BOTSID':'HL','HL02':'10'})
        itmnode.put({'BOTSID':'HL','HL03':'P'})
        itmnode.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN01':'GM'})
        itmnode.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN02':itm.get({'BOTSID':'item','namenumber':None})})
        itmnode.put({'BOTSID':'HL'},{'BOTSID':'N1','N101':'MA'})
        itmnode.put({'BOTSID':'HL'},{'BOTSID':'N1','N103':'92'})
        itmnode.put({'BOTSID':'HL'},{'BOTSID':'N1','N104':inn.get({'BOTSID':'message','storenum':None})})
        itemCnt += 1

    for lin in inn.getloop({'BOTSID':'message'},{'BOTSID':'lines'},{'BOTSID':'line'}):
        lineCnt = 200;
        ponode = out.putloop({'BOTSID':'ST'},{'BOTSID':'HL','HL01':lineCnt})
        ponode.put({'BOTSID':'HL','HL02':'100'})
        ponode.put({'BOTSID':'HL','HL03':'I'})
        ponode.put({'BOTSID':'HL'},{'BOTSID':'LIN','LIN01':lin.get({'BOTSID':'line','linenum':None})})
        ponode.put({'BOTSID':'HL'},{'BOTSID':'LIN','LIN02':'SK'})
        ponode.put({'BOTSID':'HL'},{'BOTSID':'LIN','LIN03':lin.get({'BOTSID':'line','sku':None})})
        ponode.put({'BOTSID':'HL'},{'BOTSID':'LIN','LIN04':'UP'})
        ponode.put({'BOTSID':'HL'},{'BOTSID':'LIN','LIN05':lin.get({'BOTSID':'line','gtin':None})})
        ponode.put({'BOTSID':'HL'},{'BOTSID':'SN1','SN102':lin.get({'BOTSID':'line','ordqua':None})})
        ponode.put({'BOTSID':'HL'},{'BOTSID':'SN1','SN103':'EA'})
    
    out.put({'BOTSID':'ST'},{'BOTSID':'CTT','CTT01':out.getcountoccurrences({'BOTSID':'ST'},{'BOTSID':'HL'}) }) #bots counts line items
    out.put({'BOTSID':'ST'},{'BOTSID':'SE','SE01':out.getcount()+1,'SE02':out.ta_info['reference'].zfill(4)})  #SE01: bots counts the segments produced in the X12 message.

henk-jan ebbers

unread,
Dec 23, 2016, 6:23:06 PM12/23/16
to bots...@googlegroups.com
hi Kevin,

with each HL using putloop.

also: see ASN mapping in plugin x12toxml_supplier_version850-856-810-997

or: if you write: out.put({'BOTSID':'ST'},{'BOTSID':'HL'},{'BOTSID':'PRF','PRF01':inn.get({'BOTSID':'message','docnum':None})})

how do you expect bots knows how to write to correct HL-loop?


kind regards

henk-jan
> --
> 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 <mailto:botsmail+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages