Hi All,
I hope you all have a good day! I'm a total newbie to BOTS and PYTHON and to my current company. My assignment is to find a way to make BOTS translate x12 to idoc. Currently I'm translating x12 to x12 just to know how it works. I tried the 837 example and it's working fine. But when I start from scratch on an 850 PO I get an error. I've followed the instructions on creating the grammars, routes, and translations but I hit a big wall.
This is what I have
Error Message:MessageError: [F17] line 1 pos 106: Record "ISA" expect field but "" is a subfield.
[S50]: Line:1 pos:171 record:"BEG": message has an error in its structure; this record is not allowed here. Scanned in message definition until mandatory record: "ISA-GS-GE".
Channel -> test_inIdchannel: test_in
In/out: in
Type: file
Path: botssys/infile/test
Filename: *.in
Channel -> test_outIdchannel: test_out
In/out: out
Type: file
Path: botssys/outfile/test
Filename: {infile:name}.idoc
Route -> testActive: checked
Idroute:test
Sequence: 1
Incoming channel: test_in (file)
Fromedittype: x12
Frommessagetype: x12
Translate: Translate
Outgoing channel: test_out (file)
Translation : x12Fromeditype: x12
Frommessagetype: testx12
Mapping Script: test_x12_to_x12
Toeditype: x12
Tomessagetype: testx12
Grammar -> x12.pyfrom bots.botsconfig import *
syntax = {
'version' : '00401',
}
nextmessage = ({'BOTSID':'ISA'},{'BOTSID':'GS'},{'BOTSID':'ST'})
structure = [
{ID:'ISA',MIN:0,MAX:99999,
LEVEL:[
{ID:'GS',MIN:0,MAX:99999,
LEVEL:[
{ID:'ST',MIN:0,MAX:99999},
{ID:'GE',MIN:1,MAX:1},
]
},
{ID:'IEA',MIN:1,MAX:1}
]
}
]
recorddefs = {
'ISA':[
['BOTSID','M',3,'AN'],
['ISA01','M',2,'ID'],
['ISA02','M',10,'AN'],
['ISA03','M',2,'ID'],
['ISA04','M',10,'AN'],
['ISA05','M',2,'ID'],
['ISA06','M',15,'AN'],
['ISA07','M',2,'ID'],
['ISA08','M',15,'AN'],
['ISA09','M',6,'DT'],
['ISA10','M',4,'TM'],
['ISA11','C',1,'AN'],
['ISA12','M',5,'ID'],
['ISA13','M',9,'N0'],
['ISA14','M',1,'ID'],
['ISA15','M',1,'ID'],
['ISA16','M',1,'AN'],
],
'GS':[
['BOTSID','M',3,'AN'],
['GS01','M',2,'ID'],
['GS02','M',(2,15),'AN'],
['GS03','M',(2,15),'AN'],
['GS04','M',8,'DT'],
['GS05','M',(4,8),'TM'],
['GS06','M',(1,9),'N0'],
['GS07','M',(1,2),'ID'],
['GS08','M',(1,12),'AN'],
],
'ST':[
['BOTSID','M',3,'AN'],
['ST01','M',3,'ID'],
['ST02','M',(4,9),'AN'],
],
'SE':[
['BOTSID','M',3,'AN'],
['SE01', 'M', (1,10), 'N0'],
['SE02', 'M', (4,9), 'AN'],
],
'GE':[
['BOTSID','M',3,'AN'],
['GE01', 'M', (1,6), 'N0'],
['GE02', 'M', (1,9), 'N0'],
],
'IEA':[
['BOTSID','M',3,'AN'],
['IEA01', 'M', (1,5), 'N0'],
['IEA02', 'M', 9, 'N0'],
],
}
Grammar testx12.pyfrom bots.botsconfig import *
syntax = {
'version' : '00403', #version of ISA to send
'functionalgroup' : 'PO',
}
structure = [{ID: 'ST', MIN: 1, MAX: 1, LEVEL:[
{ID: 'SE', MIN:1, MAX: 1}
]}]
recorddefs = {
'BEG': [
['BOTSID', 'M', 3,'AN'],
['BEG01', 'M', 2,'ID'],
['BEG02', 'M', 2,'ID'],
['BEG03', 'M', (1,22),'AN'],
['BEG04', 'C', (1,30),'AN'],
['BEG05', 'M', 8,'DT'],
],
'CSH': [
['BOTSID', 'M', 3,'AN'],
['CSH01', 'M', (1,2),'ID'],
],
'CTT': [
['BOTSID', 'M', 3,'AN'],
['CTT01', 'M', (1,6),'N0'],
['CTT02', 'M', (1,10),'R'],
],
'CUR': [
['BOTSID', 'M', 3,'AN'],
['CUR01', 'M', (2,3),'AN'],
['CUR02', 'M', 3,'AN'],
['CUR03', 'C', (4,10),'R'],
['CUR04', 'C', (2,3),'AN'],
['CUR05', 'C', 3,'AN'],
['CUR06', 'C', 3,'AN'],
['CUR07', 'C', 3,'AN'],
['CUR08', 'C', 8,'DT'],
['CUR09', 'C', (4,8),'TM'],
['CUR10', 'C', 3,'AN'],
['CUR11', 'C', 8,'DT'],
['CUR12', 'C', (4,8),'TM'],
['CUR13', 'C', 3,'AN'],
['CUR14', 'C', 8,'DT'],
['CUR15', 'C', (4,8),'TM'],
['CUR16', 'C', 3,'AN'],
['CUR17', 'C', 8,'DT'],
['CUR18', 'C', (4,8),'TM'],
['CUR19', 'C', 3,'AN'],
['CUR20', 'C', 8,'DT'],
['CUR21', 'C', (4,8),'TM'],
],
'DTM': [
['BOTSID', 'M', 3,'AN'],
['DTM01', 'M', 3,'ID'],
['DTM02', 'C', 8,'DT'],
],
'FOB': [
['BOTSID', 'M', 3,'AN'],
['FOB01', 'M', 2,'ID'],
['FOB02', 'C', (1,2),'AN'],
['FOB03', 'C', (1,80),'AN'],
['FOB04', 'M', 2,'ID'],
['FOB05', 'C', 3,'ID'],
['FOB06', 'C', (1,2),'ID'],
['FOB07', 'C', (1,80),'AN'],
],
'MSG': [
['BOTSID','M',3,'AN'],
['MSG01','M',(1,264),'AN'],
],
'N1': [
['BOTSID', 'M', 3,'AN'],
['N101', 'M', (2,3),'ID'],
['N102', 'C', (1,60),'AN'],
['N103', 'M', (1,2),'ID'],
['N104', 'C', (2,80),'AN'],
],
'N9': [
['BOTSID', 'M', 3,'AN'],
['N901', 'M', (2,3),'ID'],
['N902', 'C', (1,30),'AN'],
],
'PKG': [
['BOTSID', 'M', 3,'AN'],
['PKG01', 'M', 1,'ID'],
['PKG02', 'M', (1,5),'ID'],
['PKG03', 'C', 2,'AN'],
['PKG04', 'C', 7,'AN'],
['PKG05', 'M', (1,80),'AN'],
],
'PO1': [
['BOTSID', 'M', 3,'AN'],
['PO101', 'M', (1,20),'AN'],
['PO102', 'M', (1,15),'R'],
['PO103', 'M', 2,'ID'],
['PO104', 'M', (1,17),'R'],
['PO105', 'M', 2,'ID'],
['PO106', 'C', 2,'ID'],
['PO107', 'C', (1,48),'AN'],
],
'REF': [
['BOTSID', 'M', 3,'AN'],
['REF01', 'M', (2,3),'ID'],
['REF02', 'C', (1,30),'AN'],
],
'SE': [
['BOTSID', 'M', 3,'AN'],
['SE01', 'M', (1,10),'N0'],
['SE02', 'M', (4,9),'AN'],
],
'ST': [
['BOTSID', 'M', 3,'AN'],
['ST01', 'M', 3,'AN'],
['ST02', 'M', (4,9),'AN'],
],
}
Mapping -> test_x12_to_x12.pyimport bots.transform as transform
def main(inn,out):
transform.inn2out(inn,out)
Sample FileISA*00* *00* *ZZ*ABCDEF *12*1234567890 *140106*0331*U*00400*000001886*0*P*>~
GS*PO*ABCDEF*1234567890*20140106*0331*1886*X*004010~
ST*850*0001~
BEG*00*NE*V8649492**20140106~
REF*CR*MRIAQ~
CSH*Y~
DTM*064*20140106~
DTM*063*20140113~
N1*ST**15*1566008~
PO1*1*1*EA*431.88*PE*UP*633012065813~
CTT*1*1~
SE*10*0001~
GE*1*1886~
IEA*1*000001886~
Thanks in advance.
Naye