Hi henk-jan,
You are correct!
I did this by exporting the data into a csv file and then using excel created a macro that rearranged the data into the required fields so I could translate it using Bots.
At the moment I only have one trading partner that requires an 856 but I'm sure there will be more and I will probably just create another set of mappings, etc to meet there changes/requirements.
Thanks for your advice, I will keep trying to improve what I have already created using your suggestions.
Below are my input csv file layout and mapping so it may help others to use or improve what I have done.
[order.csv]
HEA,LDLLC,THEBUCKLE,ON456789,4
HLL,1,,S,CTN71,55,G,55,LB,1,2,UPSG,BM,125563,011,20120621,ST,The Buckle Inc,92,900,2915 W 16th Street,Suite x,Kearney,NE,68845,SF,Logistics Depot
HLL,2,1,O,,,,,,,,,,,,,BY,,92,900,,,,,,,,P0345678,120605,IV,9995511,IT,1122334
HLL,3,2,P,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,GM,00007287900000256222,GM,00007287900000256223,GM,00007287900000256224,GM,00007287900000256225
HLL,4,3,I,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,UP,BU12341234,30,EA
[\order.csv]
[Mapping]
#mapping-script
import time
import bots.transform as transform
def main(inn,out):
out.put({'BOTSID':'ST','ST02':out.ta_info['reference'],'ST01':'856'})
out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN01':'00'}) #PURPOSE CODE 00=ORIGINAL
out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN02':out.ta_info['reference']})
out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN03':time.strftime('%y%m%d')}) #WRITES CURRENT DATE
out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN04':time.strftime('%H%M')}) #WRITES CURRENT TIME
out.put({'BOTSID':'ST'},{'BOTSID':'BSN','BSN05':'0001'}) #PURPOSE CODE = 0001 Shipment
for lin in inn.getloop({'BOTSID':'HEA'},{'BOTSID':'HLL'}):
lou = out.putloop({'BOTSID':'ST'},{'BOTSID':'HL'})
lou.put({'BOTSID':'HL','HL01':lin.get({'BOTSID':'HLL','HL01':None})})
lou.put({'BOTSID':'HL','HL02':lin.get({'BOTSID':'HLL','HL02':None})})
lou.put({'BOTSID':'HL','HL03':lin.get({'BOTSID':'HLL','HL03':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'TD1','TD101':lin.get({'BOTSID':'HLL','TD101INFO':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'TD1','TD102':lin.get({'BOTSID':'HLL','TD102INFO':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'TD1','TD106':lin.get({'BOTSID':'HLL','TD106INFO':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'TD1','TD107':lin.get({'BOTSID':'HLL','TD107INFO':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'TD1','TD108':lin.get({'BOTSID':'HLL','TD108INFO':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'TD5','TD501':lin.get({'BOTSID':'HLL','TD501INFO':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'TD5','TD502':lin.get({'BOTSID':'HLL','TD502INFO':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'TD5','TD503':lin.get({'BOTSID':'HLL','TD503INFO':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'REF','REF01':lin.get({'BOTSID':'HLL','REF01':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'REF','REF02':lin.get({'BOTSID':'HLL','REF02':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'DTM','DTM01':lin.get({'BOTSID':'HLL','DTM01':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'DTM','DTM02':lin.get({'BOTSID':'HLL','DTM02':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1','N101':lin.get({'BOTSID':'HLL','N101':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1','N102':lin.get({'BOTSID':'HLL','N102':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1','N103':lin.get({'BOTSID':'HLL','N103':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1','N104':lin.get({'BOTSID':'HLL','N104':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1'},{'BOTSID':'N3','N301':lin.get({'BOTSID':'HLL','N301':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1'},{'BOTSID':'N3','N302':lin.get({'BOTSID':'HLL','N302':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1'},{'BOTSID':'N4','N401':lin.get({'BOTSID':'HLL','N401':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1'},{'BOTSID':'N4','N402':lin.get({'BOTSID':'HLL','N402':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1'},{'BOTSID':'N4','N403':lin.get({'BOTSID':'HLL','N403':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1','N101':lin.get({'BOTSID':'HLL','N101A':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'N1','N102':lin.get({'BOTSID':'HLL','N102A':None})})
# New HLL line starts here
lou.put({'BOTSID':'HL'},{'BOTSID':'PRF','PRF01':lin.get({'BOTSID':'HLL','PRF01':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'PRF','PRF04':lin.get({'BOTSID':'HLL','PRF04':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'REF','REF01':lin.get({'BOTSID':'HLL','REF01A':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'REF','REF02':lin.get({'BOTSID':'HLL','REF02A':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'REF','REF01':lin.get({'BOTSID':'HLL','REF01B':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'REF','REF02':lin.get({'BOTSID':'HLL','REF02B':None})})
# New HLL line starts here
if lin.get({'BOTSID':'HLL','MAN01A':None}):
lou.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN01':'GM','MAN02':lin.get({'BOTSID':'HLL','MAN02A':None})})
if lin.get({'BOTSID':'HLL','MAN01B':None}):
lou.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN01':'GM','MAN02':lin.get({'BOTSID':'HLL','MAN02B':None})})
if lin.get({'BOTSID':'HLL','MAN01C':None}):
lou.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN01':'GM','MAN02':lin.get({'BOTSID':'HLL','MAN02C':None})})
if lin.get({'BOTSID':'HLL','MAN01D':None}):
lou.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN01':'GM','MAN02':lin.get({'BOTSID':'HLL','MAN02D':None})})
if lin.get({'BOTSID':'HLL','MAN01E':None}):
lou.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN01':'GM','MAN02':lin.get({'BOTSID':'HLL','MAN02E':None})})
if lin.get({'BOTSID':'HLL','MAN01F':None}):
lou.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN01':'GM','MAN02':lin.get({'BOTSID':'HLL','MAN02F':None})})
if lin.get({'BOTSID':'HLL','MAN01GB':None}):
lou.put({'BOTSID':'HL'},{'BOTSID':'MAN','MAN01':'GM','MAN02':lin.get({'BOTSID':'HLL','MAN02G':None})})
# New HLL line starts here
lou.put({'BOTSID':'HL'},{'BOTSID':'LIN','LIN02':lin.get({'BOTSID':'HLL','LIN02':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'LIN','LIN03':lin.get({'BOTSID':'HLL','LIN03':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'SN1','SN102':lin.get({'BOTSID':'HLL','SN102':None})})
lou.put({'BOTSID':'HL'},{'BOTSID':'SN1','SN103':lin.get({'BOTSID':'HLL','SN103':None})})
out.put({'BOTSID':'ST'},{'BOTSID':'CTT','CTT01':inn.get({'BOTSID':'HEA','CTT01':None})})
out.put({'BOTSID':'ST'},{'BOTSID':'SE','SE01':out.getcount()+1,'SE02':out.ta_info['reference']}) #last line (counts the segments produced in out-message
[\Mapping]
Thanks again,
David