Skip to Content
0
Jul 29, 2016 at 05:03 AM

Adding nodes in Target message Dynamically

132 Views

Hi Gurus,

I would like to ask for your help on a complex requirement that I have.

We're trying to add a dynamic node to a target message. The schema cannot be changed because it's standard for all interfaces. The only option is to add a node in mapping runtime.

Upon browsing SCN, I saw a blog regarding playing around with the target structure. Thank you Sunil Chandra for this 😊 I used the code below as suggested by Sunil and using Single Values in the execution type:

StructureNode node = ((StructureNode) container.getParameter("STRUCTURE_NODE"));

node.setPostValue("<Body><Node><Field1>"+input1+"</Field1><Field2>"+input2+"</Field2></Node></Body>");

This worked for me for the following example:

<Body>

<Node>

<Field1>A</Field1>

<Field2>B</Field2>

</Node>

</Body>

<Body>

<Node>

<Field1>C</Field1>

<Field2>D</Field2>

</Node>

</Body>

But when I'm having multiple Nodes per Body, I'm still only getting one Node per body.

<Body>

<Node>

<Field1>A</Field1>

<Field2>B</Field2>

</Node>

<Node>

<Field1>E</Field1>

<Field2>F</Field2>

</Node>

</Body>

<Body>

<Node>

<Field1>C</Field1>

<Field2>D</Field2>

</Node>

<Node>

<Field1>G</Field1>

<Field2>H</Field2>

</Node>

</Body>

By the way, let's assume that these are the source nodes that I need to put in directly to the target message.

I tried changing the execution type to All values of a context and all values of a queue, but that did not work. Also, with that, I tried adding a for loop but I'm getting a syntax error regarding methods. I guess the node.setPostValue cannot be repeated.

Any ideas are welcome kind sirs 😊

Thanks!

Regards,

SAPEnthusiast

Attachments