cancel
Showing results for 
Search instead for 
Did you mean: 

Varialbe Substitution in Multimapping

Former Member
0 Kudos

Hi,

We are trying to use variable substitution for generating multiple files at the target. Our XI Version is XI 3.0 SP 15.

My Source Structure is

P_MT_multimapping 1..1 -


>(MessageTypeName)

source 0..unbound

A 0..1

B 0..1

C 0..1

D 0..1

and

My Target Structure is

PMTmultimapping 0..unbound -


>(MessageTypeName)

Target 0..unbound

A 1..1

B 1..1

C 1..1

D 1..1

filename1 0..unbound

filename1 1..1

My Requirement is to generate a new file for each unique value of 'B' from the source and for a particualr file multiple records should be generated for each unique value of 'A' from the source. And target field 'filename1' should be incremented by 1 for each file. For example

My source payload is:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ns1:P_MT_multimapping xmlns:ns1="http://infosys.com/xi/projects/bp/n1">

<Source>

<A>1</A>

<B>KJ</B>

<C>1</C>

<D>1</D>

</Source>

<Source>

<A>1</A>

<B>KH</B>

<C>1</C>

<D>1</D>

</Source>

<Source>

<A>1</A>

<B>KK</B>

<C>1</C>

<D>1</D>

</Source>

<Source>

<A>1</A>

<B>KL</B>

<C>1</C>

<D>1</D>

</Source>

<Source>

<A>2</A>

<B>KL</B>

<C>1</C>

<D>1</D>

</Source>

<Source>

<A>2</A>

<B>KK</B>

<C>1</C>

<D>1</D>

</Source>

</ns1:P_MT_multimapping>

</ns0:Message1>

</ns0:Messages>

And generated target payload:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ns1:PMTmultimapping xmlns:ns1="http://infosys.com/xi/projects/bp/n1">

<Target>

<A>1</A>

<B>KH</B>

<C>1</C>

<D>1</D>

</Target>

<filename1>

<filename1>1</filename1>

</filename1>

</ns1:PMTmultimapping>

<ns1:PMTmultimapping xmlns:ns1="http://infosys.com/xi/projects/bp/n1">

<Target>

<A>1</A>

<B>KJ</B>

<C>1</C>

<D>1</D>

</Target>

<filename1>

<filename1>2</filename1>

</filename1>

</ns1:PMTmultimapping>

<ns1:PMTmultimapping xmlns:ns1="http://infosys.com/xi/projects/bp/n1">

<Target>

<A>1</A>

<B>KK</B>

<C>1</C>

<D>1</D>

</Target>

<Target>

<A>2</A>

<B>KK</B>

<C>1</C>

<D>1</D>

</Target>

<filename1>

<filename1>3</filename1>

</filename1>

</ns1:PMTmultimapping>

<ns1:PMTmultimapping xmlns:ns1="http://infosys.com/xi/projects/bp/n1">

<Target>

<A>1</A>

<B>KL</B>

<C>1</C>

<D>1</D>

</Target>

<Target>

<A>2</A>

<B>KL</B>

<C>1</C>

<D>1</D>

</Target>

<filename1>

<filename1>4</filename1>

</filename1>

</ns1:PMTmultimapping>

</ns0:Message1>

</ns0:Messages>

I want to pick the filename from field 'filename1'. I used only single communication channel

My channel has the following variable substitution

payload:PMTmultimapping,1,filename1,1,filename1,1

the value for filename1 is set to "var"

I use NFS and write the target file as : file%var%sant.xml

This creates only one file at the target directory with the file name 'file1sant.xml'.

but I want to generate multiple files for the above.

Any pointers on How to Fix this.

Regards,

Abhishek.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Abhishek:

After I read your post, you have a couple of requirments.

But I do not know which part you came cross problem.

On Mapping, or get the file name ?

Anyway, my thoughts:

On Mapping part:

req 1: generate a new file for each unique value of 'B' from the source :


  B->Removecontext->PMTmultimapping

req 2: for a particualr file multiple records should be generated for each unique value of 'A' from the source


  A->reomveContext->sort->SplitByValue[Value Change]->CollapsContext--> %YourMultipleRecords%

req 3: And target field 'filename1' should be incremented by 1 for each file

You can come up an UDF by using sample code below to get the file name from source side:


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

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

conf.put(key,fname);
return " ";


  Your file counter can be passed by using index standard function

Then you concate your filename and index to your final filename.

Regards.

Liang