Skip to Content
avatar image
Former Member

Dynamic file naming

Hi ,

I have IDOC to file scenario,

The file name is in the format ABC_00.txt.

If the target location does not contain any file with name in the above format, then it should generate a file ABC_00.txt,

if the target location already contains the file with name ABC_00.txt then the next file generated should have the name ABC_01.txt and so on...

please provide details on this..

Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 04, 2009 at 08:21 AM

    Hi Akkasali,

    If you are using Transport protocol as (NFS) than you can use "Add Counter" in file construction mode.

    If you are using Transport protocol as (FTP), than develop a module, In the module,

    First check the file name in the target directtory, if exist, than rename the file by increment.

    regards,

    Chandra Shekhar.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 04, 2009 at 06:42 AM

    This can be done with the help of OS script which can be provided in the File adapter .

    The script should be such a way that it should validate the FileName if exists then need create a new file name with your filename and delete the existing file

    Rajesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 04, 2009 at 06:43 AM

    Hi,

    You can add counter in your receiver file communication channel and specify the format of the counter.

    Please see sap help for this:

    http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm

    With this it would not check for the existence of the file in the target directory. But the file will have the counter in the end. If you want to check manually then you need to write an adapter module which does this check for you.

    or as mentioend above you can try adding the counter and the OS script where you pass the input filename for your script and does the check.

    Regards,

    ---Satish

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 04, 2009 at 07:19 AM

    Hi,

    I have done similar requirement in one of my project. In receiver file structure root node implement below conditon.

    1. According to your requirement file name ABC pick from source eith idoc or constant.

    2. Generate one text file under first row add counter value 00. Read this file from mapping window after read counter data from file increment counter value(i.e first time counter value 00 after read the counter value is 01).

    Mapping logic

    Filename..............

    Counter(UDF read counter value from file)...............Contatefunction(_)

    Again take concate function and add above concate output to this function.

    Filename_counter....

    Constant(txt)........Concatfunction(.)............DynamicFilename(use standard java code)......................ReceiverRootNode

    I hope now clear

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 04, 2009 at 07:42 AM

    Hi Rajesh,

    Am new to PI ,can u please elaborate on how and where to write OS script.

    thanks.

    Add comment
    10|10000 characters needed characters exceeded