advise on hard coding fromPartner

323 views
Skip to first unread message

Ken

unread,
Jun 1, 2012, 1:55:50 PM6/1/12
to Bots Open Source EDI Translator
I have no control over the format of the fixed file output by my ERP
system.
It does not include my EDI identifier in the file. So, I need to
force bots to insert my ID as fromPartner in the envelope when
translating 810s.

Any suggestions for the best practice?


can I do it here in the grammar?

structure= [
{ID:'SOHEAD',MIN:1,MAX:10000,
QUERIES:{
'frompartner': {'BOTSID':'SOHEAD','SenderID':None},
<----------------------
'topartner': {'BOTSID':'SOHEAD','SenderID':None},
'reference': {'BOTSID':'SOHEAD','POnumber':None},
'testindicator':{'BOTSID':'SOHEAD','Test':None}},

BikeMike

unread,
Jun 1, 2012, 7:51:33 PM6/1/12
to Bots Open Source EDI Translator
Hi Ken,
You would do this in the mapping, not the grammar.

eg. out.ta_info['frompartner'] = 'MY_EDI_ID']

If you want it more configurable rather than hard-coded, you can add a
section in bots.ini, or use a user code table (I think a table is
better, leave bots.ini for bots configuration).

eg, create a table called "paramaters'
Add an entry with leftcode '810_frompartner' and rightcode is your
sending ID
In the mapping, add it like this.

out.ta_info['frompartner'] =
transform.ccode('parameters','810_frompartner')

Kind Regards,
Mike

BikeMike

unread,
Jun 1, 2012, 10:16:56 PM6/1/12
to Bots Open Source EDI Translator
You can also configure a frompartner in the route (advanced
parameters). I'm not sure if you'd need to remove the frompartner
query from the grammar in this case, it might over-ride it to one.

Ken

unread,
Jun 1, 2012, 10:58:03 PM6/1/12
to Bots Open Source EDI Translator
thanks. I've been looking at this for the last few minutes. this is a
x12 mapping. I didn't think I could effect the ISA from the mapping.
But I'm still looking.

Ken

unread,
Jun 1, 2012, 11:07:30 PM6/1/12
to Bots Open Source EDI Translator
I just re-read my op and realize I didn't make it clear that I am
creating the 810 from my flat file.

Ken

unread,
Jun 2, 2012, 7:46:10 AM6/2/12
to Bots Open Source EDI Translator
A little sleeps work wonders. I need a partner file in usersys\partners
\x12 for every partner to handle qualifiers anyway. I just added the
frompartner ID to ISA06.

clemper

unread,
Jun 4, 2012, 5:46:32 PM6/4/12
to bots...@googlegroups.com
Hi,

I am successfully using this method to hardcode the frompartner and topartner in the route.  However, my trading partner using Edifact wants also UNB.S002.0008 and UNB.S003.0014 to also be set to the frompartner and topartner ids, respectively.  

I tried adding the following to the mapping but it does not seem to have any affect:

    out.ta_info['UNB.S002.0008'] = inn.ta_info['frompartner'] # reverse sender
    out.ta_info['UNB.S003.0014'] = inn.ta_info['topartner']    # reverse receiver

How does one set fields in the envelope that do not have named entries in the out.ta_info dict?

Thanks,
Chris

clemper

unread,
Jun 4, 2012, 6:08:26 PM6/4/12
to bots...@googlegroups.com
I was able to get this to work using the envelope scripting.   I am not sure if this is the most straight forward way. 

I created a Python module name "edifact.py" under at usersys/envelopescripts/edifact containing the following:

def ta_infocontent(ta_info):
    ta_info['UNB.S002.0008'] = ta_info['frompartner'] # reverse sender
    ta_info['UNB.S003.0014'] = ta_info['topartner']   # reverse receiver

def envelopecontent(ta_info,out):
    if ta_info['UNB.S002.0008']:
        out.put({'BOTSID':'UNB','S002.0008': ta_info['UNB.S002.0008']})
    if ta_info['UNB.S003.0014']:
        out.put({'BOTSID':'UNB','S003.0014': ta_info['UNB.S003.0014']})


Thanks,
Chris

henk-jan ebbers

unread,
Jun 4, 2012, 6:12:13 PM6/4/12
to bots...@googlegroups.com
easiest is to use partner dependent syntax: there you can set the envelope variables, incl the ones you mention.
google on the mailing list for that.

kind regards,
henk-jan

Ken

unread,
Jun 6, 2012, 12:05:11 PM6/6/12
to bots...@googlegroups.com
henk-jan,

I solved my original problem by using the partner dependent syntax.  That fixed the ISA.  The GS still seems to be a problem. The GS is not getting the frompartner from the partner file. It is using the query from the gammar file. If I comment out the query line to try to force it,  I get OutMessageError: In enveloping "frompartner" or "topartner" unknown.  Because my ERP export does not contain my 'from' identifier I have my query defined as

            'frompartner':  {'BOTSID':'SOHEAD','CustomerID':None},
            'topartner':    {'BOTSID':'SOHEAD','CustomerID':None},

just so that the frompartner query will work. granted it returns the wrong data.

For the ISA, that wrong data is over written by the partner dependent syntax and I get a correctly formatted ISA record.  But the GS ends up with

GS*IN*CustomerID*CustomerID*20120606*1044*5*X*004010~

should the partner file content have overridden this?

ken

henk-jan ebbers

unread,
Jun 6, 2012, 12:13:23 PM6/6/12
to bots...@googlegroups.com
I guess it should.
will check this later.


henk-jan

henk-jan ebbers

unread,
Jun 6, 2012, 6:08:38 PM6/6/12
to bots...@googlegroups.com
you are right, GS field have separate values:
'GS02' = frompartner
'GS03' = topartner

but if you want my advice:
set the values for the partners as early as you can - in the route.
you now set them as late as possible (partner specific parameters).

reason is that a lot of features in bots are triggered by the partner-ID.

kind regards,
henk-jan


On 06/06/2012 06:05 PM, Ken wrote:

Ken

unread,
Jun 7, 2012, 10:34:17 AM6/7/12
to Bots Open Source EDI Translator
thanks henk-jan

I just realized that I had an error in the partner file that prevented
the GS from working correctly.

I had tried Mike's suggestion of using
eg. out.ta_info['frompartner'] = 'MY_EDI_ID'
in the mapping but must not understand the python syntax or its
placement in the mapping.
I just put it at the top of the mapping like this:

def main(inn,out):
#~ print 'translation script invoice810.py'

out.ta_info['frompartner'] = 'MY_ID'

out.put({'BOTSID':'ST','ST02':out.ta_info['reference'],'ST01':'810'})

and get
IndentationError: expected an indented block

I think it is just a syntax error - I guess I'll be studying python
abit.

thanks for all your help

ken

Ken

unread,
Jun 7, 2012, 10:50:37 AM6/7/12
to Bots Open Source EDI Translator
thanks henk-jan

I just realized that I had an error in the partner file that prevented
the GS from working correctly.

I had tried Mike's suggestion of using
eg. out.ta_info['frompartner'] = 'MY_EDI_ID'
in the mapping but must not understand the python syntax or its
placement in the mapping.
I just put it at the top of the mapping like this:

def main(inn,out):
#~ print 'translation script invoice810.py'

out.ta_info['frompartner'] = 'MY_ID'

out.put({'BOTSID':'ST','ST02':out.ta_info['reference'],'ST01':'810'})

and get
IndentationError: expected an indented block

I think it is just a syntax error - I guess I'll be studying python
abit.

thanks for all your help

ken

On Jun 6, 5:08 pm, henk-jan ebbers <eppye.b...@gmail.com> wrote:

Ken

unread,
Jun 7, 2012, 11:06:45 AM6/7/12
to Bots Open Source EDI Translator
thanks henk-jan

I just realized that I had an error in the partner file that prevented
the GS from working correctly.

I had tried Mike's suggestion of using
eg. out.ta_info['frompartner'] = 'MY_EDI_ID'
in the mapping but must not understand the python syntax or its
placement in the mapping.
I just put it at the top of the mapping like this:

def main(inn,out):
#~ print 'translation script invoice810.py'

out.ta_info['frompartner'] = 'MY_ID'

out.put({'BOTSID':'ST','ST02':out.ta_info['reference'],'ST01':'810'})

and get
IndentationError: expected an indented block

I think it is just a syntax error - I guess I'll be studying python
abit.

thanks for all your help

ken

On Jun 6, 5:08 pm, henk-jan ebbers <eppye.b...@gmail.com> wrote:

Ken

unread,
Jun 7, 2012, 12:38:44 PM6/7/12
to Bots Open Source EDI Translator
got it - lost the indent while editing

henk-jan ebbers

unread,
Jun 7, 2012, 5:22:46 PM6/7/12
to bots...@googlegroups.com
yes - python and indenting.
actually I like this very much in python.

it is wise not to use tabs.
I use an editor that inserts spaces when I use the TAB key.

kind regards,
henk-jan
Reply all
Reply to author
Forward
0 new messages