x12 940 to xml

450 views
Skip to first unread message

Ros Bay

unread,
May 20, 2013, 11:52:36 AM5/20/13
to bots...@googlegroups.com
Hello

I am new to EDI and my boss wants me to explore Bots Open Source EDI Translator. I haven't used python before so I'm still reading tutorials. Anyways after reading tutorials from the  Bots site, I tried translating a 940 sample file to xml he sent me by downloading and  using the plugin x12toxml_supplier_version850-856-810-997_20130124. I also downloaded the X12_004010_all_transactions_and_segments.zip file and used the 940004010.py. I have edited the 940004010.py to try and solve errors and the latest error is this: 

InMessageError: Message nr 1, type 940004010, [S50]: Line:8 pos:1 record:"N1": message has an error in its structure; this record is not allowed here. Scanned in message definition until mandatory record: "[['ST'], ['W66']]".


I have attached the grammar and the sample x12 940 file.

Thanks,
Ros Bay

940004010.py
940.txt

BikeMike

unread,
May 21, 2013, 12:49:40 AM5/21/13
to bots...@googlegroups.com
Hi Ros,
Welcome to the Bots mailing list (and to the world of EDI!).

I'm not an expert in X12 but I see in the grammar that N1 mandatory but not allowed to repeat. It has MIN: 1, MAX: 1.
So either the grammar or the the EDI file does not conform to the X12 standards.

I know in EDIFACT the equivalent is NAD segments, and they are allowed to repeat up to 5 times. So this seems a strange limitation to me. The file has different qualifiers for the different N1 Blocks (ST and SD).
You could try changing the grammar to accept the repeated N1 block, eg. set MAX: 5.
But if the X12 standards say no repeats allowed (ie. the grammar is correct) then you should contact your trading partner about this and tell them the document is wrong. Unfortunately in the real world sometimes you just have to accept them and deal with it!

Kind Regards,
Mike

BikeMike

unread,
May 21, 2013, 1:03:43 AM5/21/13
to bots...@googlegroups.com
According to this online reference the grammar is incorrect, N1 should be MIN: 0, MAX: 10.

http://websupport.misg.com/x12/index.php?show=document&document=940&version=4010

henk-jan ebbers

unread,
May 21, 2013, 5:14:03 AM5/21/13
to bots...@googlegroups.com
hi Ros,

in general, the x12 grammars that are on the web-site are according to x12 standard.
do not edit these.
I never edit these grammars (except for syntax part).
It is not useful - why would you edit a standard ;-))

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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

BikeMike

unread,
May 21, 2013, 5:54:13 AM5/21/13
to bots...@googlegroups.com
Hi henk-jan,
In this case it looks like the grammar is incorrect (unless I am mis-reading the standards, I'm not an expert in X12).
N1 loop can repeat 10x but the 940 grammar has MAX: 1

Kind Regards,
Mike

henk-jan ebbers

unread,
May 21, 2013, 6:05:29 AM5/21/13
to bots...@googlegroups.com
yes, but Ros changed the grammar first.
I checked the downloads to be sure, but the provided one is correct ;-))

I saw more changes in the grammar.
He might want to bring the grammar in line with the MIG.
it is better to use the grammar that is inline with the standard, and use the structure of the inhouse file and/or check in mapping to deal with the limitations he might want to achieve.

I see this more often with x12. The x12 standard is not free, and hard to find (with your experience, you know that you have to go to the standard 'intuitively' ;-)
He probably is looking at a MIG, and is wondering why the grammar is different for the MIG.

kind regards,
henk-jan
Message has been deleted

Ros Bay

unread,
May 21, 2013, 10:01:36 AM5/21/13
to bots...@googlegroups.com
Thanks for all your replies. So I tried it again without editing the grammar for the 940 and the error is like this:

MessageError: At least 10 errors: 
Message nr 1, type 940004010, [F05]: Record "[['ST'], ['N1'], ['N4']]" field "N404" too big (max 3): "_unitedStates". 
Message nr 1, type 940004010, [F05]: Record "[['ST'], ['W66']]" field "W6610" too big (max 4): "UPSGND". 
Message nr 1, type 940004010, [F02]: Record "[['ST'], ['LX'], ['W01']]" field "W0102" is mandatory. 
Message nr 1, type 940004010, [F05]: Record "[['ST'], ['LX'], ['W01'], ['G69']]" field "G6901" too big (max 45): "8' Harvest Bamboo Tree in Planter (Box 1 of 2)". 
Message nr 1, type 940004010, [F02]: Record "[['ST'], ['LX'], ['W01']]" field "W0102" is mandatory. 
Message nr 1, type 940004010, [F05]: Record "[['ST'], ['LX'], ['W01'], ['G69']]" field "G6901" too big (max 45): "8' Harvest Bamboo Tree in Planter (Box 2 of 2) Pot". Message nr 2, type 940004010, [F05]: Record "[['ST'], ['W66']]" field "W6610" too big (max 4): "UPSGND". 
Message nr 2, type 940004010, [F02]: Record "[['ST'], ['LX'], ['W01']]" field "W0102" is mandatory. 
Message nr 2, type 940004010, [F05]: Record "[['ST'], ['LX'], ['W01'], ['G69']]" field "G6901" too big (max 45): "Grass in brown and gold mosaic container (11x11x11.75") - 2 pack". 
Message nr 3, type 940004010, [F02]: Record "[['ST'], ['LX'], ['W01']]" field "W0102" is mandatory.

Can anyone please explain what the error message says. Do you think the 940 document is wrong? What will I edit so that it follows the 940 document. Forgive me with this kind of questions since I'm a beginner to this kind of things.


Sincerely,
Ros

henk-jan ebbers

unread,
May 21, 2013, 10:11:58 AM5/21/13
to bots...@googlegroups.com
The errors seems to be quite clear.
eg field N404 is max three positions, the content is larger than 3 positions, etc etc.

check this with your partner.
if they insist on 'improving' the standard you will need to change the grammar.

kind regards,
henk-jan

Ros Bay

unread,
May 21, 2013, 10:32:37 AM5/21/13
to bots...@googlegroups.com
Thank you very much. I already said it to my boss and it seemed that their partner veered from the standard. I will wait for further actions on what to do next. Thank you henk-jan.
Reply all
Reply to author
Forward
0 new messages