xenpu / bots

Automatically exported from code.google.com/p/bots
0 stars 0 forks source link

fixed: bug in fixed length fields for x12 ,edifact #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
normal field is defined like eg:
  ['fieldname', 'C', 8, 'AN'],
it is now also possible to define this as:
  ['fieldname', 'C', (8,8), 'AN'],
this field has a min length of 8, max 8
or
  ['fieldname', 'C', (6,8), 'AN'],
this field has a min length of 6, max 8

Original issue reported on code.google.com by hjebb...@gmail.com on 1 Nov 2011 at 12:43

GoogleCodeExporter commented 9 years ago
Hi Henk-jan,
I think this has introduced a new bug. For idoc grammars (fixed column 
positions), if a field is not mandatory and has no value, it's space is omitted 
from the output and all remaining fields are then shifted left out of their 
correct position. Have not fully analysed this, but seems to be in 
_canonicalfields (message.py). There are no minimum lengths in any of my 
grammars.
Kind Regards,
Mike

Original comment by mjg1964 on 3 Nov 2011 at 6:45

GoogleCodeExporter commented 9 years ago
Well, maybe not quite a bug!
It was specifically related to the DOCNUM field in idocs. The default syntax 
initializes it to '0'. 

In my mapping I had out.ta_info['DOCNUM'] = '' # empty string
This caused it to be completely omitted from the output with new message.py 
installed.

I changed my mapping to to out.ta_info['DOCNUM'] = ' ' # one space
and now it works ok.

Kind Regards,
Mike

Original comment by mjg1964 on 3 Nov 2011 at 7:42

GoogleCodeExporter commented 9 years ago
hi Mike,

how is the DOCNUM defintion? numeric?
I will test this.

Original comment by hjebb...@gmail.com on 3 Nov 2011 at 10:36

GoogleCodeExporter commented 9 years ago
['DOCNUM','C',16,'AN']
grammar is attached

Original comment by mjg1964 on 3 Nov 2011 at 10:50

Attachments:

GoogleCodeExporter commented 9 years ago
yes, I see the problem.
thanks!

Original comment by hjebb...@gmail.com on 3 Nov 2011 at 11:08

GoogleCodeExporter commented 9 years ago
hi Mike,

reading this again I am not sure I understand.

in your mapping:
     out.ta_info['DOCNUM'] = ''
but the changes I made are in message/outmessage, about how a message gets 
written.

is there something else you do with out.ta_info['DOCNUM']   ??

Original comment by hjebb...@gmail.com on 3 Nov 2011 at 1:07

GoogleCodeExporter commented 9 years ago
Hi henk-jan,
In my output I want DOCNUM to be blank (16 spaces). IDoc is a fixed 
positional format. In the mapping, if I make DOCNUM='' then each record 
in the written IDoc is 16 characters shorter and all following fields 
are in the wrong positions, I assume because DOCNUM is not written at 
all. If I make DOCNUM=' ' it works ok.

Original comment by mjg1964 on 3 Nov 2011 at 9:08

GoogleCodeExporter commented 9 years ago
hi Mike,

I think I solved this issue; DOCNUM='' should work also.

Original comment by hjebb...@gmail.com on 4 Nov 2011 at 11:45

GoogleCodeExporter commented 9 years ago
Yes that has fixed it.

Original comment by mjg1964 on 4 Nov 2011 at 12:22

GoogleCodeExporter commented 9 years ago
File "D:\python27\lib\site-packages\bots\outmessage.py", line 176, in 
_tree2recordfields if grammarsubfield[ID] in noderecord and 
noderecord[grammarfield[ID]]: #field exists in outgoing message and has data 
KeyError: 'S009'

I think line 176 should be
if grammarsubfield[ID] in noderecord and noderecord[grammarsubfield[ID]]:

Original comment by mjg1964 on 4 Nov 2011 at 11:47

GoogleCodeExporter commented 9 years ago
yes, you are right!

thanks, henk-jan

Original comment by hjebb...@gmail.com on 5 Nov 2011 at 1:25

GoogleCodeExporter commented 9 years ago

Original comment by hjebb...@gmail.com on 10 Sep 2013 at 12:44