on 05-25-2016 12:15 PM
Hi guys,
Can you help me with a mapping issue please?
My scenario is SOAP to BAPI. When there are no values in some of the source nodes, BAPI is having empty row created (during debug) and returning BAPI error. It doesn't work whether I have the mapping or remove it altogether from the config. But when I have the mapping and remove unused target nodes mapping it is working and successful response is received.
Now my question is... how can we use graphical mapping to avoid creating the respective target node if none of the input values are present under a source node. If at least one source field is present under a node, it should only then create the respective target node. Of course I can use "Map if exist" for all source fields or "map if not empty" but I have many fields in some of the source nodes.
Any idea how to achieve this please? Preferably graphical, but any help with UDF is appreciated as well.
Thanks in advance.
Ramesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ramesh!
If you need to check node only for any subnode existance, you can try a kind of "tricky" way:
Use Text function "EqualsS" where the first argument is your node with option "Return as XML tree" and the second is constant representing value of empty node, for example "<MyNode/>" If values are equal - your node is empty.
I can't test it myself now but you can try.
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Evgeniy,
Can you please let us know where will you direct the output of the text function.
Secondly even if you are able to direct the output to entire xml of target, there is another issue.
How many node names you need to compare to with entire source XML. As per first post by Ramesh, there are lot many fields like this.
I do not mean to offend you in any way just curious to know.
Regards
Anupam
Hi, Anupam!
1. EqualsS returns true or false. You use CreateIf for target node creation when EqualsS returns false (node is not empty).
2. You don't need to check every subnode. When you use XML tree representation, it returns something like this: "<Node><subnode1>value</subnode1><subnode2>value</subnode2></Node>
Node without any subnodes looks like <Node/>.
We just compare actual node XML representation with the same node representation when it's empty. If the values are equal - node is empty.
It's just an idea which requires testing.
Regards, Evgeniy.
Hi Evgeniy,
Thank you so much for your response.
Here are few points which I feel about this solution
1. Testing with EqualsS will always return false since comparison between xml tree and a single blank node will never match except for the case all sub nodes are empty and header node has formed.
2. You are comparing the header node value of a segment if it is empty.
This case does not take care of individual fields withing the header node. So in case some field value comes as blank where as others are coming with a value then this match will not give you proper result. Somewhere you need to compare with individual field node names. Take this case
<Node><subnode1/><subnode2>value</subnode2><subnode3/></Node>
here you need to compare individually to remove empty nodes.
Regards
Anupam
Hi Ramesh,
If you are not using "creatIf" node function, still it should work.
The target field should have minimum occurrence value as zero. In case the source field is not coming in payload ideally it should not create the target. I guess what is happening in your case is that the source nodes are coming with blank values , in such case empty target node gets created. If you do not want to check for a blank value for each field, then only way to remove all blank nodes is java mapping for a nested structure with multiple segment.
Thus you need a java mapping after message mapping.
Can you upload a sample input/output and desired output xml structure so that forum can suggest java mapping for the same.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Evgeniy,
The thread you provided is not relevant to my question as it was talking about list/context creation.
My issue is different.
Source:
<Parent BAPI Node> 1..1
<Node1> 0..1
<Field1>abc</Field1>
<Field2></Field>
<Node2> 0..1
<Field1></Field1>
<Field2></Field>
</Parent BAPI Node>
Target:
<Parent BAPI Node> 1..1
<Node1> 0..1
<Field1>abc</Field1>
<Field2></Field>
</Parent BAPI Node>
Target Node2 should not be created if all the fields under it are empty.
Thanks,
Ramesh.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.