BOTS newbie

909 views
Skip to first unread message

rve...@natrol.com

unread,
Dec 23, 2014, 3:43:48 PM12/23/14
to bots...@googlegroups.com
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_in

Idchannel: test_in
In/out: in
Type: file
Path: botssys/infile/test
Filename: *.in

Channel -> test_out

Idchannel: test_out
In/out: out
Type: file
Path: botssys/outfile/test
Filename: {infile:name}.idoc

Route -> test

Active: checked
Idroute:test
Sequence: 1
Incoming channel: test_in (file)
Fromedittype: x12
Frommessagetype: x12
Translate: Translate
Outgoing channel: test_out (file)

Translation : x12

Fromeditype: x12
Frommessagetype: testx12
Mapping Script: test_x12_to_x12
Toeditype: x12
Tomessagetype: testx12

Grammar -> x12.py

from 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.py

from 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.py

import bots.transform as transform
def main(inn,out):
    transform.inn2out(inn,out)

Sample File

ISA*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


 We are under new ownership and our company, Natrol, Inc., has now become Natrol LLC,  - a subsidiary of Aurobindo Pharma USA Inc.

henk-jan ebbers

unread,
Dec 23, 2014, 4:03:43 PM12/23/14
to bots...@googlegroups.com
if you receive 850, use plugin x12toxml_supplier_version850-856-810-997
it does more what you want.
it maps to xml, but handling is the same in mapping.
take a look at that setup (route-script, mappings).
Than there is another plugin that might be interesting:
demo_sap_idoc_orders_WPPLU

Think it maps incoming orders (edifact) to idoc.
(handling of edifact or x12 is quite similar - but they do use different segmenttags, data-elements names)

kind regards,
henk-jan

rve...@natrol.com

unread,
Dec 23, 2014, 4:30:39 PM12/23/14
to bots...@googlegroups.com
To what I know, SAP expects only idoc files. Or at least it was what I've learned so far.

I'm not sure if what I'm thinking is right, but are you saying BOTS is not capable of translating x12 to idoc directly?

BTW, thanks for the quick reply.

Naye :)

henk-jan ebbers

unread,
Dec 23, 2014, 4:35:30 PM12/23/14
to bots...@googlegroups.com
no, that is not what I am saying.

there is a whole bunch of plugins; these are example and training material.
there is no x12 <-> idoc plugin because nobody made a plugin for that.
but configuration is not different from other plugins.
so I was pointing you out the IMHO best 2 plugins to start from.

Or: sure bots can translate directy from x12 to idoc or vice versa.


kind regards,
henk-jan

On 12/23/2014 10:30 PM, rve...@natrol.com wrote:
> To what I know, SAP expects only idoc files. Or at least it was what I've learned so far.
>
> I'm not sure if what I'm thinking is right, but are you saying BOTS is not capable of translating x12 to idoc directly?
>
> BTW, thanks for the quick reply.
>
> Naye :)
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> /*We are under new ownership and our company, Natrol, Inc., has now become Natrol LLC, - a subsidiary of Aurobindo Pharma USA Inc.*/ --
> 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.

rve...@natrol.com

unread,
Dec 23, 2014, 4:42:08 PM12/23/14
to bots...@googlegroups.com
Oh, that's good to know! Now I feel I have a chance to make this work. I'll try it now. Wish me luck. Thanks!!!


rve...@natrol.com

unread,
Jan 2, 2015, 3:22:57 PM1/2/15
to bots...@googlegroups.com
The transfer of data from x12 to idoc was a success. Unfortunately, I couldn't figure how to manipulate the envelop information. I noticed that processing the envelop is separate from processing of the content. Is it possible to join them or is it compulsory to split them. Please point me to the right direction.

Thanks and Belated Happy New Year!!!

BikeMike

unread,
Jan 4, 2015, 1:50:05 AM1/4/15
to bots...@googlegroups.com
Hi Naye,
This would depend on how you structured your IDoc grammars. I created mine using a script from WE63 output files. I made the EDI_DC40 record the "root" record in the grammar but have not configured an "envelope" (in hindsight maybe could do this differently but it has been working well for 5 years!). Then I just write the EDI_DC40 like any other record, in the mapping. My IDoc ORDERS05 grammar is attached.

Kind Regards,
Mike


_IDOC.py
ORDERS05.py
Message has been deleted

rve...@natrol.com

unread,
Jan 5, 2015, 7:54:01 PM1/5/15
to bots...@googlegroups.com
Hi BikeMike,

Just curious, did you learn BOTS by yourself or did you undergo a training? The reason is, although I'm moving little by little, I don't know if having a training on BOTS is a must. Or should I ask "Is there an available training for BOTS out there"? If so, do you know how much does it cost?

Thanks,
Naye

BikeMike

unread,
Jan 6, 2015, 2:45:10 AM1/6/15
to bots...@googlegroups.com
Hi Naye,
To begin with I was already a programmer, although I had never seen python! I have found it a great language and easy to pick up. Also I had previously quite a bit of EDI experience with TrustedLink and custom written RPG programs on iSeries hardware. Bots replaced all that!

I learned Bots by myself through:
  • Loading some of the plugins, test and experiment with their configuration
  • Looking at Bots source code, trying to understand it
  • Asking questions on this mailing list :-)
  • Trying to do "unusual" things that I needed for my work 
  • Making improvements to Bots code and submitting for the new versions
At the time there was no wiki, but there was some documentation on the website. Now we have the wiki IMO it is much better and improving all the time. I try to add stuff to it in response to questions on the mailing list too.

I have done a few training sessions for my users, but there is no official training course that I know of. Perhaps Henk-jan can offer some training?

