cancel
Showing results for 
Search instead for 
Did you mean: 

Help with mapping

former_member190543
Participant
0 Kudos

Hi all,

I have an RFC lookup within the message mapping to get a table from ERP which has Employee_number and Employee_Name. The table in ERP can change, so the number of values is not fixed. The RFC call sends the table structure and receives the data in the table.

Now I have to compare the values coming from the source message under field EMP_NUM to each line of the RFC result and take the corresponding Employee_Name and map it to a target field.

The number of lines in the RFC result table and the number of values in the context of EMP_NUM are different. So how can I map this different number of context changes?

Many thanks in advance.

Ramesh.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184720
Active Contributor
0 Kudos

Can you elaborate a bit more?

What is the input to your RFC? a table name? and result would be the the list of columns along with values?

Can you execute the RFC in ECC and share the input and output?

This can be easily handled inside the RFC itself right? pass the empnumber and return the employee name.

former_member190543
Participant
0 Kudos

Hi Hareesh,

Yes, the input to the RFC is table name and the output is table. I have to compare a field of my source message to each row of the RFC result table and take the value that is matching. This is the requirement as there will be thousands of source fields. RFC table may be 30 or 40 rows.

so thousands of context changes for the source field have to be compared with less than 100 rows of the RFC table. Any solution please?

Thanks.

Harish
Active Contributor
0 Kudos

Hi Ramesh,

So you are getting the table date (two columns) as a result of RFC lookup. you can use the Hash table in PI to retrieve the employee name based on employee number from the input message.

refer the below wiki

http://wiki.scn.sap.com/wiki/display/XI/How+to+use+Cross+Reference+within+external+Database

regards,

Harish

former_member182412
Active Contributor
0 Kudos

Hi Ramesh,

Adding to Harish reply, you can use below UDF.

Execution Type : All values of context

argument1 : a (type string)

argument2 : b (type string)

argument3 : c (type string)


public void getNameById(String[] a, String[] b, String[] c, ResultList result, Container container) throws StreamTransformationException{

Map map = (Map) container.getParameter("names");

  if (map == null) {

  map = new HashMap();

  for (int i = 0; i < b.length; i++) {

  map.put(b[i], c[i]);

  }

  container.setParameter("names", map);

  }

  result.addValue((String) map.get(a[0]));

}

Mapping look like below:

EMP_NUM (From Source)---------->

EMP_NUM (From RFC result)-----> UDF------->mapWithDefault-------> TargetEMP_NAME

EMP_NAME (From RFC result)---->

Note: EMP_NUM source field must pass to UDF each value with context change, EMP_NUM and EMP_NAME from RFC must pass without context changes (use remove context change function if you have context changes) and make sure both queue are equal.

Regards,

Praveen.

former_member190543
Participant
0 Kudos

Thank you Praveen and Harish. I will try that and let you know how it goes.

Regards,

Ramesh.

former_member190543
Participant
0 Kudos

Thank you very much Praveen. Your solution worked and produced my desired results.

Regards,

Ramesh.

PS: Thanks Harish and Raghu for your inputs too.

Answers (1)

Answers (1)

RaghuVamseedhar
Active Contributor
0 Kudos

Ramesh,

Please check first section in below blog. You can write an UDF (with two for loops) to loop over look-up result and loop over input records.