cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in IDOC mapping

monikandan_p
Active Participant
0 Kudos

Dear Experts,

    I am facing issue in below idoc mapping, I need a udf for the below requirement.Kindly help me.

First eight field of one context should map to 0010015447

second 4 field of one context should map to 0010015822

same like all..

Kindly guide me.

Best Regards,

Monikandan

Accepted Solutions (1)

Accepted Solutions (1)

azharshaikh
Active Contributor
0 Kudos

Hi Monikandan,

You can achieve it using combination of Graphical and simple UDF in your MM. Please check the following screenshots of MM and UDF.

Hope it helps

Regards,

Azhar

monikandan_p
Active Participant
0 Kudos

Dear Experts,

My requirement is whenever PARVW field having number of RG,ZO we need to multiple

for ex:first context of PARVW having 3 RG and 5 ZO so it need come as 15 target node

       second context having 2 RG so 2 target node need to be create.

So first 10 set of PARVW values based on the condition need to map to KUNNR-0010015447

   Second set of PARVW values based on the condition need to map to KUNNR-0010015822

   Third set of PARVW values based on the condition need to map to KUNNR-0010055617

As per the requirement target node is coming correct but second target context node value KUNNR-0010015822 is missing in target side and unwanted null value coming at the end of context.

udf and mapping for the above requirement below.Kindly help to avoid null values and second target context node value KUNNR-0010015822 is missing in target.Help me to resolve.

UDF:

int var_RG=0;

int var_Z0=0;

int var=0;

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

{

if(var1[i].equals("RG"))

var_RG++;

if(var1[i].equals("Z0"))

var_Z0++;

}

if(var_RG != 0 && var_Z0 != 0)

{

for(int j=0;j<var_RG;j++)

{

for(int k=0;k<var_Z0;k++)

{

result.addValue("");

}

}

result.addContextChange();

}

else if(var_RG != 0) {

for(int j=0;j<var_RG;j++)

{

result.addValue("");

}

result.addContextChange();

}

else if(var_Z0 != 0) {

for(int j=0;j<var_Z0;j++)

{

result.addValue("");

}

result.addContextChange();

}

Target Output as per the requirement coming correctly but with some null values and second KUNNR value is missing:

Thanks

Best Regards,

Monikandan

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Monikandan,

If your udf createSoldTo is of type context, then use the below udf code. I have just corrected your udf only.

UDF:

int var_RG=0;

int var_Z0=0;

int var=0;

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

{

if(var1[i].equals("RG"))

var_RG++;

if(var1[i].equals("Z0"))

var_Z0++;

}

if(var_RG != 0 && var_Z0 != 0)

{

for(int j=0;j<var_RG;j++)

{

for(int k=0;k<var_Z0;k++)

{

result.addValue("");

}

}

}

else if(var_RG != 0) {

for(int j=0;j<var_RG;j++)

{

result.addValue("");

}

}

else if(var_Z0 != 0) {

for(int j=0;j<var_Z0;j++)

{

result.addValue("");

}

}

Try this out and let me know if you struck anywhere.

Regards

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Monikandan,

If you issue has resolved, then can you please close this this thread discussion:

Regards

Answers (3)

Answers (3)

RaghuVamseedhar
Active Contributor
0 Kudos

Monikandan,

Please use 'useOneAsMany'.

(4th screenshot).

http://saprainbow.com/sap-pi-mapping/useoneasmany-explained-in-easy-example/

nitindeshpande
Active Contributor
0 Kudos

Hi Monikandan,

Do you want to map the constant value based on the context of data arrives or is it like after 8 lines of data in first context must be mapped to first value and second context 4 lines of data must be mapped to second constant value?

Regards,

Nitin

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Monikandan,

Can you please elaborate the requirement for better understanding.

Regards