cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping logic to populate number of IDocs based on input logic

ramu_g4
Participant
0 Kudos

Hi Experts,

We are working on File to IDoc scenario.Number of ADRMAS01 IDocs that get generated should depend on below logic.

If IsCustomer and IsSupplier both are equal to string "true" then number of IDocs that should get generated should be equal to (number of occurrences of NatVer field multiplied by 2) i.e., suppose both of them are true then number of ADRMAS01 IDocs that should generate are 2 * no.of occurrences of NatVer field in input. Else if either of them IsCustomer andIsSupplier value is equal to "true" then number of ADRMAS01 IDocs that should occur is equal to number of occurrences of NatVer field.

Can this be achieved by standard functions or UDF is required. Kindly help.

Snippet of roles nodes.

Thanks,

Ramu.

Accepted Solutions (0)

Answers (7)

Answers (7)

ramu_g4
Participant
0 Kudos

Hi Raghu/Experts,

Can you help/guide me in this requirement.

Thanks,

Ramu.

former_member186851
Active Contributor
0 Kudos

Hello Ramu,

Provide district fields sample input and how it is required.

former_member186851
Active Contributor
0 Kudos

Hello Ramu,

Use remove contexts Followed by the same UDF(all values of context).

Result:

ramu_g4
Participant
0 Kudos

Thank you very much Raghu, now it creates the number of IDocs as expected:)

But I need one more help like segments under the IDocs should occur accordingly. For example:

In our case receiver IDoc ADRMAS01 with message type ADRMAS. "DISTRICT" target field should occur same number of times "district" in source payload and also the value should be mapped to appropriate context of E1BPAD1VL. "Address" node can occur multiple times in source payload under "NationalVersion".

Thanks,

Ramu.

former_member186851
Active Contributor
0 Kudos

Hello Ramu,

Try chaning the UDF with all values of context or share one small xml?

ramu_g4
Participant
0 Kudos

Hi Raghu

Thank you very much for your help!

The above UDF works when the occurrence ofBusinessPartnernode is only one [i.e., NameDetails node in your case occurs only once]. The requirement is like below where the BusinessPartnernode can occur multiple times as shown in 1st snippet andNationalVersionnode may or maynot occur as shown in 3rd snippet. The number of IDocs generated should be equal to (number of occurrences ofNatVerfield multiplied by 2) if suppose both of them are true i.e IfIsCustomerand IsSupplierboth are equal to string "true" then number of IDocs that should get generated should be equal to (number of occurrences ofNatVerfield multiplied by 2) i.e., suppose both of them are true then number of ADRMAS01 IDocs that should generate are 2 * no.of occurrences of NatVer field in input. Else if either of themIsCustomerandIsSuppliervalue is equal to "true" then number of ADRMAS01 IDocs that should occur is equal to number of occurrences ofNatVerfield.

Input structure looks like below:

BusinessPartnernode will have the following field details:

NationalVersion node may or may not occur under BusinessPartner as shown below:

Thanks,

Ramu.

former_member186851
Active Contributor
0 Kudos

ello Ramu,

Try the below UDF(All Values of Queue):

for(int i=0;i<var1.length;i++)
{
if(var1[i].equals("true")&&var2[i].equals("true"))
{
for(int k=0;k<var3.length*2;k++)
{
result.addValue("");
}
}
else if (var1[i].equals("true")||var2[i].equals("true"))
{
for(int j=0;j<var3.length;j++)
{
result.addValue("");
}
}
}

With both the Input values as true:

With both the Input values one as true and other as false:

ramu_g4
Participant
0 Kudos

Hi Experts,

Please help to achieve this.

Thanks,

Ramu.