cancel
Showing results for 
Search instead for 
Did you mean: 

CPI Mapping - Dynamic Target Mapping ?

0 Kudos

Hello Team,

We are integrating S4H on Prem and C4C System using CPI.

There has been an upgrade in an interface from C4C end and so certain fields are added and require to be mapped.
I have tried many steps but it isn't working and CPI's mapping simulation is pretty basic.

Can you guys suggest me a solution on this. Tried many workarounds. Still didnt get the desired result. My requirement is this:

Based on FIeld 1's value. I want to map to different targets.

If Field1 is lets say A. Field 2 should be mapped to ParentA_2
if Field1 is B. FIeld2 should be mapped to ParentA_3.

Since the context of Field2 and ParentA_2/3 are different. I want Field2 to map ParentA_2/3 atleast once.

Eg. Field1's queue

C
D
A
F
B

For the third n fifth occurrence I want Field 2 to be mapped to ParentA_2 and ParentA_3.

Attaching sample input and output file.
Any assistance would be greatly helpful.

Regards,
Abraham.
input-copy.txt

output-copy.txt

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi Morten,

I removed all the mappings and used only graphical mapping to connect PartyRoleCode to SalesMan to check my theory.

Turns out only first value in the queue is getting assigned. After the first value in the queue getting assigned to SalesMan it doesn't get called again to assign second value to Salesman.

Regards,

Abraham.

MortenWittrock
Active Contributor
0 Kudos

Hi Abraham

Do you mean that the SalesSupervisor and SalesMan elements can occur multiple times? If so, that's not really clear at all from your descriptions.

Also, please note that you are answering your own question right now, rather than commenting on my answer.

Regards,

Morten

MortenWittrock
Active Contributor
0 Kudos

Hi Abraham

I'm not entirely sure about the cardinalities of your elements (but describing mappings precisely in a human-readable format is very hard!).

If you could post an example input document and its corresponding output document, that would help a lot. But please keep them as small as you can!

Generally speaking, you should probably consider which mapping tool you choose to solve this. Using XSLT, this is not a hard problem at all. But if you don't know XSLT, it does have quite a learning curve.

I recently wrote a blog post about Cloud Integration's mapping tools. That will give you an overview of what you have available, and when to use each tool.

Regards,

Morten

0 Kudos

Hi Morten,

Thanks for the suggestion and I did look into your blog before posting my question. As we are nearing deadline. I'm obliged to complete soon. Hence the rush.

As you suggested I have updated my question with attachments which provides more clarity.

As always, appreciate the help from community.

Regards,

Abraham.

MortenWittrock
Active Contributor
0 Kudos

Hello again

The issue is still not completely clear to me. Is this specifically about the values of the SalesSupervisor and SalesMan elements in the target structure, and only those two elements?

Regards,

Morten

0 Kudos

Yes only those two elements .Whenever PartyRoleCode comes as ZS it should be assigned to SalesSupervisor and likewise when ZE comes it should be assigned to Salesman.

Regards,

Abraham.

MortenWittrock
Active Contributor
0 Kudos

Right, okay. This you can actually achieve fairly easily in message mapping. I would do it in a custom function. Here's my code:

import com.sap.it.api.mapping.*

def void filterRoles(String[] partyRoleCode, String[] partyInternalId, String[] roleToFind, Output output, MappingContext context) {
    def index = Arrays.asList(partyRoleCode).indexOf(roleToFind[0])
    if (index == -1) {
        // That role is not in the input document. If that's an error, raise an exception. If not, maybe add a default value.
    } else {
        output.addValue(partyInternalId[index])
    }
}

Map as follows:

And the same for SalesSupervisor, but with the constant updated, of course.

Note that the PartyRoleCode and PartyInternalID fields have the SalesArrangement context.

The code assumes that every PartnerFunctions element always contains both a PartyRoleCode element and a PartyInternalID element. If not, the logic breaks down.

Regards,

Morten

Rathika
Participant
0 Kudos

Thanks Morten. Was away so couldnt reply straightaway. Trying your approach.

Regards,

Abraham.

MortenWittrock
Active Contributor
0 Kudos

Cool. Please note that you seem to be logged in from a different account right now?

Regards,

Morten

0 Kudos

Yeah sorry. CPI user auto logged in.


It seems that this is getting executed only once for the first occurrence of PartyRoleCode. Does it have to do with their context being different .
And whenever ZE comes as like second or third in the queue. It only takes the first value and assigns Sales Man as a negative value .

Any way I can execute this mapping n times if partyrolecode value exists.?

Regards,

Abraham.

MortenWittrock
Active Contributor
0 Kudos

Hi Abraham

I have of course tested the mapping before posting my solution, and it works on my end. There is no context in play, when you set the context to the root element. In that situation, the script receives a queue of values, with no context changes.

Regards,

Morten

0 Kudos

Hi Morten,

I removed all the mappings and used only graphical mapping to connect PartyRoleCode to SalesMan to check my theory.

Turns out only first value in the queue is getting assigned. After the first value in the queue getting assigned to SalesMan it doesn't get called again to assign second value to Salesman.

Regards,

Abraham.