Dynamic Filename from source IDOC payload

Hi,
I have a scenario IDOC --> ABAP Mapping --> Flat File.  I need to create the receiver file name dynamically with the document number from souce IDOC. Since the target payload is flat file I don't know whether I can use the variable substitution. Also can I use the dynamic configuration with ABAP Class mapping.
Please help.
Thanks.
Srini

Actually Henrique's reply in this thread has the exact code,
Re: Abap mapping and variable substitution in File adapter
METHOD if_mapping~execute.
DATA l_record type mpp_dynamic.
* copy payload
result = source.
* add an adapter specific attribute
l_record-namespace = 'http://sap.com/xi/XI/System/File'.
l_record-name = 'FileName'.
l_record-value = 'test.xml'.
dynamic_configuration->add_record( l_record ).
ENDMETHOD.
Regards
Bhavesh

Similar Messages

  • Dynamic Filename from source Idoc

    Hi All,
      I need to give the filename from the field in the source idoc. the field value need to be picked up as below
    ZSSV_GENERIC_IDOC
    -IDOC
    --Z1SSV_ITEMS_SUMMARY
    ---HOST_FILENAME
    Note: - represent the level in the datastructure.
    here the value of HOST_FILENAME need to be given as filename.  I check the Variable Substitution but I hope we can give only the values from message: and payload:
    Please let me know how to give this valueas filename.
    my filename need to be as
    HOST_FILENAMEmatmastimestap.dat
    Regards,
    Dhill

    Dhil,
    Check the below code if its feasible to you rather than going for variable substitution.
    input --->UDF -
    >Root node of  target.
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(
        "http://sap.com/xi/XI/System/File",
        "FileName");
    String fname =input+"MATMAS";
    conf.put(key,fname);
    return "";
    In receiver comm.channel check the checkbox for ASMA -Filename.
    Creation mode - AddTimestamp.
    Hope it helps!!!
    Best regards,
    raj.

  • File Receiver - Dynamically create filename from data in payload

    Hi there.
    Can anyone tell me the approach I need to take to be able to use the data in one field to determine the filename in the file receiver adaptor.
    I have a requirement that requires that I save a file with the following mask:
    xxxx_xxx<b><date extracted from field in payload></b>.csv
    I would appreciate any help on this.
    Thanks in advance.
    Mick.

    Hi Mick,
    you just need to use adapter specific parameters
    and you will be able to set the name in your mapping
    (from your payload)
    /people/william.li/blog/2006/04/18/dynamic-configuration-of-some-communication-channel-parameters-using-message-mapping
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Node function to use for relating two idoc segments from source in mesmapp

    Hi Sap All.
    here i have got a requirement to do a graphical mapping between Souce Idoc Structure to target file structure .
    here i have got  aspecific requirement from the Functional saying that they want
    for a segment from source idoc with name E1EDL24-NTGEW should be mapped with shipment_detail-nett_weight
    and the conditon here is There should be a corresponding entry in E1EDL24 for each E1EDL44?(other) segment type.
    can nay body help me in guiding  how and what node functions do i need to use here to ge the solution.
    regards.
    Varma

    Varma,
    If you could give a sample that would be great!
    raj.

  • Dynamic Filename in BPM process (SOAP with attachm. and PayloadSwapBean)

    Hello together
    I have the following BPM process:
    1. IDoc=>WebServiceRequest
    2. WebServiceResponse (payload) => IDoc
    3. WebServiceResponse (attachment) => File
    XI receivs an IDoc an map it to an WebService. The Webservice is called by XI and we receive the WebServiceResponse including a PDF attachment.
    The challenge is to store the PDF attachment with a dynamic filename from the payload of WebServiceResponse.
    We use the PayloadSwapBean to change the payload to the PDF attachment. But then we are not able to access the required information on the original WebService-XML-Response via variable substitution.
    Is there a solution in the standard or have we to use a custom adapter module?
    Thx
    manuku

    Hi Jayasimha,
    We can do this by "Adapter Specific Message Properties" of ur comunication channels.
    1.If u want to keep the output filename same as input filename, no need to use the UDF. only the 'adapter specific parameters' in both sender n receiver file adapter will do that.
    In case if u want to get the filename inside our mapping we have to create a user defined function
    which will return the filename and map it to one of our XML tags. 2nd point gives solution 4 that:
    2. If u want to generate an output file taking some input from the payload,then u hav to use the UDF.There u hav to populate the name.
    Pretty much.... if you set an attribute from the sender side, for example, you can use a UDF and access the particular attribute sent and use it in the mapping. In another example, where no attributes are sent from the sender, you can still actually set a particular attribute, say a filename derived from the payload, using a UDF, and enable the receiver attribute to use it. That's where the UDFs come in - either to get or set particular adapter specific message attributes.
    This will be a very helpful blog which solves ur query:
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    Regards,
    Vinod.

  • Dynamic Filename in File adapter

    Hi,
    I am doing idoc-file scenario.I get the filename as a field in one of the segments of my idoc.Can anyone please let me know how i can get the filename from my idoc and use this filename in my file adapter.
    --Thanks

    Hi all,
    Thanks a lot for your replies.
    Please find below the inbound message that i get. Now i need to get the filename that i get in one of the segments and use that in the file adapter.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ZSSV_GENERIC_IDOC>
    - <IDOC BEGIN="1">
    - <EDI_DC40 SEGMENT="1">
        <TABNAM>EDI_DC40</TABNAM>
        <MANDT>100</MANDT>
        <DOCNUM>0000000000203015</DOCNUM>
        <DOCREL>620</DOCREL>
        <STATUS>30</STATUS>
        <DIRECT>1</DIRECT>
        <OUTMOD>2</OUTMOD>
        <IDOCTYP>ZSSV_GENERIC_IDOC</IDOCTYP>
        <MESTYP>ZSSV_GENERIC_MSG</MESTYP>
        <SNDPOR>SAPYRA</SNDPOR>
        <SNDPRT>LS</SNDPRT>
        <SNDPRN>YRACLNT100</SNDPRN>
        <RCVPOR>YXDTEST_GI</RCVPOR>
        <RCVPRT>LS</RCVPRT>
        <RCVPRN>IDES_LS1</RCVPRN>
        <CREDAT>20060420</CREDAT>
        <CRETIM>184948</CRETIM>
        <SERIAL>20060420184948</SERIAL>
        </EDI_DC40>
    - <Z1SSV_ITEMS_SUMMARY SEGMENT="1">
        <IDOC_SEQ_NUM>1</IDOC_SEQ_NUM>
        <TOTAL_REC_COUNT>50</TOTAL_REC_COUNT>
        <IDOC_SEG_COUNT>50</IDOC_SEG_COUNT>
        <OUTPUT_REC_LENGTH>90</OUTPUT_REC_LENGTH>
       <INTERFACE_DESCRIPTOR>OUT_RYDER_0001</INTERFACE_DESCRIPTOR>
      <b><HOST_FILENAME>TEST1</HOST_FILENAME></b>
      <RECORD_DELIMITER>^</RECORD_DELIMITER>
      <SEGMENT_DELIMITER>|</SEGMENT_DELIMITER>
      </Z1SSV_ITEMS_SUMMARY>
    In the file adapter, I have specified "%filename%.xml" as my file name and in variable substitution the reference is  "payload:ZSSV_GENERIC_IDOC,1,IDOC,1,EDI_DC40,1,Z1SSV_ITEMS_SUMMARY,1,HOST_FILENAME,1".
    I still get the same error "Message processing failed: Error during variable substitution: "
    Waiting for your help in this matter.
    Regards,

  • Filename from payload - FTP receiver adapter

    Hello everyone!
    I have a scenario wherein I need to get the value from a field coming from an IDOC and then give that value as the "filename" of the file that is saved in the FTP folder.
    IDOC > XI > FILE
    For example, if /ORDERS05/IDOC/E1EDK02/BELNR = 620000123
    then I want the name of the file to be saved in the FTP folder to be 620000123.xml
    I understand you may use the 'variable substitution' property in the FTP receiver adapter, but subsequent attempts at trying to configure that property have resulted in errors. Can anyone help me out?
    Warm regards,
    Glenn

    do u have recordset name (root message)
    For Ex: If you want to refer to the field which is bold
    below is your variable substuition:
    payload:root,1,e1,1,e2,2
    <?xml version="1.0" encoding="UTF-8" ?>
    <root>
      <dummy>
         <e1>
            <e2>Data_1</e2>
            <f/>
           <g attr="abc">text</g>
            <e2>Data_2</e2>
         </e1>
      </dummy>
      <e1>
         <e2>illegal/value</e2>
         <f/>
         <g attr="abc">text</g>
         <e2 attr="fghij">Example Value</e2>
       </e1>
    </root>
    Similarly
    for your strucutre:
    <MS_MT>
    <order>
          <number>
    the variable substuition would be
    payload:MS_MT,1,order,1,number,1
    you have to give complete XML to arrive to this value.

  • Dynamic filename to payload

    Hi Guys,
    I have a file to IDoc scenario in which the Sender system places a file on FTP Directory at source side. PI picks up the file, generates a IDoc and take a "FileName" from the name of the source file.
    For example, If "Sender A" sends a file "20140404.TXT" then I have take the name like
    <IDOC>
    <filename>20140404.TXT </filename>
    </IDOC>
    It would be helpful if some helpful suggestions/approach can be provided for this scenario. Thanks, PM

    Hi Peter,
    you have to create udf for this.
    DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
    String name = conf1.get(key1);
    return name;
    in the sender file adapter check ASMA properties. and select File name.
    Regards,
    Muni.

  • Call ABAP program from Unix script passing dynamic filename

    Hi,
    Does anyone know if it is possible to call an ABAP program from a Unix script passing a dynamic filename to the ABAP program?
    We are receiving a file from an external company and on receipt of the file want to call an ABAP program passing the filename.  The filename is made up of File ID, Date and Time which we need to read in the ABAP program.  We usually use Events to trigger a program which is fine when the filename if static however since this filename will be dynamic we cannot do this.  In addition we cannot just rename the file to a static name in the Unix script as we need to know the value of the date and time from the file ID in the ABAP program.  I can change the ABAP program to check our /in directory for a Filename that starts with the fixed File ID however I thought there must be a better way of doing this.  We want the external company to put this information in a file header record but they don't want to change the file contents.  Any ideas would be appreciated.
    Thanks,
    Sinead.

    You could follow the following method
    1.Let the external file reside in the SAP application layer in a defined path e.g. /usr/sap/tmp/interface/working/
    2.Write an ABAP program which will include the following steps:-
       i) read all files in the file path using function module EPS_GET_DIRECTORY_LISTING
      ii) Read the data from files existing in the directory using OPEN_DATASET statement
    iii) After the files have been read move the files to another directory e.g. /usr/sap/tmp/interface/backup/ or you can delete the file.
    3.Schedule this program to be executed depending on the frequency of the external file being generated.

  • Idoc sending program from source port

    Hi Experts,
      I am sending the Idoc through customized program. I am getting the status 03 & 30. successfully sent to external system.
    Is there any standard program to send the Idoc from source port to destination port.
    Thanks and regards,
    Venkatraman.N

    Run RBDMOIND, then idoc will get the status 12 -Dispatch ok. status 12 is the confirmation that idoc was reached target system.
    Reddy

  • Dynamic FileName generation

    Hi,
    I have a source idoc xml file and the target structure has only 2 fields. Mapping contains only 2 fields which is used from the idoc and put to the fields in the target strucuture.
    After transformation, I need to create a file with the filename in the format <idoctype>_<idocnumber>.xml. And also the idocnumber will be of certain length like 15 digits. if the idoc number is 2343 then the file name should be <idoctype>_000000000002343.xml.
    If the value was to be picked in target payload then variable substitution would be the answer. But in this case it is from the source payload,
    Please guide me.
    Regards
    Shashi

    Hi
    refer this blogs..
    /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
    Might help you
    Thanks,
    vasanth.

  • ABAP mapping split messages and dynamic filename

    Hello,
    i have set up a IDOC to file scenario where the IDOC is split into several files, which works fine. In addition to this it is required to set a dynamic filename out of the ABAP mapping for each file. If only one file is created this works already as well but how do you set the dynamic configuration when the messages are split?
    Regards,
    Andreas
    Edited by: Andreas on Feb 26, 2009 9:09 AM

    you cannot do dynamic configuration for message splits. The below is from SAP help.
    Adapter-Specific Attributes and Multi-Mappings
    In multi-mappings, there are multiple message headers with adapter-specific attributes. The mapping API can only access one message header. This has the following consequences depending on whether there are multiple source or target messages:
    u25CF     1:n Transformation
    If there are multiple target messages, the header for the adapter-specific attributes is copied for each message. This means that you can only create one header for all adapter-specific attributes, and not individual headers.
    u25CF     n:1 Transformation
    This variant is only possible for multi-mappings in integration processes. If there is more than one source message, read-access to the adapter-specific attributes of the various message headers is not possible at runtime.
    u25CF     m:n Transformation
    All afore-mentioned restrictions apply here. Developers can at most write the same adapter-specific attributes for all target messages to the header, without read-access to the attributes of the source messages. m:n transformations are only supported within integration processes.
    What i will suggest is to use BPM to have the message split i.e 1:N mapping and then after that have another mapping 1-1 to have the dynamic configuration

  • Dynamic Filename in Fileadapter

    Hi all,
    I like to use the new feature (SP15) of the "Adapter Specific Message Properties" but with out success. I have read Michaels Blog "XI: The same filename from a sender to a receiver file adapter - SP14" but it give me not a clue how to use these properties during the normal receiver configuration and also the manual is not very clear about it. I have set a Variable with "FileName    message:FileName" (I have tried also "message:File_Name") Than I have used this filename Variable in the field "Filename Schema" like %FileName%. But I allways got this error: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: Unknown message header category 'FileName' for variable 'FileName'.
    What have I missed out here?
    Thankx
    Manfred Schmidt-Voigt

    Hi Manfred,
    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,
    Regards,
    Bhavesh

  • Dynamic filename in XI

    Hi,
    In XI SP12 is possible to use dynamic filename? I need to generate a filename in Adapter using the content of an element in message, how I do it?
    thanks.

    Hi Elton,
    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,
    Regards,
    Bhavesh

  • How to acces the filename from Message Header during variable substitution

    Hi,
    We need to access the attribute filename from Message Header during Variable Substitution.We are able to access the following attributes of Message Header
    sender_party, sender_service, receiver_party, receiver_service, interface_name, interface_namespace,
    message_id (message ID with hyphens, for example 9fbe1ff1-9a0d-11d9-8665-cbf10a126331)
    message_id_hex (message ID in hexadecimal format, for example 9fbe1ff19a0d11d98665cbf10a126331)
    For example, if we want to specify the interface name from the message header in the target directory or in the file name scheme, we enter message:interface_name as the reference.
    In the same way i need to access the filename which we get in the Message Header(which we get in the Message Header when we check the Adaptor specific message properties and filename in sender CC).Any suggestions on the same
    Thanks and Regards,
    Bhargav
    Message was edited by:
            bhargav gundabolu
    Message was edited by:
            bhargav gundabolu

    Hi Bhargav,
    Use this UDF to retreive the file name from the Dynamic Configuration Payload in the mapping.
    getFileName(UDF) -
    > Filename(node in the target structure).
    public String getFileName(Container container)
       //write your code here
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return  ourSourceFileName; 
    Create a node in the target structure top hold the filename returned by the UDF.
    Now your payload will have the filename along with the actual data.
    U can use the variable substution now as u use for the other data in the payload since the filename is now a part of your payload.
    Regards
    San

