Skip to Content
0

Mapping logic to populate number of IDocs based on input logic

Nov 03, 2017 at 03:01 PM

88

avatar image

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.

roles.jpg (25.0 kB)
roles.jpg (23.9 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

7 Answers

Ramu G Nov 04, 2017 at 11:57 AM
0

Hi Experts,

Please help to achieve this.

Thanks,

Ramu.

Share
10 |10000 characters needed characters left characters exceeded
Raghuraman S Nov 06, 2017 at 08:34 AM
0

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:


udf1.png (6.1 kB)
udf2.png (19.7 kB)
udf3.png (24.8 kB)
udf3.png (20.4 kB)
Share
10 |10000 characters needed characters left characters exceeded
Ramu G Nov 07, 2017 at 09:10 AM
0

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.


Share
10 |10000 characters needed characters left characters exceeded
Raghuraman S Nov 07, 2017 at 09:29 AM
0

Hello Ramu,

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

Share
10 |10000 characters needed characters left characters exceeded
Raghuraman S Nov 07, 2017 at 02:14 PM
0

Hello Ramu,

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

Result:


1.png (8.1 kB)
2.png (20.3 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0
Raghuraman S Nov 08, 2017 at 08:39 AM
0

Hello Ramu,

Provide district fields sample input and how it is required.

Share
10 |10000 characters needed characters left characters exceeded
Ramu G Nov 10, 2017 at 08:17 AM
0

Hi Raghu/Experts,

Can you help/guide me in this requirement.

Thanks,

Ramu.

Share
10 |10000 characters needed characters left characters exceeded