there is no build-in logic in bots for the concept of 'same fieldname'.
so you have to tell what field goes to what field (bots often deals with edi formats, which have a very elaborate stucture)
but I do think there is a tric for what you want.
there is a grammar for input.csv,
and a grammar for output1.csv
remove all fields you do not need in grammar output1 (so leave only d,f,a,b)
than in the syntax of the grammar:
'checkunknownentities': False,
you need a tfile, but is is very simple:
import bots.transform as transform
def main(inn,out):
transform.inn2out(inn,out)
(have not tried this myself, but I expect this to work. let me know if this works for you)
kind regards,
henk-jan
Bots Open Source EDI Translator: http://bots.sourceforge.net
yes, that would be a nice enhancement!
henk-jan
henk-jan
On 01/25/2012 08:41 PM, Bill Butler wrote:
> Hmmm,
>
> The terminology has me a little baffled. We have:
>
> -Tscripts,
you are right, this is confusing. they should be called mapping scripts, I will change this in the interface.
> -Translations
> -messagetypes
> -grammars
> -routes
> -editype
> -mapping scripts
> -Alternative translations
> -channels
>
> Channels are well defined (in and out paths).
> Tscripts, and mapping scripts appear to be one in the same.
these are these same, yes. tscript should disappear!
> Translations are possibly the combination of grammars and Tscripts/
> mapping scripts
each messagetype is defined in a grammar (records, fields, etc).
a translation uses a mapping script
a translation is being define in the GUI, it refers to a mapping script
> Grammars are messagetypes
a messagetype is defined in a grammar.
> Routes map translations to paths and tie them to trading partners.
I do not know what you have in mind here.
> Editype appears to be redundant for the purposed of classification
I am not a native speaker of english, it is not clear to me what you have in mind here.
> I hope that I'm wrong about the stuff above, because the nomenclature
> is killing me!
your post is indeed helping to get the se names better and more clear! thank you.
> Here is what I did per your suggestion
>
> fromeditype: csv
> frommessagetype: my_in
might wanna choose a name that has more meaning. Eg orders, invoices? what document is coming in?
> Tscript: my_in2EDITrans
I try to use the name systematic as: <fromeditype><<frommessagetype>2<toeditype><tomessagetype>
> toeditype: csv
> tomessagetype: EDITrans
try to use something that has a meaning to your business process.
> alternate translation: EDIPatient
>
> fromeditype: csv
> frommessagetype: my_in
> Tscript: my_in2EDIPatient
> toeditype: csv
> tomessagetype: EDIPatient
>
> I added return 'EDIPatient' to the bottom of TScript: my_in2EDITrans
> (although I don't really understand why since I specified the
> alternate translation in my first translation).
>
> All I ended up with was the EDIPatient file. No EDITrans file was
> generated. Just to recap, I can run one at a time successfully.
yes, and I can see why: it should be at the end of the my_in2EDIPatient script.
the id's used here get quite confusion.
maybe an alt ID like 'do_the_2nd_translation:EDItrans' would be better.
my 'alt' names have the tendency to be long and descriptive, I hope you understand why.
> One question about this: When I string together translations, is it
> running them simultaneously building EDITrans and EDIPatient
> simultaneously or is it finishing EDITrans and then moving on to
> EDIPatient?
see below how it works, but translations are done one after the other.
> Also, what are we specifying in the return statement?
works likes this:
- bots parses the incoming message, using the fromeditype and frommessagetype to find the right grammar.
- bots looks up in the translation table, with fromeditype and frommessagetype as keys.
It will find the mappingscript (in your case: my_in2EDIPatient), the toeditype (csv) and tomessagetype (EDIPatient)
- the mappingscript is run, and produces the EDIPatient-outgoing files (within bots, actual output is later)
- the mapping script ends with return 'EDIPatient'
- bots will again look in the translation table, with fromeditype and frommessagetype as keys but 'EDIpatient' as 'alt' (is used as extra key in the lokup)
For this 2nd translation bots will find the mappingscript (in your case: my_in2EDITrans), the toeditype (csv) and tomessagetype (EDITrans)
- the mappingscript is run, and produces these outgoing files (within bots, actual output is later)
- the mapping script does not send an 'alt' value, and bots will not do another translation for the incoming file
hope this makes it more clear.
> it the name of a Translation, or a TScript? Translations are
> particularly weird in BOTS, because they aren't really named.
yes, that is weird.
it might have been better to use the name of the mapping script as the name of the translation.
I have to think about this.
I guess this did not feel right, because (fromeditype, frommessageetype, alt etc) is the key.
> For
> instance, when I make a route, I give it a name, but a translation is
> just a combination of stuff with no name.
yes.
> If I get this figured out with your help, I will spend the time to
> write a dedicated section of the WIKI devoted to this.
great.
The topic of sensible naming of all these things is quite important (for me).
I have lots of setups (I do commercial services for bots).
when I look at a setup I haven't seen for a year, I want to understand fast what everything does.
eg I mostly use for naming routes and channels:
route: inbound_<name company>
inchannel: inbound_<name company>_in
outchannel: inbound_<name company>_out
(where inbound means: coming into your company)
kind regards,
Henk-Jan Ebbers
henk-jan
On 01/30/2012 03:50 PM, Bill Butler wrote:
> That was the trick. I ended up getting this to work by defining the
> first route with the infile, translation and outfile. Then I named the
> second route the same but with a different priority and just named the
> outfile. It wasn't that intuitive, but it works. I view EDI as a
> series of paths and I find it strange that you'd build in
> functionality to string translations together. Seems that it would
> make a lot more sense to map grammars to maps and then back to
> grammars in any combination that the user sees fit.
that is what the translation table does, doesn't it?
or do you have something else in mind?
> Also, I'd envision
> a page that actually gives you a popup list of all of your grammars
> instead of forcing you to type in the grammar.
yes, that would be a good idea.
> I understand the
> concept of channels, but it seems like there should be a more
> intuitive way to handle this as well. Tying a grammar back to a
> channel isn't really intuitive.
I am not sure what you have in mind here.
> Seems like that could also just be
> part of the route...for instance:
>
> Route A: priority 10
>
> Inbound transport: ftp:21:username:password
problem is: some channels have much more parameters than that.
kind regards,
Henk-Jan Ebbers