Skip to Content

Mapping logic to populate number of IDocs based on input logic

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Nov 04, 2017 at 11:57 AM

    Hi Experts,

    Please help to achieve this.

    Thanks,

    Ramu.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 06, 2017 at 08:34 AM

    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:

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 07, 2017 at 09:10 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 07, 2017 at 09:29 AM

    Hello Ramu,

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

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 07, 2017 at 02:14 PM

    Hello Ramu,

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

    Result:

    Add comment
    10|10000 characters needed 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.

  • Nov 08, 2017 at 08:39 AM

    Hello Ramu,

    Provide district fields sample input and how it is required.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 10, 2017 at 08:17 AM

    Hi Raghu/Experts,

    Can you help/guide me in this requirement.

    Thanks,

    Ramu.

    Add comment
    10|10000 characters needed characters exceeded