cancel
Showing results for 
Search instead for 
Did you mean: 

Read file name from Payload (File Adapter)

Former Member
0 Kudos

Hello experts,

with Receiver-File Adapter I want to save a specific file. Name is given in the xml payload. I use Variable Substitution.

My structure is like this:


<root>
    <elements>
        <name>name1</name>
    </elements>
    <elements>
        <name>name2></name>
    </elements>
</root>

File name schema: %file%

Variable Substitution:

File Name: file

Reference: payload:root,1,elements,1,name,1

With this expression my file adapter creates two files (as recommended), but they have both the name "name1". I want to create n files with n different names, given by one xml structure. How can this task be done? Setting the occurency from "1" to "n" or "*" does not work.

Thank you very much!

Ilona Seifert

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

hi,

if you have XI SP14 don't use variable Substitution

use the method described in my weblog

(easier to use and allows better handling

you can concat two values for the filename etc):

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

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>

Former Member
0 Kudos

Hi,

thanks for your quick answer!

However, I have to use Variable Substitution. Any suggestions, how this can be done!

Kind Regards,

Ilona

Former Member
0 Kudos

Seifert,

If you want to use variable substitution go through the below weblog:

/people/sameer.shadab/blog/2005/09/23/an-interesting-usage-of-variable-substitution-in-xi

Just check this link out,

http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

---Satish

Former Member
0 Kudos

Hi Michal,

I tried out the Adapter specific message properties, but discovered the following error:

I created a user defined function and used it in mapping. What I should get is n different files, each one carrying the name I get from the mapped element. Actually I get only one file, carrying the name of the last element of my xml structure. Receiver adapter doesn´t create n files.

Do you have an idea?

Thank you very much!

Ilona

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

How are you creating N files?

1. You message mapping should create N target messages ( you should changed the occurence of the target message type to 0 to unbounded in messsage mapping).

2. The Interface mapping should also create N target messages ( you should have changed the occurence of the target message interface to 0 to unbounded in the interface mapping) .

3. In Interface determination, you selected the option extended / enhanced and then selected you interface mapping.

Have you done this?

Also, in your case Adapter specific identifiers will not work as you have only one mapping program and the filename will be the same for all files. use multimapping and variable name substitution and make sure that the filename is in the same element for every target message ( file ) and it will work fine.

Former Member
0 Kudos

Hi,

you are right, the error was in Multimapping! Now everything works fine! Thank you very much!

Ilona

Answers (2)

Answers (2)

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Like pointed by you , your source strucutre,

<root>
    <elements>
        <name>name1</name>
    </elements>
    <elements>
        <name>name2></name>
    </elements>
</root>

The target strucuture after mutlimapping will be like,

My structure is like this:

<root>
    <elements>
        <name>nameX</name>
    </elements>
   </root>

Now, using Variable Name substitution, you will have the "name " element at a fixed level always , <b> payload:root,1,elements,1,name,1</b> and so you Variable Name subsitution will also work fine.

Hope it clears,

Regards

Bhavesh

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Not sure I get the entire flow here. You are creating N files ( and so ) you will have N different Messages coming into your Receiver File adapter . So, if you want to use Dynamic File Name then make sure that the filename is in the same element in the same occurence in every file.

Can you maybe explain the requirements a bit further?

Regards

Bhavesh

Former Member
0 Kudos

Hello Bhavesh,

This is a test scenario, to discover the abilities of File Adapter.

I have one csv-file, having n lines. Each line is representing an independant record. Sender File Adapter transforms the csv file to the xml data structure I mentioned in the first posting. So I have n record sets in the xml, every new recordset is introduced with the name-tag. With Receiver File Adapter I want to split this xml file into n separate files, each one carrying the name <name>. I hope made my issue clear.

Kind Regards

Ilona