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.
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:
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.
Hello Ramu,
Try chaning the UDF with all values of context or share one small xml?
Hello Ramu,
Use remove contexts Followed by the same UDF(all values of context).
Result:
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.
Hello Ramu,
Provide district fields sample input and how it is required.