cancel
Showing results for 
Search instead for 
Did you mean: 

Need Mapping Help: Generate index if value comes

Former Member
0 Kudos

Hi Experts,

I need mapping help to generate index if value comes form source. we have 4 fields in item level of source and target side we have to pass the these filed values and sequence number.

below given the structures:

Source:              Target:

Item                    Item

   A1                      Text

    A2                      Seq_No

    A3

    A4

my requirement is if A1 filed values comes from source we should pass to text and pass seq_no to constant-1, same as A2,A3 and A4 filed values also we should pass to text and seq_no for A2 is 2 and A3 is 3 and A4 is 4. suppose if A1 value is not coming from source we should pass seq_no for A2 is 1. if A1 and A3 filed values are not coming from source then we should pass seq_no for A2 and A3 are 1 and 2.

can you please help me how to achieve this. appreciate for your support.

Regards,

Sanjay.

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi Sanjay,

Have you  tried the statistic function index?

Check Stefan Grube's blog http://scn.sap.com/people/stefan.grube/blog/2005/12/29/new-functions-in-the-graphical-mapping-tool-x...

Regards.

Former Member
0 Kudos

Hi,

Thanks for prompt reply, in my case i just want to map single item to multiple items.

please find the below

Source:              Target:

Item                    Item

   A1                      Text

    A2                      Seq_No

    A3                     Item

    A4                         Text

                          Seq_no

                       Item

                          Text

                          Seq_no

                       Item

                         Text

                         Seq_no

if i am using the index it should be increased when the items are multiple. i don't want to increase number. seq_no should be always 1,2,3,4. if the one filed value is not coming the seq_no should be  1,2,3.

Regards,

Sanjay.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Sanjay,

                  you can  try this mapping

1. Generate the target 4  ITEM's  by duplicating the subtree as shown below 3 times.

Now create the each target item starting from first by mapping them to A1,A2,A3 and A4 respectively. I have shown the first ITEM mapping above. similarly you can map A2 to ITEM[1],

A3 to ITEM[2] and A4 to ITEM[3].

2. Now you can map the A* fields to Text one to one as shown below

Please repeat the same for A2,A3 and A4 to respective Text fields.

3. 

First seq_no field as shown

and similarly others as shown

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

Thank you so much, its working fine now.

Regards,

Sanjay.

former_member184681
Active Contributor
0 Kudos

Smart thing with count and add, I did not think to use those

anupam_ghosh2
Active Contributor
0 Kudos

Thanks Greg. I am glad to know you liked the mapping.

Regards

Anupam

Answers (1)

Answers (1)

former_member184681
Active Contributor
0 Kudos

Hi Sanjay,

I think the simplest solution is to create a UDFs or use Java mapping to handle the entire logic. If you use UDFs, they could look like that:

1. UDF for "Item" node:

if (inA1 != null) result.addValue(""); else result.addValue(ResultList.SUPPRESS);

if (inA2 != null) result.addValue(""); else result.addValue(ResultList.SUPPRESS);

if (inA3 != null) result.addValue(""); else result.addValue(ResultList.SUPPRESS);

if (inA4 != null) result.addValue(""); else result.addValue(ResultList.SUPPRESS);

2. UDF for "Text" field:

result.addValue(inA1);

result.addValue(inA2);

result.addValue(inA3);

result.addValue(inA4);

3. UDF for "Seq_No" field:

int counter = 1;

if (inA1 != null) { result.addValue(counter); counter++; } else result.addValue("");

if (inA2 != null) { result.addValue(counter); counter++; } else result.addValue("");

if (inA3 != null) { result.addValue(counter); counter++; } else result.addValue("");

if (inA4 != null) { result.addValue(counter); counter++; } else result.addValue("");

Regards,

Greg