cancel
Showing results for 
Search instead for 
Did you mean: 

How to create multiple idocs based on complex condition

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

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

Answers (4)

Answers (4)

0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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