Search code examples
ibm-mqibm-integration-busextended-sql

Get Multiple Outputs From Single Input Message


I want to get multiple output from a single XML input message.

<List>
<type>mailbox</type>
<Docs>
  <DocID>38ghjk</DocID>
</Docs>
<Docs>
  <DocID>39ghjk</DocID>
</Docs>

This is how my XML looks it contains more DocID. My requirement is I want separate output messages for each DocID. I tried with while loop but I'm not getting separate messages for each DocIDs. I can fetch all DocIDs but I'm not able to get Separate Output each DocID.

Please suggest any way or solution to do it and please comment for any queries.


Solution

  • DECLARE I INTEGER;
    DECLARE J INTEGER;
    SET J = CARDINALITY(InputRoot.XMLNSC.List.Docs[]);
    SET I = 1;
    WHILE I < J  DO
    SET OutputRoot.XMLNSC.LIST.DocId[K] = InputRoot.XMLNSC.List.Docs[I].DocId;
    PROPAGATE TO TERMINAL 'out' delete none;
    SET I = I + 1;
    END WHILE;
    

    Earlier I was not using propagate statement so I was getting single output but now I'm getting different output for all docid.