Maybe you are looking for

  • I can't see some collection attributes in the DSAME

    Hi, this is the problem: i want to edit some collection type attributes like channelsHasFrame, channelsRow, channelsColumn... in a Container with the DSAME but the attributes didn't appears, if I try to create them, the DSAME warn me that all ready e

  • Qosmio G20-127: Screen blackout after closing the lid on Vista

    Hi, I have Qosmio G20-127 and I've recently installed Vista Ultimate Edition (32-bit). I managed to bring everything to its place (except the magic buttons, but the drivers are not out yet), but I have a problem that is seriously making me reconsider

  • FP04 : Write off and debiting Tax accounts

    Dear All, I have an issue with debiting tax account on write off. Scenario: Invoice posted $1000 including tax of $100.  i.e $900 consumption (revenue) + $100 tax. GL Postings: Customer account 1000 Dr Revenue Account   900 Cr Sales tax              

  • J2iun- AED is flowing into ADC

    hi all, I have a scenario whre while executing j2iun, in the duties box that shows the duty liability, hte system is splitting AED (which is itself wrng as its no longer been used) amount into AED and ADC cond. i have checked the excise invoices, the

  • How to checkout from the batch script?

    Hello All ! Does anybody knows how to maintain versioned files with the batch scripts? Particularly I'm talking about doing a checkout/checkin operations. Are any command-line utilities available? Is it possible at all? Regards, Sergey.