Closed GoogleCodeExporter closed 8 years ago
Hi henj-jan,
I have a slightly different requirement which I do now with a routescript.
Sometimes do 2 translations in sequence over the same file, eg. xml -> idoc ->
html-template. This is because we get many input formats and convert all to
idoc. But then sometimes, because of an unusual condition we know the idoc
cannot be imported into SAP and some human interpretation is required. In this
case, we email a user-friendly html format for manual entry.
My current solution is to set out.ta_info['alt'] = 'EMAIL' in the mapping, then
with a simple routescript, change status back to TRANSLATE and do a second
translation.
def posttranslation(routedict):
transform.addinfo(change={'status':TRANSLATE},where={'status':TRANSLATED,'idroute':routedict['idroute'],'alt':'EMAIL'})
transform.translate(idroute=routedict['idroute'])
If I were to just return 'EMAIL' from the mapping I would need a new mapping
from each input format to html format, rather than just one from idoc to html.
Maybe return syntax like '+EMAIL' to indicate this is an additional translation
on the output of the previous one.
Original comment by mjg1964
on 26 Apr 2012 at 7:27
hi Mike,
this might be a very good idea.
realizing this should be easy; this is al about what a mapping return.
my first thoughts would be:
- do not change the way it works now; returning a string activates another
(chained) translation.
- but a translation can also return a dict, or type, etc. Easy to test on this.
if returnedvalue is a dict:
if returnedvalue['type'] == <some value>:
(starts the thing you do now)
(this can make this general and extensible; there might be more cases. jean-Francois might be touching something like this in a very recent posting)
tryng to get a clear picture of what you do now:
in the mapping script you check for certain conditions in the incoming data.
if OK:
write IDOC
if not OK:
(do not write IDOC?)
start alt translation (with alt=EMAIL)
this alt translation writes the IDOC
then you 'turn back' the outgoing files whre alt=email
you receive the IDOC as incoming?
you generate html-output
Is this right?
kind regards,
Henk-Jan Ebbers
www.ebbersconsult.com
t: 0031 30 2888358
Bots Open Source EDI Translator: http://bots.sourceforge.net
On 04/26/2012 09:27 AM, bots@googlecode.com wrote:
Original comment by hjebb...@gmail.com
on 26 Apr 2012 at 4:54
Not quite right...
In the mapping scripts, convert incoming to idoc as normal.
Incoming can be edifact, fixed, csv, xml...
Last step in each mapping, check idoc data against some rules
if OK:
return none (idoc is the output)
if not OK:
return <something else>, a dict would be ok
idoc is still written into bots data folder
start another translation, it's input is the idoc just written
this alt translation writes the html-template
html-template is output by the route
view details shows two translations, idoc can be viewed
then I send the email to be entered manually with a second seq and outchannel
in the route.
My current method, mapping script always returns None, but it sets alt in
ta_info. Then I detect this in many routescripts. New method would allow return
<something> to trigger this behaviour and not need the routescripts.
Original comment by mjg1964
on 26 Apr 2012 at 10:42
so, it could be:
you can return a dict; if certain type than use in out-object as inn in
alt-translation
eg return {'type': 'out_as_inn', 'alt':'alt-value'}
kind regards,
Henk-Jan Ebbers
On 04/27/2012 12:42 AM, bots@googlecode.com wrote:
Original comment by hjebb...@gmail.com
on 1 May 2012 at 3:24
yes that sounds good :)
Original comment by mjg1964
on 1 May 2012 at 7:36
hi mike,
this extended chained translation is now in repository.
kind regards,
henk-jan
Original comment by hjebb...@gmail.com
on 10 May 2012 at 5:40
Original comment by hjebb...@gmail.com
on 10 Sep 2013 at 12:45
Original issue reported on code.google.com by
hjebb...@gmail.com
on 25 Apr 2012 at 4:11