Filename out of Messagescript

195 views
Skip to first unread message

PGMEUP

unread,
Oct 26, 2012, 3:20:07 AM10/26/12
to bots...@googlegroups.com
Hello,

I am using a very strange way to set the Bots outputfilename, and I want to change this. The existing Threads about filenames didn't help me either (or maybe I didn't search correct).

This is my requirement: Use Fields out of the Input or Output file as part of my filename.

This is how I changed my mapping-script:
# testindicator is a variable field used to give the output name
out.ta_info['testindicator'] = '%s|%s|%s' % (value1, value2, value3)

This is my communicationscript:


import time 

def main(channeldict,filename):
return true

# Name the output file using partner names
# channel must include "*" in filename
# syntax must contain 'merge':False
def filename(channeldict,ta,filename):
# fetch the attributes of ta-object
ta.syn('frompartner')
ta.syn('testindicator')
# the fetched attributes can be accesed with "ta.[attributename]" now
if ta.testindicator :
# get values out of testindicator. testindicator is filled in the mapping script.
  value1 = ta.testindicator.split('|')[0]
  value2 = ta.testindicator.split('|')[1]
  value3 = ta.testindicator.split('|')[2]

    # return filename
  return channeldict['filename'].replace('*', value1 + '_' + value2 + '_' + value3 + '_' + time.strftime('%Y%m%d'))
else:
  return filename



How is this issue solved usually? I don't think that testindicator was a good idea for me.

Kind regards,
Dominik Müller

BikeMike

unread,
Nov 4, 2012, 4:19:28 AM11/4/12
to bots...@googlegroups.com
Hi Dominik,
Normally I would use botskey for this (unless perhaps you are using it for something else).

