try this mapping code (still errors, but much better);;
#mapping-script
#~ from x12lib import get_art_num #import x12 specifc helper function
import bots.transform as transform #import div bots helper functions
def main(inn,out):
docnum = inn.get({'BOTSID':'message','docdtm':None})
inn.ta_info['botskey']=docnum
out.ta_info['botskey']=docnum
#convert dates to right internal format
docdtm = inn.get({'BOTSID':'message','docdtm':None})
#docdtm = transform.datemask(docdtm,'CCYY-MM-DD','CCYYMMDD')
out.put({'BOTSID':'ST','ST01':'856','ST02':out.ta_info['reference'].zfill(4)})
out.put({'BOTSID':'ST'},{'BOTSID':'XQ','XQ01':'H','XQ02':docdtm})
#loop over partys
for party in inn.getloop({'BOTSID':'message'},{'BOTSID':'partys'},{'BOTSID':'party'}):
pou = out.putloop({'BOTSID':'ST'},{'BOTSID':'N1'})
pou.put({'BOTSID':'N1','N101':party.get({'BOTSID':'party','qual':None})})
#loop over lines
for po1 in inn.getloop({'BOTSID':'message'},{'BOTSID':'lines'},{'BOTSID':'line'}):
lou = out.putloop({'BOTSID':'ST'},{'BOTSID':'LIN','LIN02':'UP','LIN03':'LIN'})
#~ lou = out.putloop({'BOTSID':'ST'},{'BOTSID':'N9','N901':'ZZ','N902':'Product'}) #no idea what this should do
offset = 6
gtin = po1.get({'BOTSID':'line','gtin':None})
if gtin:
#loop over detail
for detail in inn.getloop({'BOTSID':'message'},{'BOTSID':'lines'},{'BOTSID':'line'},{'BOTSID':'details'}):
dou = out.putloop({'BOTSID':'ST'},{'BOTSID':'LIN'},{'BOTSID':'ZA'})
dou.put({'BOTSID':'ZA','ZA01':'QE','ZA02':'QE'[3:3]})
out.put({'BOTSID':'ST'},{'BOTSID':'CTT','CTT01':out.getcountoccurrences({'BOTSID':'ST'},{'BOTSID':'PO1'}) }) #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.
On 04/17/2017 11:17 PM, Brent Holtsclaw wrote: