Skip to Content
avatar image
Former Member

How to create multiple idocs based on complex condition

HI Users,

my scenario is jms(xml file) to idoc. for each file have multiple records for each record i need to create multiple idocs.

source structure:

<lineitem>

<student sid="cid">456</student>

<hreference>

<reference rtype="number">123</reference>

.........

</hreference>

<hreference>

<reference rtype="number">789</reference>

</hreference>

<hreference>

<reference rtype="char">147</reference>

</hreference>

now condition is One input message must create only one output message for each unique rtype="number" and sid="cid" combination.

for example

1. rtype="number" and sid="cid" the value combination means 123456 for this one idoc

2. rtype="number" and sid="cid" the value combination means 789456 for this one idoc

--> the below file shows with out sid="cid"

<lineitem>

<student sid="abc">456</student>

<hreference>

<reference rtype="number">123</reference>

.........

</hreference>

<hreference>

<reference rtype="number">789</reference>

</hreference>

<hreference>

<reference rtype="number">147</reference>

</hreference>

in this case we have to consider only rtype="number" so here we need to create 3 idocs.

Could anyone help me in this regard.

Thanks in advance

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Jul 02, 2011 at 03:53 PM

    Hi,

    take XSD of IDoc change occurrence of IDoc segment to 1 to unbounded and import it as External definition and use it in message mapping.

    write mapping logic to IDoc segment, try with different ways. this can be achieve easily.

    Regards,

    Raj

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 02, 2011 at 03:55 PM

    Hi,

    do ur mapping as mentioned below:

    reference(change its context to lineItem) ---

    -


    Concat-- sort -splitbyvalue (Each Value)-- collapse context -Idoc

    Student -


    Refer this:

    https://wiki.sdn.sap.com/wiki/display/XI/File%20to%20Multiple%20IDOC%20Splitting%20without%20BPM

    thanks

    Amit

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 03, 2011 at 10:50 AM

    Hi Swathip,

    Change the occurence of the IDoc to "unbounded", so that multiple IDocs can get create

    Try with below logic

    If (SID = "CID")

    Then

    If(rtype = "number")

    concat(student,reference ) ---> removeContext ---> Idoc

    Else

    rtype ---> removeContext ---> Idoc

    • If combination of unique student and reference can occur more than once in the XML, use sort command and splitByValue (Value Change)

    Edited by: chandra shekhar on Jul 3, 2011 12:53 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 04, 2011 at 08:52 AM

    If you look your mapping logic in different angle then you don't need to bother about "cid". Basically the dependency of creating IDOC is when rtype="number". So apply the logic something like this..

    IF (rtype = number) THEN (reference -RemoveContext-Sort-SplitByValue( On Value Change )-CollapseContext---IDOC)

    Note: Before this you have to create the IDOC xsd with unbounded occurrence to generate multiple IDOCs.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 04, 2011 at 09:35 AM

    Hi,

    First Change the IDOC occurence i.e. 0...Unbounded. Import into External Definition. you can use External Definiton only Message Mapping.

    Operation Mapping you can use the Imported IDOC.

    logic

    if(rtype == number) && (sid == cid)

    then

    concat(rtype, sid) --> remove Context

    Regards,

    Naga.

    Add comment
    10|10000 characters needed characters exceeded