Get/put dynamic file name using FTP

Hi Friends,
  I am currently using FTP_Connect, FTP_command and FTP_disconnect to get/put a file from a remote server.
But the file name was changed to add a date/time stamp.
So the filename became dynamic (example from 'test.txt' to 'test_200512160800.txt').
I tried using get test. but my FTP command failed. Do you know anyway of doing this?
Thanks.

Hi Lego,
here's another sample for the fm:
REPORT ztest_epsf.
PARAMETERS: date LIKE sy-datum,
            dir  TYPE epsf-epsdirnam,
            pattern TYPE epsf-epsfilnam,
            zid   LIKE vers_dest-rfcdest.
DATA dir_list LIKE epsfili OCCURS 0 WITH HEADER LINE.
DATA cnt_file TYPE epsf-epsfilsiz.
DATA err_file TYPE epsf-epsfilsiz.
START-OF-SELECTION.
  IF date IS INITIAL.
    date = sy-datum.
  ENDIF.
*build pattern with input-pattern and date
  CONCATENATE pattern date '*' INTO pattern.
*search for files in foreign system
  CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
       DESTINATION                   zid
       EXPORTING
            dir_name               = dir
            file_mask              = pattern
       IMPORTING
            file_counter           = cnt_file
            error_counter          = err_file
       TABLES
            dir_list               = dir_list
       EXCEPTIONS
            invalid_eps_subdir     = 1
            sapgparam_failed       = 2
            build_directory_failed = 3
            no_authorization       = 4
            read_directory_failed  = 5
            too_many_read_errors   = 6
            empty_directory_list   = 7
            OTHERS                 = 8.
  WRITE: / pattern.
  ULINE.
  LOOP AT dir_list.
    WRITE: / dir_list-name.
  ENDLOOP.
  ULINE.
  WRITE: / cnt_file.
  WRITE: / err_file.
pls reward points for useful hints.
thanks and
regards Andreas

Similar Messages

  • Dynamic file name using FTP adapter

    I was trying the dynamic filename scenario taking help from Michal's blog https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2664. [original link is broken] [original link is broken] [original link is broken] [original link is broken]
    If I check the 'adapter specific properties' in both sender and receiver file adapter,then in output I am getting the output filename as same as input filename without using the UDF.
    When I used the UDF in mapping,it had absolutely no effect. I am not clear what is the use of the UDF. please let me know where to use the UDF and how to use it.
    Thanks
    Smith

    1. In the mapping program that you are using populate the filename coming from the source into the target in any of the fileds.
    2.Sender adapters can write adapter-specific attributes to the message header; these can then be evaluated at configuration time.You can get dynamic filename in UDF in msg mapping....just in ID in comm channel select adapter specific attributes -> filename.....then whatever dynamic name you will create in UDF will be the target filename.....
    3. To change the adapter-specific attributes of the message header by using message mappings, you access the <b>required classes of the mapping API by using a mapping runtime constant.</b>
    To access the classes DynamicConfiguration and DynamicConfigurationKey by using the mapping runtime constant DYNAMIC_CONFIGURATION, use the method getTransformationParameters() of the container object.
    You donot need to hard code the value of the filename in the file adapter for your interface.
    In SXMB_MONI, when you see the pipeline services you would see that the value of the filename is populated in the message payload.

  • Dynamic File name in FTP Communication Channel

    Hi All,
    We have requirement where ,we create a filenames dynamically ( runtime).These filenames whihc do change for every execution needs to be added in FTP communication channel.
    1. How can we add the this generated file name in FTP CC Communication Channel.
    2. Does this file needs to part of target structure during graphical mapping ?
    3. Can we also dynamically append the Directory name to file names aswell ?
    Please provide your valuable sugestions.
    Thanks for your support.

    1. How can we add the this generated file name in FTP CC Communication Channel.
    3. Can we also dynamically append the Directory name to file names aswell ?
    to get the FileName:
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    To get the Directory:
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
    Then append:
    key+key1
    And then in the CC select the Directory checkbox under the ASMA properties...
    2. Does this file needs to part of target structure during graphical mapping ?
    The file which is sent using the CC will have the FileName as configured in the UDF of the graphical mapping....and if i am not wrong then the target structure resembles the file (if there is no FCC done)....
    Regards,
    Abhishek.

  • Sequence number/counter in File name using FTP

    Hi
    I have to add sequence number in the file name. How can i do that? everytime file generates it should pick up the latest file number.
    Example File1 File2 File3. 1,2 and 3 are the sequnce number.
    Regards

    Hi ria,
             You can do this by dynamic file creation. Use this following code and cretate an UDF. The map the required file format to the target header structure as below;
    UDF
    sequence number:
    IDENTIFIER is the parameter
    Import com.bp.xi.util.*;
    Code:
    return ServiceUtil.getSequenceValue( IDENTIFIER, container, false );
    Dynamic file:
    Key & Value is the parameter
    Code:
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get( StreamTransformationConstants.DYNAMIC_CONFIGURATION );
    DynamicConfigurationKey confkey = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File",  Key );
    conf.put( confkey, Value );
    return "";     
    Input parameter "Key" is given a constant value"FileName"
    Second parameter "Value" is the file pattern
    Mapping
    Constant(File)concat function sequence numberUDF ==> Dynami File udf ==>target header record.
    In the receiver communication channel check the adapter specific function, filename
    points if useful
    regards,
    Murugavel

  • How to get the incoming file name using JMS adapter and SOAP adapter

    Hi Everybody,
       In one of my interface i need to get the file name of incoming flat file using JMS adapter at sender side. and then i am using xslt to convert it to IDOC and then posting to  SAP IDOC.
    my incoming filname are in this form price<DateTimestamp>.txt. when i do the tranformation this incoming file name should be part of one element in the IDOC which i am posting.
    EX:
    <IDOC
    <REF>price<DateTimestamp>.txt</REF>
    </IDOC>
    Hope it is clear to everybody. I need your suggestion how i can capture this incoming file name and send it as part of IDOC.
    Thanks
    raj

    If they are passing it in message id or correlation id,
    you can access it using
    <xsl:variable name="dynamic-conf" 
            select="map:get($inputparam, 'DynamicConfiguration')" />
        <xsl:variable name="dynamic-key"  
            select="key:create('http://sap.com/xi/XI/System/JMS', 'DCJMSMessageID/ DCJMSCorrelationID')" />
        <xsl:variable name="dynamic-value"
            select="dyn:get($dynamic-conf, $dynamic-key)" />
    Check this:
    http://help.sap.com/saphelp_nw70/helpdata/en/f4/2d6189f0e27a4894ad517961762db7/content.htm
    Thanks,
    Beena.

  • Problems getting just the file name using an upload component

    Hi everyone, I'm using an upload component on my page and I need to get just the name of the image/file in order to store it in a database, I used the code of the tutorial and It works fine on mozilla but the problem comes when I use Internet Explorer because I get the whole path of the image/file and not just the name of it. I believe the browser is the cause of the problem, I already checked the http://jakarta.apache.org/commons/fileupload/, but I don't understand how to use anything, and not even the code of the tutorial works eventhough it is specified in comments:
    // some browsers return complete path name, some don't
       // make sure we only have the file name
       String justFileName = uploadedFileName.substring
          ( uploadedFileName.lastIndexOf(File.separatorChar) + 1 );If anybody could helpme solve this problem I'd appreciate it so much
    Regards
    Yes
    Message was edited by:
    Yesenia

    Let's walk through the code...
    File.separatorChar is the system-dependent default hame-separator charac tor. This field is initialized to contain the first character of the system property file.separator. On UNIX systems, the value of this field is '/'; on Microsoft Windows systems it is '\\'.
    String justFileName =
    // get the substring of uploadedFileName
    // that starts after the last separator (\ or /)
    uploadedFileName.substring
    uploadedFileName.lastIndexOf(File.separatorChar) + 1
    You say that this statement is returning the complete path name, for example:
    C:\Documents and Settings\All
    Users\Documentos\Mis im��genes\Im��genes de
    muestra\Puesta de sol.jpgSo, we can make an assumption that the File.separatorChar must not be \, or else the statement would return Puesta de sol.jpg.
    We know that it works for you on Solaris/Mozilla.
    We also know that Misha has tested the statement in IE and it works for him.
    (And I know that this tutorial was tested by a software engineer and a quality engineer, and it worked for both of them, as well as the tutorial author and a peer).
    So, what is different here??????
    Can you print out File.separatorChar and see if it is '\\' (I think the first \ is an escape char, that is \\ (escape-escape) is the equivalent of \ (backslash)) or '\'?
    When you run it on another machine, how are you deploying it on the other machine? Is it deployed to Solaris and running on Windows?
    Have you tested to see if it works on a Windows machine using Mozilla?
    Thanks in advance for any light you can shed on the problem.

  • Dynamic file name using reciver file adpater if no Mapping  involved

    Hi XI/PI experts,
    I am working on one scenerion where I have to poll the files from one server and send them to target FTP server with no content conversion( no Mapping involved).
    for example:
    if the source file is ABC_Invoice_item.csv
    then the target file is expected as  invoice_YYYYMMDD.csv
    Please advise how we can acchive this?
    Many Thanks in advance for your valuable inputs.
    Cheers,
    Mohan

    Hi,
          You can refer the following link for selecting additional files using a single comm channel :
    http://help.sap.com/saphelp_nwpi71/helpdata/EN/44/692ab8a4b633eae10000000a1553f6/content.htm
    You can also use a Java mapping instead of adapter module to store the filename dynamically in the message header. In this case, use a data type that has just one field under it. Use the same data type for both sender and receiver.
    In your Java mapping, use the code for dynamic configuration to retrieve the sender filename, alter it and then store it in the message header again for use by the receiver adapter.
    No changes will be required in the sender comm channel. There will not be any conversion to xml format and the data will pass through as is.
    Regards

  • How to give a dynamic File Name for Receiver File/FTP Adapter.

    Hi Experts,
        I have one scenario in which we are creating a flat file of IDOC which is coming from R/3 & sending it to FTP location. For this we have configured Receiver FTP adapter with File Name Scheme as "NT.out"  & in File Consturction mode i have given as "Add Time Stamp".
        therfore while creating a file it is creating as NTyyyyMMdd-HHmmss-SSS.out
    where as my requirement is only to to add Time & not the Date. (NThhmmss.out)
        How to do this ?
        for your info we are using ABAP Mapping.
        Pl help me
    Regards,
    Umesh

    Hi Umesh,
          Add one more field to your target structure for your file name and populate that field as per your requirement like NTyyyyMMdd.out. In receiver communication channel use Variable subtiution option and give the refrence of Payload and file construction mode set as create.
    And refer the below weblogs for Variable Subtiutuion File Name Scheme
    /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i - Dynamic File Name Part 1
    /people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii - Dynamic File Name Part 2
    Hope this way would be solve u r problem.
    Cheers
    Veera
    >>>Reward points, if it is needful

  • Dynamic File Name - UDF

    Hi Master,
    I written the UDF for Getting the Dynamic File name.
    DynamicConfiguration conf = (DynamicConfiguration) container.getParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    // Retrieve the filename
    String FileName = conf.get(key);
    This is working ok - but I want to return these values so I can be used in mapping.
    when I try to add the statement return FileName; , the compiler then complains with the following error:
    cannot return a value from method whose result type is void return FileName;
    Please help me,
    Thanks,
    Anu

    Thanks Nithiyanandam,
    I am using the Same code. But i am getting the Syntax error:
    Source code has syntax error:  E:/usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapaf708c00d6bb11dd83ee00101816a382/source/com/sap/xi/tf/_MM_I_FF_O_RFC_.java:13: cannot resolve symbol symbol : class variable location: class com.sap.xi.tf._MM_I_FF_O_RFC_ variable a; ^ 1 error
    UDF Name: FileName
    while creating the UDF, I select the first radio button(Value). not  Context and Queue.
    I written the below code.
    DynamicConfiguration conf = (DynamicConfiguration) container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(
        "http://sap.com/xi/XI/System/File",
        "FileName");
    String FileName = conf.put(key, a);
    return FileName;
    Thanks,
    ANU

  • Xml file in dynamic file name in file receiver adapter

    Hi,
    I'm doing the dynamic file name in file receiver adapter. I have done as per instructed in /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i
    All turned out okay. I have got the file name I require. Except that the file format is XML and I need to suppress the filename node occupied by the dynamic file name.
    The content conversion mentioned in /people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12, does not seem to solve my problem. As it is only for file format other than the XML one, because we only do the content conversion if we want to "convert" the format of the content from XML to the other format.
    Does anybody have the solution to my problem? thanks in advance

    Thank you Raj for the direction
    The way to do it is :
    1. In ID, advanced tab, put a check on the adapter-specific message attributes - file name.
    2. Put a "*" on the file name scheme
    3. In IR, create a UDF to set up target file name :
    DynamicConfiguration conf = (DynamicConfiguration) container
    .getTransformationParameters()
    .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    // set up file name for receiver adapter
    String SourceFileName = conf.get(key);
    conf.put(key, TargetFileName);
    return " ";
    4. Map the above UDF to the header level of the target structure.
    Regards,
    Idi

  • Dynamic file name from messsage payload

    Hi Friends,
    My requirement is to read one .xml file , which has  Purchase Order deatails and place .html file on receiver side, we are using XSLT for mapping.
    The file name should be "POnumber.html " , i've gone through below but couldn't get much
    http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
    Can any one send the that code , and steps to add that code in side XSLT.
    Thanks
    John

    Hi,
    With above links
    /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i - Dynamic File Name Part 1
    /people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii - Dynamic File Name Part 2
    See in the below Michal blog , how to conver the file as html , take that part only.
    /people/michal.krawczyk2/blog/2005/11/23/xi-html-e-mails-from-the-receiver-mail-adapter
    Regards
    Chilla

  • Dynamic file name in communication channel

    hello
    is it possible to give in the communication channel, under the 'File Access Parameters', a dynamic file name?
    to get it out of a table or something?
    Thanks
    Kfir

    Hi,
    Yes its bit possible to use the dynamic file name at File access paramters
    The dynamic filename generation concept is as follows.
    In your filename field. just give a variable with % symbols. (eg: %file% ).
    Now, under the option Variable Name Substitution, you can give how the value has to be created.
    It can be your interface name, sender service name, etc or it can be some value dynamically from your payload.
    For the former, your give
    message:interface_name ,etc
    and for the payload part you give,
    Payload: "your element root which u wanna acecss"
    Just check this link out,
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    And read the contents under variable substitution and it will help you understand the concepts better.
    If you have any clarifications, do get back,
    Refer below links for more in depth details about it
    Re: Dynamic file name in Receiver File Adapter
    http://help.sap.com/saphelp_nw2004s/helpdata/en/21/6faf35c2d74295a3cb97f6f3ccf43c/frameset.htm
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    /people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14
    /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i
    /people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii
    /people/michal.krawczyk2/blog/2006/02/23/xi-dynamic-name-in-the-mail-attachment--pseudo-variable-substitution
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    Check out this URL
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    Check these weblogs as well...
    /people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12
    /people/sameer.shadab/blog/2005/09/23/an-interesting-usage-of-variable-substitution-in-xi
    Thanks
    Swarup

  • Mail Receiver adapter - dynamic file name without mail package

    I know that we can get the dynamic attachment name using mail package... As per the FAQ Mail adapter, the Mail package use is deprecated and hence we do not want to go that route.
    I have seen the following wiki entry for setting the file attachment name...
    http://wiki.sdn.sap.com/wiki/display/XI/Adapter%20Module%20PI%207.0%20Set%20Attachment%20Name?bc=true
    Is this the only approach to dynamic attachment name using Mail adapter (and without Mail package). Or a different approach without Adapter module is possible?

    There is a different approach without using mail package or adapter module.
    Have a look at this Wiki:
    http://wiki.sdn.sap.com/wiki/display/ESOAInfrastructure/Dynamic+Email+Attachment+name+for+Received+Mails+with+ASMA+and+without+using+mail+package

  • Dynamic file name while sending to target FTP

    Hi Experts,
    we have a scenario wherein we are trying to implement dynamic file names.
    The scenario is IDOC to file, and  we need to append the data corresponding to all the IDOC triggered n a daily basis.
    Its like  the file abc_01will contain data for day 1(data of oll the IDOC in that day).For day to we need to dynamically name the file as abc_02 and so on.
    But before naming the file as abc_02 we need to check if abc01 is present or not .If abc_01 is not present then for day 2 file  we need to give the name as abc_01 and so on_.This condition is need to be checked becasue there may be the case that a file may not be picked by the script running  at the target system.
    can anyone let me know how to check whether file are correctly picked at target.
    Regards,
    srinivas.

    Hi  Srinivas,
    I think you can achieve this with the next scenario:
    - For getting all the Idocs info, you need a ccBPM to collect them, and then, download them to a file.
    - To dynamically put the filename, you need to use Dynamic Configuration at the File Receiver Adapter (in the Message Mapping, you can write a UDF.)
    - And to check if the daily file exists, you can also write an UDF and then decide the name of the output file.
    Hope this helps,
    Regards,
    Juan

  • How to find the File name using the FTP Adapter

    hi all,
    how to find the File name using the FTP Adapter with BPEL.
    Regards

    Found the solution for this.
    First In the mediator's routing rule use assign property $in.property.jca.file.FileName to $out.property.jca.file.FileName
    In the BPEL's receive activity go to the properties tab and get the property to a BPEL variable. That should do it.
    Thanks for the posts

Maybe you are looking for