I am developing a creation/modification web service in SAP. Creation is OK but for modification the calling system has a standard:
- if they send a tag that's filled with a value: modify field in SAP
- if the tag is empty: clear field in SAP
- if any tag is not present: do nothing to the corresponding field
In SAP, I am in a class and see a simple structure of fields. No view of the XML. In addition, between me and other system is SAP-PI, a middleware. Apparently, PI always sends all tags. So how do I detect the three states?
For now our solution is PI sends me all tags and for those that he detects as "present" he adds an attribute is_present='X' to the tag. With this all the fields become structures with two fields: CONTENT, IS_PRESENT.
Before I rework my code, does anybody know if there is another way to do this?
There is a best practice to recognize whether a field is blank because its value is blank or the corresponding XML tag is missing.
Precondition: PI must not arbitrarily add missing tags
Because
is generally false. I don't know if your PI mapping adds missing tags for some reason but generally speaking PI definitely has the ability keep a tag absent in the xml resulted after the conversion.
If your PI mapping must add those missing tags or you can't change it, you can stop reading further.
Assuming you have the following situation:
And source xml contains
The message resulting after the PI conversion should be like
And not
At Backend side
In the input data of your inbound method you'll find some fields called
CONTEXT
(PRXCTRLTAB
type). You have oneCONTEXT
for every structure, in case of deep structures.In this table you can find the field names where XML is missing. Example:
To activate this feature implement the
CONSTRUCTOR
of your ABAP Proxy class and setSET_EXTENDED_XML_HANDLING = 'X'
. For example:Source: Activating Extended XML Handling