in mapping:
out.ta_info['botskey] = '%s_%s_%s_%s' % (value1, value2, value3, time.strftime('%Y%m%d'))

in communicationscript:
ta.syn('botskey')
if ta.botskey:
    return channeldict['filename'].replace('*', botskey)
else:
    return filename


Note: in the next version there will be a new way to do this without a communicationscript; see details here.
Kind Regards,
Mike.

PGMEUP

unread,
Nov 8, 2012, 2:50:02 AM11/8/12
to bots...@googlegroups.com
Dear Mike,

thank you for your suggestions. As I see understood now, using the ta-fields for passing information to the communicationscript isn't that bad at all. 
But why should I use botskey instead of testindicator? Does it matter? 

Kind Regards,
Dominik Müller

BikeMike

unread,
Nov 8, 2012, 6:26:32 AM11/8/12
to bots...@googlegroups.com
Hi Dominik,
testindicator is a field with a specific purpose. If the output is edifact or x12 the testindicator is part of the document envelope and indicates to the recipient whether the document is test or production (1 or 0).

botskey is a "user" field that can be used for anything useful to you and can also be used to search (normally I use it for the order number. invoice number etc). It does not go into the output unless you deliberately map it somewhere,

Kind Regards,
Mike

PGMEUP

unread,
Nov 8, 2012, 11:47:09 AM11/8/12
to bots...@googlegroups.com
Dear Mike,

ok, I will use botskey (hope it isn't a problem when the field is not unique). Thank you.

Kind Regards,
Dominik Müller

henk-jan ebbers

unread,
Nov 8, 2012, 11:54:07 AM11/8/12
to bots...@googlegroups.com
Dominik,

that filenames generated by bots are unique....
botskey might not be unique.
it is not good to use their documentnumber as a unique key.
(general edi/IT rule: be able to operate independent from such assumptions)

if you for some reason need the document-number in the filename, keep the unique part that bots offers. (eg append the documetn number to the unique file name)

also: botskey only works if one file contains one document.
in edifact messages are typically 'enveloped'.

kind regards,
henk-jan
> --
>
>

PGMEUP

unread,
Nov 8, 2012, 12:09:29 PM11/8/12
to bots...@googlegroups.com
Hello Henk-Jan,

in that case, I won't use botskey. I stay with testindicator, but I still have no use for bots unique file name. Because my EDI partner has very strict filename rules.
I know that filenames shouldn't be a matter in EDI flow, but unfortunately, my partner insists on his logic.

Kind Regards
Dominik Müller

henk-jan ebbers

unread,
Nov 8, 2012, 12:13:53 PM11/8/12
to bots...@googlegroups.com
what is their logic for filenames?

henk-jan
> --
>
>

BikeMike

unread,
Nov 8, 2012, 4:30:31 PM11/8/12
to bots...@googlegroups.com
Hi Dominik,
I think you misunderstood what henk-jan meant...
It does not matter if botskey is not unique, it is just a field within bots for searching etc.

It does (or might) matter if the output filename is not unique, because the files could be overwritten etc. This will also depend on the output location and what happens there, eg. whether files get picked up and deleted immediately, possibility of a duplicate filename in the same run etc. So you could include a unique part in the filename to eliminate the risk.

in communicationscript:
ta.syn('botskey')
if ta.botskey:
    return channeldict['filename'].replace('*', botskey + '_' + filename) # filename field contains unique name
else:
    return filename


Kind Regards,
Mike

PGMEUP

unread,
Nov 9, 2012, 3:30:04 AM11/9/12
to bots...@googlegroups.com
Dear Henk-Jan,

they want to have our customer number in all our files, as well as an unique Number. The unique Number can't be provided by bots, because our system needs the same unique number for other purposes, too. 
Hence, we have to take the unique number out of our source system (mapping script), and map it into the output filename.

Kind Regards, 
Dominik Müller

PGMEUP

unread,
Nov 9, 2012, 3:43:17 AM11/9/12
to bots...@googlegroups.com
Hi Mike,

I thought using botskey on EDIFACT for filename won't work, because its enveloped.

Regarding unique filename: If the filename isn't unique, we have a problem in our previous processes. By appending "_[bots unique number]" , I would not fix the actual problem. 

Sorry for not mentioning this before, I didn't want to bother you with (seemingly) unnecessary information.

Kind Regards
Dominik Müller

PGMEUP

unread,
Nov 9, 2012, 3:43:30 AM11/9/12
to bots...@googlegroups.com
Hi Mike,

I thought using botskey on EDIFACT for filename won't work, because its enveloped.

Regarding unique filename: If the filename isn't unique, we have a problem in our previous processes. By appending "_[bots unique number]" , I would not fix the actual problem. 

Sorry for not mentioning this before, I didn't want to bother you with (seemingly) unnecessary information.

Kind Regards
Dominik Müller

Am Donnerstag, 8. November 2012 22:30:31 UTC+1 schrieb BikeMike:

henk-jan ebbers

unread,
Nov 9, 2012, 6:32:36 AM11/9/12
to bots...@googlegroups.com
hi Dominik,

I just do not understand the requirements (after reading this email and your others).
(I really don't)

henk-jan
> --
>
>

PGMEUP

unread,
Nov 9, 2012, 8:12:12 AM11/9/12
to bots...@googlegroups.com
Hi Henk-Jan,

I am converting Flatfiles (coming from our inhouse system) into EDIFACT files (for our EDI Partner).
My Flatfile contains an unique ID, which MUST occur in the outfile name.

1. Take unique ID out of my infile (mappingscript) -> ta.testindicator or ta.botskey
2. Use unique ID for creating outfile (communicationscript)

I opened this Thread, because I thought, there would be a better way then "abusing" the ta-fields to send values from my mappingscript to my communicationscript.

Kind Regards,
Dominik Müller

henk-jan ebbers

unread,
Nov 9, 2012, 8:26:25 AM11/9/12
to bots...@googlegroups.com
1 edi file comes in.
it contains n (?) messages (editype 'fixed', messagetype 'x')
each message of editype 'fixed', messagetype 'x' is converted to m (?) messages (editype 'edifact', messagetype 'Y')

where is the uniqueID related to? this file, the n messages, the m messages?? (or: what is identified?)

or are there more incoming edi-files with same unique number?


I hope you understand why things are not clear to me....
I am convinced that as soon as I understand the problem therre is a solution ;-))


(so far, there have been several suggestions, but for each suggestion you say: yes, but <additional requirement>.
no problem, but let's get the requirements clear first. all of them)


henk-jan
> --
>
>

PGMEUP

unread,
Nov 9, 2012, 8:54:05 AM11/9/12
to bots...@googlegroups.com
Dear Henk-Jan,

sorry for the confusion. 
I just wanted to keep things as simple as possible, because I already have a working solution (testindicator) and just wanted to know the "official" way.

I have 1 Input File, containing 1 Message, which goes to 1 Output file (1 Message). The ID is unique for each Input File, therefore, it is unique for each Output File.

Kind Regards,
Dominik Müller

henk-jan ebbers

unread,
Nov 9, 2012, 9:06:48 AM11/9/12
to bots...@googlegroups.com




On 11/09/2012 02:54 PM, PGMEUP wrote:
> Dear Henk-Jan,
>
> sorry for the confusion.
no trouble.
> I just wanted to keep things as simple as possible, because I already have a working solution (testindicator) and just wanted to know the "official" way.
what does it identifiy really?
what is the number used for? why do you need it in your internal system?
waht is the number called?
is it a document ID? (liek order number, invoice number)
is it an interchange number that needs to be sequential number, identifiying the file-transport?
(there are so many 'unique identifiers' in edi.....)


henk-jan
> --
>
>

PGMEUP

unread,
Nov 9, 2012, 9:18:13 AM11/9/12
to bots...@googlegroups.com
Dear Henk-Jan,

it is an shipment identifier. In our system, we use it for selections, displays and printouts. And it also is a sequential number, identifying the file-transport. If we talk to our EDI partner, we say "IFTMIN for shipment no. xxx had an issue with yyy".
Each shipment is a new file and a new message.

Kind Regards,
Dominik Müller

henk-jan ebbers

unread,
Nov 9, 2012, 9:22:02 AM11/9/12
to bots...@googlegroups.com
OK, now I understand.

this is in bots called a document ID; and indeed the technical name (in database) is botskey.
so botskey is really what you need here...

kind regards,
henk-jan
> --
>
>

PGMEUP

unread,
Nov 9, 2012, 9:27:40 AM11/9/12
to bots...@googlegroups.com
Hello Henk-Jan,

good that things are settled now!
I use botskey and that's it. Thank you, and Mike too.

Kind Regards,
Dominik Müller
Reply all
Reply to author
Forward
0 new messages