cancel
Showing results for 
Search instead for 
Did you mean: 

Naming text file dynamically with multiple files being generated

RafaelVieira
Active Participant
0 Kudos

Hi all,

I'm developing an interface where a single source structure generates multiple message types and, each of the message types generates a text file in the target FTP directory. Before defining the 1:N cardinality, the interface was operating as 1:1, therefore generating only 1 text file in the FTP.

With 1 file being generated in the FTP, I was naming the text file dynamically through the following UDF:

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

conf.put(key,[parameter]);

The above mentioned UDF was being mapped to the Message Type target node.

Now, my question is, I have multiple MT being generated on target side. How can I do to keep generating multiple files and naming them dynamically?

Tks,

Rafael.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Multimapping does not support DC..u have to use variable substitution.

However, below blogs talks abt the multimapping using adapter module...u can chk the same (personally i would have opted for Variable Substitution):

http://scn.sap.com/people/praveen.gujjeti/blog/2011/03/29/multi-mapping-assigning-asmas-for-child-me...

Thanks

Amit Srivastava

RafaelVieira
Active Participant
0 Kudos

Using ASMA + UDF is not mandatory in my interface. So how can I achieve it by using variable substitution?

Say that I could create an additional field in the target field specific for file naming purposes and always use the variable subst.

I'm just not totally sure how to define it in the adapter, Advanced tab.

Target structure sample:

<Messages>

     <Message1>

          <MT_File>

               <fieldA>1</fieldA>

               <fieldB>1</fieldB>

               <fieldC>name11</fieldC>

          </MT_File>

          <MT_File>

               <fieldA>2</fieldA>

               <fieldB>2</fieldB>

               <fieldC>name22</fieldC>

          </MT_File>

     </Message1>

</Messages>

Is it enough if I use Variable Name = %file_name% and reference payload:Messages,1,Message1,1,MT_File,1,fieldC,1

??


Will the configuration assume that each MT has to generate a different file with name corresponding to fieldC field from target structure and indeed generate 2 files with dynamic name?

Tks.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi All,

can any one tell if we can use Variable substitution with File content conversion in  SAP SFTP adapter. It is working fine with File Adapter but throwing error for SFTP.

Regards,

Vinod Mishra

zameerf
Contributor
0 Kudos

You can check the below wiki as well which explains the exact requirement as yours using Variable Substitution and a single file channel.

http://wiki.sdn.sap.com/wiki/display/NWTech/One+IDOC+to+Multiple+Files+sending+to+Multiple+folders+o...

RafaelVieira
Active Participant
0 Kudos

It's working.

Just by maintaining the variable substitution and defining the multi-mapping structures the output files get generated each with the corresponding value gotten from target structure.

Tks.

Rafael Vieira.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

In addition to Praveen's reply, if you need screenshot for the variable substitution against payload structure, You can view this link

http://www.saptechnical.com/Tutorials/XI/Variable/substitution.htm

Ryan-Crosby
Active Contributor
0 Kudos

Hi Rafael,

Are the target messages all the same?  Also, is the number of target files fixed or dynamic?

Regards,

Ryan Crosby

RafaelVieira
Active Participant
0 Kudos

Yes, the structure of target files are always the same.

And no, source message might send 2 documents, so we would have 2 output files, or source message could send 10 documents so we would see 10 files being generated. Each of the files with its corresponding name based on a field from target structure.

former_member181985
Active Contributor
0 Kudos

You should use the normal one for Variable substitution: payload:MT_File,1,fieldC,1

Reason: The message will be according to orginal target schema once splitting happens at Adapter engine level

This message is in reply to "Rafael Da Silva"

Message was edited by: Praveen Gujjeti This message is in reply to "Rafael Da Silva"

Ryan-Crosby
Active Contributor
0 Kudos

Ok,

The thing I was thinking about wouldn't work for your scenario then... I think you'd have to go with the variable substitution approach then.

Regards,

Ryan Crosby

rajasekhar_reddy14
Active Contributor
0 Kudos

As Amit already mentioned Dyncamic configuration wont work with Multi mapping.

How you are genarating mutiple files?using multi mapping?

RafaelVieira
Active Participant
0 Kudos

As per his answer "Multimapping does not support DC..u have to use variable substitution."

What I just said is that I'm using variable substitution.

Now, please read my previous message again to see the questions I have.

Multi mapping to generate multiple files - yes.

1 source structure generates N target structures (just like the MT target structure in my previous post).

Tks.