cancel
Showing results for 
Search instead for 
Did you mean: 

PI Mapping

Former Member
0 Kudos

Hi,

My scenario is File to Idoc (Orders)

My File looks like below

Customer    ...     Code    Quantity

100                      10       1000

200                                 2000

100                                 3000

300                      20        4000

200                                 5000

300                      40       6000

300                                 7000

1) Create one idoc for each customer

2) If there is more than one record for a customer, then E1EDP01 should be repeated.

3) E1EDP01 should be populated only when code value is blank. if the record has a value in the "Code" then that record should be skipped.

we are able to achieve 1 and 2 in the mapping.

But we are not sure how to do the mapping for the Point 3 above.how to skip the E1EDP01 when there is a value in the code field.

Appreciate your help.

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

Perform two levels of mapping, first level mapping is to create only records where only code value is Blank.

Second level mapping toi create IDocs.

Former Member
0 Kudos

Hi Raj,

iam trying your approach to go with 2 levels of mapping

1st Mapping to eliminate the records which has value in code.

2nd mapping is to map to the idocs.

iam facing a issue in the operation mapping, because 1st mapping the occurence is 1:1

in the 2nd mapping the occurence is 1: unbounded(creating multiple idocs).

How can i resolve this issue.

Thanks

Srinivas

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Srinivas,

In first level mapping source and target is souce message type. Change root node of source data type to 1 to unbounded. it should work.

Paste your souce data typoe structure here.

Thank you,

Raj

Former Member
0 Kudos

Thanks all for your help

I followed your Raj suggestion, in the first mapping,deleting the records which has a value in code and

in second mapping creating the idocs.

Thanks

Srinivas

Answers (4)

Answers (4)

former_member201264
Active Contributor
0 Kudos

Hi ,

You can try like below:

OutPut:

Design:

Regards,

Sreeni.

Former Member
0 Kudos

Hi Srini,

Use the below logic.  Check if the code is blank or not and use createIf function.

Thanks,

Satish.

former_member184789
Active Contributor
0 Kudos

Hi,

I assume that you want E1EDP01 to be repeated as many times as the no. of records come except the cases where code value is not blank. It can be done simply by: if length of field 'Code' = 0; then CreateIf->E1EDP01. But I have one doubt, is it such that for each customer say 100,200 the code may occur multiple times. In such a case the above logic may work fine. In case if it is such that the source will have one code per Customer & the no. of E1EDP01 will be one less than total no.of Customer minus the one where Code exists:

Customer    Code

100        10

200        20

300        30

100

100

200

300

300

Thus you want to have two E1EDP01 for 100, one for E1EDP01,two for E1EDP01. In this case you can also have the logic sort the customer, then split by value(value change), count,then substract 1 as you will have one code for each customer. Using this count say inp1, you can have a small UDF for creating no. of contexts as per the count in var1. The input for inp2 will be code field:

for(int a=0;a<inp1.length;a++){

    int temp = Integer.parseInt(inp1[a]);

    for(int b=0;b<temp;b++){

        result.addValue(inp2[a]);

    }

}

Former Member
0 Kudos

Hi,

>>

we are able to achieve 1 and 2 in the mapping.But we are not sure how to do the mapping for the Point 3 above.how to skip the E1EDP01 when there is a value in the code field.

Your requirement not completely understood.As per my understanding ,in the above example for 100 client.In IDOC1--> E1EDP01 should open once.

for 200 client in IDOC2 E1EDP01 should open twice (as both doesn't have code)

for 300 client in IDOC3 E1EDP01 should open only once(two of them having code value and one doesn't have)

For example say you have 400 client too which is having one record then E1EDP01 shouldn't open in IDOC4.

Did my understanding correct ?

If yes ,use the below logic :

CustomerNumber--->remove context----->sortbykey-->count(Staticfn)-->splitbyval(eachval)-->o/p1

CustomerNumber--->remove context----->sortbykey------------------------------->formatbyexample->o/p2

Code->mapwithdef(empty)->remocont->/

Customer Number--->remove context-->sort->splitbyvalue(valuechange)-/

o/p1-->try udf or std fns to check for empty value in o/p2 nad pass them to o/p.

o/p2-/

Let me know if you are not able to do it.I will do.

Regards

Venkat

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Srinivas,

Use below mapping logic

Customer Number--->remove contect-->sort-->splitbyvalue(value change)-->collapseContext-->IDoc.

Customer context should be root node.

Regards,

Raj

Former Member
0 Kudos

Hi Raj,

Thanks for your reply, I have already done the header mapping creating one idoc for multiple customer records in the file.

My problem is segment E1EDP01 should be populated only when code value is blank. if the record has a value in the "Code" then that record should be skipped.

Thanks

Srinivas

Former Member
0 Kudos

Hi Srinivas,

Use CreateIf function with the desired condition to populate segment E1EDP01.

Thanks,

Pranav