Counter in target file name

Hi ,
      There is a feature to append a counter value to the file name in the file adapter using NFS protocol , where is this counter value stored in the adapter engine so that the next time a file is created its name has incremented value for the counter. Can that value be stored and accessed using custom module in the receiver adapter for some modification in the standard feature.
Thanks in advance,
Pravesh Puria.

Hi,
In the "Processing Parameters" section, in the dropdown for "File Constrcution Mode", you can select "Add Counter".  Then, use the "Counter Definition" section to configure tne increment for the counter.  You can also put a prefix before the counter in this configuration.
Also, by using the section "Adapter-Specific Message Attributes", you can use an user-defined function to create the filename based on your own specific requirement, which can by dynamically determined duirng runtime.
Regards,
Bill

Similar Messages

  • Target file name as field in target structure

    Hi SDNers,
    I have a requirement where I need to populate a field in target structure with the target file name, this will be a counter.
    So if the interface is run 2 times already the third file should have name XXXXXXX_03 and also this needs to be mapped to a field in the target structure.
    Any ideas on how to achieve this?
    (Pls Note: I am aware of ASMA and variable substitution)
    Regards,
    Gautam Purohit

    Hello Gautam!
    File adapter - How to pass File name and path at runtime
    This SDN topic probably covers the requirement you mentioned!
    BR,
    Lucas

  • Need to genereate Target file name same as Source File Name thru Local J2SE

    Hi Everyone,
    I want to genereate Target file name exactly same as Source File Name. I know how to handle this in Central Adapter Engine(Sender & Receiver Communication Channel).
    But I need to do this in Local J2SE adpater engine.
    Please help me in this regard.
    Thanks & Regards,
    Nagaraju

    U can use the parameter to save the filename in the message header
    file.messageAttributes=<name,directory>
    This is similar "Adapter-Specific Message Attributes" concept.
    http://help.sap.com/saphelp_nw04/helpdata/en/6f/246b3de666930fe10000000a114084/frameset.htm
    Regards,
    Prateek

  • Need Target File  Name  Timestamp  is  same  as Source File name Timestamp

    Hi ,
           I want to genereate Target file name (Target_09062008082030.xml)   but  this time stamp is exactly Sorce FileTime stamp..(Source_09062008082030.xml)..
         so, i want to create a  target file  with the same source file time stamp.. 
    for this.. i sed Message Specific attributes... in both sender and receiver side.. but  that was creating with the complete name.of source file name.. but i want only Timestamp of the source filename... and remaing is the constant.. for this  how can i proceed  ..
    Thanks
    Jain

    See in Sender CC when you set the Adapter Specific Message Attr  for file name it will send the filename in the header of the XI Message.
    To acces this file name inside mapping you need to create a UDF . The type can be any thing as you desire.
    You dont need to pass any variable .if suppose you want the file name (constant) e.g ABC_<timestamp>.xml
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String fileName= conf.get(key);
    //see above your key is FileName which will be sent by the sender CC automatically... You are simply accessing it here using get() method.
    //now ur filename will contain name of the source file... you need to perform a substring operation to get the timestamp and create a new file name as you desire.
    fileName = "New_<timestmp>.xml"; //for e.g
    //set this file name again in header message using put()
    conf.put(key, fileName);
    //when you check on the adapter specific message attr for fileName in the receiver CC ,it will automatically take this new file name value.
    return fileName;
    // if you want to use this new fileName inside your mapping payload (for other fields) you can assign this to any target field,else just assign it to the root tag which will make no difference if this file name is not used anywhere.

  • Regarding Target File name

    Hi Everyone,
    I want the Target File name to be as Update_Order_%y%y%y%y%M%M%d%d%H%H%m%m%s%s.A04.
    How do i proceed to create such files.
    Any help would be appreciated.
    Thanks & Regards,
    Varun

    >
    Varun Reddy wrote:
    > Hi Everyone,
    >
    > I want the Target File name to be as Update_Order_%y%y%y%y%M%M%d%d%H%H%m%m%s%s.A04.
    > How do i proceed to create such files.
    > Any help would be appreciated.
    >
    > Thanks & Regards,
    > Varun
    Hi,
    1. In the Sender File Communication Channel, check the option Set Adapter-Specific Message Attribute and Filename.
    2. Assuming Update_Order is a constant string, Use this UDF. If Update_Order is a element at your source structure, pass it as a parameter to the UDF.
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    java.text.SimpleDateFormat dateformat = new java.text.SimpleDateFormat( "yyyyMMddHHmmss" );
    dateformat.format( new java.util.Date() );
    String tagetfilename="Update_Order_" + dateformat;
    conf.put(key, newfilename);
    Regards,
    Chandra

  • Add counter in  Receiver File name

    Hello  Everyone,
    I have a Idoc to file scenaraio . The file comes regularly and whenevr the file comes, it should get suffix with datestamp and then the counter.
    The  name is should be Partner_YYYYMMDDHHMMSSL.xml.
    Where L is counter and should be increased everytime.
    Regards,
    Ravi

    try below logic:
    partnerconstant(_) concat -> time stamp udf + concatcounter concat+constant(.xml) +concat -> dynamic config udf -> target node.
    click on counter standard function and enter Initial value 1 and incremental 1 .
    time stamp udf:
    String AddTimestamp(String var1, Container container) throws StreamTransformationException{
    String DATE_FORMAT_NOW = "yyyyMMddHHmmss";
       Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
        return sdf.format(cal.getTime());
    note :add import instructions(pkg) java.text.SimpleDateFormat
    dynamic conf:
    String DynamicConfig(String a, Container container) throws StreamTransformationException{
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    conf.put(key,a);
    return "";
    in id:
    you have to enable ASMA and File Name properties in Receiver File Adapter.
    Edited by: bhavanisankar.solasu on Mar 7, 2012 4:13 PM

  • Variable subsitution for target file names

    Hi All,
    I am using variable subsitution for dynamic file names. I am using the multimapping for multiple files in the target.So i coluld not able to use the dynamic configuration for file names. Now i want to replace all the spaces in the filename to underscore.
    For example
    My payload filed value "file name in the target file".
    Now my filename  "file_name_in_the_target_file".
    How to achieve this using Variable subsitution.
    Regards,
    Ramalakshmi.G

    Use replaceString Function.
    file name
    Constant (" ")               --> replaceString -------> TargetField
    Constant ("_")
    Regards
    Ramesh

  • Target file name-'YYYYMMDD-HHMMSSMMM- test .txt

    Hi Experts,
    We have a requirement where we need target filename as 'YYYYMMDD-HHMMSSMMM-test.txt'. Kindly suggest can we get this filename without using Variable Substitution and Dynamic Configuration.
    Regards,
    Sudha

    Hi Sudha,
    If your requirement is to avoid using Variable Substitution and Dynamic Configuration, you can always use an Operating System Command After Processing that you will define in the Receiver Communication Channel. You can use it to change the file name of the file that just got created, and add the timestamp at the beginning.
    Hope this helps,
    Greg

  • How to get the target file name from an URL?

    Hi there,
    I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
    If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
    URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
    However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
    URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Do you know how I can do that.
    Thanks for your help
    // JB
    Edited by: jb-from-sydney on Feb 9, 2010 10:37 PM

    Thanks for your answer.
    By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
          * Download locally a file from a given URL.
          * @param url - the url.
          * @param destinationFolder - The destination folder.
          * @return the file
          * @throws IOException Signals that an I/O exception has occurred.
         public static final File downloadFile(URL url, File destinationFolder) throws IOException {
              URLConnection urlC = url.openConnection();
              InputStream is = urlC.getInputStream();
              FileOutputStream fos = null;
              String fileName = getFileName(urlC);
              destinationFolder.mkdirs();
              File localFile = new File(destinationFolder, fileName);
              fos = new FileOutputStream(localFile);
              try {
                   byte[] buf = new byte[1024];
                   int i = 0;
                   while ((i = is.read(buf)) != -1) {
                        fos.write(buf, 0, i);
              } finally {
                   if (is != null)
                        is.close();
                   if (fos != null)
                        fos.close();
              return localFile;
          * Returns the file name associated to an url connection.<br />
          * The result is not a path but just a file name.
          * @param urlC - the url connection
          * @return the file name
          * @throws IOException Signals that an I/O exception has occurred.
         private static final String getFileName(URLConnection urlC) throws IOException {
              String fileName = null;
              String contentDisposition = urlC.getHeaderField("content-disposition");
              if (contentDisposition != null) {
                   fileName = extractFileNameFromContentDisposition(contentDisposition);
              // if the file name cannot be extracted from the content-disposition
              // header, using the url.getFilename() method
              if (fileName == null) {
                   StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
                   while (st.hasMoreTokens())
                        fileName = st.nextToken();
              return fileName;
          * Extract the file name from the content disposition header.
          * <p>
          * See <a
          * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
          * //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
          * information regarding the headers in HTML.
          * @param contentDisposition - the content-disposition header. Cannot be
          *            <code>null>/code>.
          * @return the file name, or <code>null</code> if the content-disposition
          *         header does not contain the filename attribute.
         private static final String extractFileNameFromContentDisposition(
                   String contentDisposition) {
              String[] attributes = contentDisposition.split(";");
              for (String a : attributes) {
                   if (a.toLowerCase().contains("filename")) {
                        // The attribute is the file name. The filename is between
                        // quotes.
                        return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
              // not found
              return null;
         }

  • Target file name using Dynamic Configuration

    Hi,
    Currently we have requirement Idoc to File interface.In this scenario if one field exists infile then we have to check and we need to create update directory and  if it is not exist then we should create one more  directory and upload files over there there files should create with timestamp. Since,File system using Sql database so we have used JDBC lookup to check that particaluar field  and if it exists we are passing update to UDF if it is not then we are passing constant Create to that. If we use Adapter Specific Message Attributes  then in reciever side file Communication Channel addtimestap will it consider or do we have to write anything in Udf it self? Could anybody explain on this?Please provide some sample udf .
    Thanks ,
    Aparna.
    Edited by: aparna_karnam on Dec 24, 2011 11:44 AM
    Edited by: aparna_karnam on Dec 24, 2011 11:52 AM

    Hi,   
            I have added little changes to the code you have written, to meet your expectations
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
    conf.put(key,"/sap-dev/" +a);
    DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
    string filename=conf1.get(key1);
    final String DATE_FORMAT_NOW = "dd-MM-yyyy_HH-mm-ss";
    String s;
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT_NOW);
    java.util.Calendar cal = java.util.Calendar.getInstance();
    s=sdf.format(cal.getTime());
    filename=a+" "+"User_"+s+".txt";
    conf1.put(key1,filename);
    return " ";
    So if value of input variable "a" is "update" then the target directory will be "/sap-dev/update" and the file formed will have name "update User_26-12-2011_01-20-50.txt", of course the date and time values will change depending on server settings. I just showed a sample. one more point, the directory will not be created, you have to create the directories before you run the scenario, only the final directory will be decided depending on value of variable "a". In case you wanna create new directory if directory is not pre-existing then try ticking  on "Create Target Directory" option under "file access parameters" in communication channel. (I have never used this option u can have a try. )
    Now coming to your queries
    1. But whether file type txt automatically it will take or do we have to give in udf it self ?
    ans) You have to put the value in UDF as I have done in code.
    2.    how it will consider timestamp ?
    ans) This has been generated in UDF itself.
    3.  how i can give file extension .txt?
    ans) same as ans 1
    4. And also in Receiver Communication Channel under Adapter Specific Message attributes we have option of file type how it works?
    ans) File type determines is the file you are going to write is of type "text" or "binary". From "Processing Parameters" tab you can select this from drop down menu in communication channel or you can set it through ASMA properties in similar manner as you have done for file name and directory name. For more details refer to http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    http://help.sap.com/saphelp_nwpi71/helpdata/en/44/6830e67f2a6d12e10000000a1553f6/content.htm
    Finally few more points I would like to add
    1) you have  not mentioned the operating system of the server where file is going to form. In case its UNIX/LINUX you are not allowed to use space in the filename. you can consult these links before you decide on file name and directory name in the UDF mentioned above
    http://www.med.nyu.edu/rcr/rcr/nyu_vms/unixfileanddirectorynames.htm     (UNIX)
    http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions  (WINDOWS)
    2) you can alter the string "DATE_FORMAT_NOW" as per your requirement so  that the timestamp appears in the way you want. I have just showed a sample.
    3) Plesae do not forget to tick on the options "Use Adapter-Specific Message Attributes indicator", "Fail If Adapter-Specific Message Attributes Missing", indicators "File Name" and "Directory" under "Define Adapter-Specific Message Attributes." in receiver communication channel.
    Hope this solves your problem.
    Wish my dear forum members and users of SDN
    Merry Christmas and Happy new year (in advance)
    Regards
    Anupam
    N.B:- I initially forgot to add the ".txt" part to the file name. I made necessary corrections in code now.

  • Target file name - YYMMDD FILE - how to achieve

    Hi guys!
    I need to produce target file in my receiver fila adapter of name, where date is a part of the name. However, it is not a part of message, so there's no way, how to get it from payload.
    Any ideas, how to achieve it?
    example: 070924FILE
    Olian

    Hi Olian
    have a look at this Thread
    mapping UDF
    File Name with extension
    mapping UDF
    Re: convert to julian date
    Thanks !

  • How to get target file name and buffer the incoming messages?

    Hi Experts
    I have one scenarion like
    I wanted to find whether is there any file existing in target folder. If it exists I dont want to overwrite it but I have to buffer the incoming messages in some queue or something like that. And when ever the request comes next time I have to send the data buffered in queue first.
    I dont want to add any time stamp for target file to avoide duplication.
    Can we do this using XI. If yes please suggest me how to achive this.
    Regards
    Sowmya

    >
    Sowmya wrote:
    > Hi Experts
    >
    > I have one scenarion like
    > I wanted to find whether is there any file existing in target folder. If it exists I dont want to overwrite it but I have to buffer the incoming messages in some queue or something like that. And when ever the request comes next time I have to send the data buffered in queue first.
    >
    > I dont want to add any time stamp for target file to avoide duplication.
    >
    > Can we do this using XI. If yes please suggest me how to achive this.
    >
    >
    > Regards
    > Sowmya
    there is no standard way to achieve this. I suggest a redesign.
    post the files to a different directory and write a script which will move the file to the required target directory only if it is not present there.

  • Add Counter at the end of file name

    Hi all,
       I am using NFS protocol and trying to add counter at the end of the file. I have given the Prefix as  '-'
    Format : 1
    Step: 1
    Mode: After First File
    Is the prefix is right? Am i giving the values in right way? Please help me.
    The format required is: test_1.xml
    Thanks,
    Sri

    HI Arun,
    I m not so sure but i think prefix can not have any special character.
    You can do this by giving your file name in target->file name schema as File_* while configuring your communication channel.
    After that it will add automatically your required counter.
    thanks.

  • Counter in file name in receiver file adapter

    Hi,
    I am using FTP, my requirement is to add counter in the file name i.e XYZ001.
    And added to this i can increment the counter till XYZ020, after this i am supposed to start again from XYZ001.It will be some how handled that when i place XYZ001 for the second time , it will not overwrite the earlier one as it will be proccess by that time.
    I could have used addcounter but it doesnt work for FTP:(...also have seen /people/shabarish.vijayakumar/blog/2009/10/05/pixi-maintaining-sequence-numbers-in-file-name-scheme
    Do we have any new feature added in PI 7.1 for handling this.
    Regards,
    Abhi

    thanks shabz..
    Request you to please let me know how to proceed with the first option which you have mentioned i.e,how to create tables and will i be able to start the counter again from xyz001 once i reach xyz020? is there any abap code to be written (wiil be asking SAP counterpart ) or we need to do it in the dynamic configuration udf? Please let me know how to do the same.
    1. Maintain a table in SAP. Use/Code a RFC call to look up the sequence number from this table, incrementing the value after it is read. The result is then used in a dynamic configuration code, and the file name can be generated at that point.
    Will this impact performance ?..mine is a credit card authentication interface and response time is imp...
    Regards,
    Abhi

  • Target file of the same name as source file

    Hi,
        I am working on a file to file scenario. I need the target file name to be same as the source file name.
        I checked the adapter specific message attributes in the sender as well as receiver file adapter,and also checked the file name.
        Now am using variable substitution for the file name in the receiver file adapter.
        I defined the variable value as :
        message:FileName
       But no file is getting created in the destination folder.
       Can anyone help me out with this.
    Thanks and regards,
    Pravesh Puria.

    Pravesh,
    If you have selected  File adapter --> Adapter Specfic Attribuest --> File name in the sender and receiver file adapter , then do not go for variable name substittutuion.
    Just make a dummy file name in the receiver file adapter for the file name field and XI will automatically use the same file name as the source when creating the file.
    Regards,
    Bhavesh

Maybe you are looking for

  • Number of connections unused in a weblogic pool ?

    Here is my question : Do you know a way to know the number of connections unused (or the number of connections in use) at a particular moment in a weblogic connection pool ? Thanks a lot ! And sorry for my poor english... Jerome.

  • Benefits Strong Interview Questions - Urgent Please

    Dear Friends, I need know the more depth Benefits Interview Questions and Answers? I appreciate your time. Thanks, Sammer.

  • Need info on Cloning Server Services in BOXi3.1

    Hi All, I am looking for information on Cloning Server Services in BOXi3.1. The specific points that i am looking for are mentioned below: 1. How cloning is of advantage, specially in areas where we are facing network traffic? 2. Can we monitor WEBI

  • CS6 not opening in CS5  color books error

    When I save a PhotoShop CS6 file, the computer we still have running CS5 will not open the file.  The error message is... "Could not complete your request because the specified color book cannot be found."  What are the work arounds for this?

  • QaaWS and SSL

    I have configured Tomcat to use SSL and this works great.  I have DNS name for the site which is not our CMS name.  I am able to use CMC and Infoview without any issues.  We are running BO Enterprise (Version 3.1 Hotfix 1.2).  We have developed a Das