Kind Regards,
Mike

rve...@natrol.com

unread,
Jan 6, 2015, 11:29:10 AM1/6/15
to bots...@googlegroups.com
Hi BikeMike,

Good morning! I'm in almost the same path as you did except that I am totally new to EDI and that I haven't looked at the BOTS code because I don't know which code file to call first. And, I also found python very easy to learn. With regards to the training, as of now, all I can do is propose to my boss regarding the training package. Although it is not guaranteed, it's better than not trying.

Thanks,
Naye

rve...@natrol.com

unread,
Jan 6, 2015, 7:37:31 PM1/6/15
to bots...@googlegroups.com
Hi BikeMike,

The sample on your previous reply, is that X12 to iDoc? If so, I would really appreciate if you can share the mapping, only if it's ok. That would be a very good reference and would make my struggles easier.

Thanks,
Naye

BikeMike

unread,
Jan 7, 2015, 2:40:00 AM1/7/15
to bots...@googlegroups.com
I don't have any X12 to IDoc mappings, but I do have csv, xml, edifact, fixed... All of them are quite complex and use a library of functions with a lot of business specific logic.

I will try to find the simplest one (probably a csv) to post here.

henk-jan ebbers

unread,
Jan 7, 2015, 8:49:18 AM1/7/15
to bots...@googlegroups.com
hi Naye,

I do quite a lot of x12, I sometimes do idocs, but never did X12 <-> idoc
but I do not think it matters much.
handling of x12 and edifact is very similar.

what exactly is the problem you are running into?

kind regards,
henk-jan

On 01/07/2015 01:37 AM, rve...@natrol.com wrote:
> Hi BikeMike,
>
> The sample on your previous reply, is that X12 to iDoc? If so, I would really appreciate if you can share the mapping, only if it's ok. That would be a very good reference and would make my
> struggles easier.
>
> Thanks,
> Naye
>

rve...@natrol.com

unread,
Jan 7, 2015, 11:42:55 AM1/7/15
to bots...@googlegroups.com
Hi BikeMike and Eppye,


Thanks for the consistent reply. I hope you are both having a perfect day!

In view of reducing the monthly company bills, we are planning to replace an application with BOTS. But I simply don't have the knowledge and I only rely on the WIKI documentation and the x12 provided by the customer. Frankly, I don't also have experience with SAP. So, I'm currently trying my best to put things together.

With the information both of you provided, I was able to learn how to transfer data from X12 to iDoc. BUT, it's according to the looping on X12, meaning i didn't follow any iDoc rules since i don't have documentation. My current problems are

Spacing
Actual             : EDI_DC40                      300
Suppose to be : EDI_DC40  300

Unprovided data -> Where does BOTS get this information?
EDI_DC40  300                      2   ORDERS05                      ZORDERSEX2                    ORDERS

Structure of iDoc -> On X12 it says when a portion is a loop. On iDoc, I have no idea.


Thanks,
Naye


henk-jan ebbers

unread,
Jan 7, 2015, 11:53:02 AM1/7/15
to bots...@googlegroups.com

On 01/07/2015 05:42 PM, rve...@natrol.com wrote:
> Hi BikeMike and Eppye,
>
>
> Thanks for the consistent reply. I hope you are both having a perfect day!
>
> In view of reducing the monthly company bills, we are planning to replace an application with BOTS. But I simply don't have the knowledge and I only rely on the WIKI documentation and the x12
> provided by the customer. Frankly, I don't also have experience with SAP. So, I'm currently trying my best to put things together.
>
> With the information both of you provided, I was able to learn how to transfer data from X12 to iDoc. BUT, it's according to the looping on X12, meaning i didn't follow any iDoc rules since i don't
> have documentation. My current problems are
>
> _*Spacing*_
> Actual : EDI_DC40300
> Suppose to be : EDI_DC40300
for Bots idocs are a kind of fixed records files.

in the grammar is defined which fields there in each idoc record, and the the length of the field.
so the spacing is done by bots (using the gramar)
>
> _*Unprovided data*_ -> Where does BOTS get this information?
> EDI_DC40 300 2 ORDERS05 ZORDERSEX2 ORDERS
to me, these are constants. Look like idoc type/version numbers...do not know the details; I just know this has to be there.
These are just constants in the mapping.
>
> _*Structure of iDoc*_ -> On X12 it says when a portion is a loop. On iDoc, I have no idea.
Look in SAP itself. There is na transacdtion (I think it is called in SAP) that generates idoc documentation. Even with different layouts.
Using an editor and advanced search/replace this can be reworked to use in grammar.

kind regards,
henk-jan

rve...@natrol.com

unread,
Jan 7, 2015, 12:07:49 PM1/7/15
to bots...@googlegroups.com
Now that's what I call INSTANT reply...THANKS!!! :)


BikeMike

unread,
Jan 7, 2015, 6:02:21 PM1/7/15
to bots...@googlegroups.com

Hi Naye,
Attached is a slightly simplified mapping from csv to IDoc ORDERS05. I have removed most of our company-specific logic and copied the remaining maplib functions into this mapping.

The "constant" EDI_DC40 values in my case are configured in a ccode table. This allows easy changes between SAP environments for pre-production etc.


#example csv to idoc order.py

rve...@natrol.com

unread,
Jan 9, 2015, 3:59:17 PM1/9/15
to bots...@googlegroups.com
Hi BikeMike,

Good day! I don't know if what I found is correct but it seems the envelope data are contained in the EDIDC table of SAP.

BTW, thanks for the Sample file.

Naye
Reply all
Reply to author
Forward
0 new messages