cancel
Showing results for 
Search instead for 
Did you mean: 

Context Function : copyValue() USE

Former Member
0 Kudos

Hi

I have to use the context function in my scenario but before that I was trying the functions with different data values & conditions. Now when I am using <b>copyValue</b> using same example given in <a href="http://help.sap.com/saphelp_nw04/helpdata/en/26/d22366565be0449d7b3cc26b1bab10/content.htm">copyValue Help document</a> with source structure as

<i>partner 0 to Unbounded

Name 1 to 1

addDat 3 to 3</i>

& Target Structure as

<i>Customer 0 to Unbounded

Name 1 to 1

City 1 to 1 =CopyValue([nnumber=0]addData)

Street 1 to 1 =CopyValue([nnumber=1]addData)

Zip 1 to 1 =CopyValue([nnumber=2]addData)</i>

Now when I am sending single record, I am getting the desired results but when I am sending 2 records the value of city, street & zip are of the first record. E.g

<b><Partner>

<Name>lalit</Name>

<addData>Noida</addData>

<addData>Raj Road</addData>

<addData>201001</addData>

</Partner>

<Partner>

<Name>lalit1234</Name>

<addData>Noida123</addData>

<addData>Raj Road678</addData>

<addData>20100190</addData>

</Partner>

<Customer><Name>lalit</Name><City>Noida</City><Street>Raj Road</Street><Zip>201001</Zip></Customer><Customer><Name>lalit1234</Name><City>Noida</City><Street>Raj Road</Street><Zip>201001</Zip></Customer></b>

Also when I am giving only one value of addData in Source the same value is getting copied in city, street & zip, it should give the exception over here.

Pls. suggest that these are the limitations of copyValue function or I am doing something wrong.

I am testing my mapping in Integration Builder only.

Regards

- Lalit -

Accepted Solutions (0)

Answers (2)

Answers (2)

STALANKI
Active Contributor
0 Kudos

Read this articles..this will help u in message mapping to a greater extent../people/sravya.talanki2/blog/2005/08/16/message-mapping-simplified--part-i

/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii

Former Member
0 Kudos

Hi,

CopyValue() function is used to copy the value of a tag to n number of occurances of the tags in the target.

The mapping in your case, is behaving normally.

If you want the values of the target to be different depending on the sourcevalue, then do a direct mapping.

<Partner>

<Name>lalit</Name>

<addData>Noida</addData>

<addData>Raj Road</addData>

<addData>201001</addData>

</Partner>

<Partner>

<Name>lalit1234</Name>

<addData>Noida123</addData>

<addData>Raj Road678</addData>

<addData>20100190</addData>

</Partner>

If you want the both the values of the partner tags to occur, then do the mapping without a copyValue function.

Regards,

Smitha.

Former Member
0 Kudos

Smitha

I tried that but if you will do the Direct Mapping of addData with 3 fields of target message it will copy the value of first occurance of addData in all 3 fields.

For e.g

<addData>Noida</addData>

<addData>Raj Road</addData>

<addData>201001</addData>

Results in

<City>Noida</City><Street>Noida</Street><Zip>Noida</Zip>

Is this applicable with copyValue() -->

CopyValue() function is used to copy the value of a tag <i>whose context is occuring multiple times</i> to n number of occurances of the tags in the target.

- lalit -

Former Member
0 Kudos

Hi,

>><i>CopyValue() function is used to copy the value of a tag whose context is occuring multiple times to n number of occurances of the tags in the target.</i>

Yes. CopyValue is used when there are multiple occurances of a field in the source, and we need to map only the value of the first occurance of this field to the target.

Since you have used this function between the source addData and the target tags city, state and zip, the value of the tags will be filled with the value of the addData field.

If there are multiple occurances of target tags(city,state,zip)and only one occurance of the addData in the source, the same value will be copied to the targets occuring multiple times.

If there are multiple addData(source)tags, correspondingly, the targets will have different values.

Regards,

Smitha.

Former Member
0 Kudos

Smitha

>><i>If there are multiple addData(source)tags, correspondingly, the targets will have different values.</i>

This is what is not happening, when I am using multiple addData tags, the targets tags are not having the different values but the values of the first record of addData tags.

Can anyone try this & verify. I just want to clear this & would like to explore the complete functionalities of Context functions.

Thanks

- Lalit -

stefan_grube
Active Contributor
0 Kudos

Hi Lalit,

copyValue() considers only values from the first context. All other contexts are ignored.

To achieve your requested mapping, you need a more complex construct like

addData - index 
                 equalS 
    constant(1) /        ifWithoutElse - City
                addData /

index comes with SP13, in lower SP levels you need a UDF.

Regards

Stefan

Former Member
0 Kudos

Hi,

I tried this out now.

In your example you have <b>addData</b>tags with occurance 3... that means, at any time, there must be 3 source addData tags.

For a copy value function, we do the following

<addData> > copyValue() (position 0)> <city>

<addData> > copyValue() (position 1)> <street>

<addData> > copyValue() (position 2)> <zip>

The <b>position</b>value specifies the occurance of the addData field.

i.e, the first occurance(position 0) of addData field contains the value for <city>

The second occurance of addData contains value for <street> and similarly for zip.

Hope this helps

Regards,

Smitha.