Page 1 of 1

How to deal with OPTIONAL BOOLs in SAP Soap Clients?

PostPosted: Thu Jul 05, 2018 4:02 pm
by Bernd Welter
HI there,

these days a player mentioned that SAP has an issue with the creation of some SOAP request elements. Maybe someone of you has an idea how to deal with this?

The issue is
  • Some SOAP elements are defined as OPTIONAL with a boolean type (e.g. constructionStep)
    xml code
    <complexType name="StandardParams">
    <extension base="tns:PlanningParams">
    <element maxOccurs="1" minOccurs="0" name="goalImportance" nillable="true" type="tns:GoalImportance"/>
    <attribute name="availableMachineTime" type="xsd:int" use="optional"/>
    <attribute name="basicConstructionMethod" type="xsd:string" use="optional"/>
    <attribute name="constructionStep" type="xsd:boolean" use="optional"/>
    <attribute name="endSequencingStep" type="xsd:boolean" use="optional"/>
    <attribute name="improvementMethod" type="xsd:string" use="optional"/>
    <attribute name="improvementStep" type="xsd:boolean" use="optional"/>
    <attribute name="maximumNumberOfUnscheduledOrdersToBeAnalyzed" type="xsd:int" use="optional"/>
    <attribute name="middleSequencingStep" type="xsd:boolean" use="optional"/>
    <attribute name="sequencingMethod" type="xsd:string" use="optional"/>
    <attribute name="startSequencingStep" type="xsd:boolean" use="optional"/>
    <attribute name="tourReductionStep" type="xsd:boolean" use="optional"/>
  • If the ABAP source mentions the value of the property as "false" it causes the whole element not to be mentioned in the SOAP request which means the server - not being aware of the source of the request - has to treat the value based on a server side configuration.
  • The server standard for "constructionStep" when StandardParams are applied is TRUE.
  • Can you see the problem? If an ABAP developer wants to override the step by setting the source to false it doesn't cause the proper reaction.
So here's the challenge for you experts: HOW CAN WE OVERRIDE THIS IN SAP ABAP? I can't imagine that this issue has to be resolved by each and every ABAP developer who deals with SOAP...

Any help is appreciated!


Re: How to deal with OPTIONAL BOOLs in SAP Soap Clients?

PostPosted: Fri Jul 06, 2018 5:39 am
by jasci01
Hi Bernd,

I came across a similar problem using xTour-planBasicTours, where all of the "top" attributes are mandatory, but I did not want to use a input plan.

The deep attributes are mapped into structures in SAP, with each structure containing its fields as well as a table "CONTROLLER". We can use the controller tab to force a xsi:nil-Element in the XML. The following code must be executed before sending the request .

Code: Select all
DATA: lt_prxctrltab           TYPE prxctrltab,
          ls_prxctrltab           LIKE LINE OF lt_prxctrltab,
          lo_payload_protocol     TYPE REF TO if_wsprotocol_payload.

    IF ls_request-plan_basic_tours-plan_5 IS INITIAL.
      "fill controller table
      ls_prxctrltab-field = 'PLAN_5'.
      ls_prxctrltab-value = sai_ctrl_nil.
      APPEND ls_prxctrltab TO lt_prxctrltab.
      ls_request-plan_basic_tours-controller = lt_prxctrltab.

      "enable extended XML handling
      lo_payload_protocol ?= lo_proxy->get_protocol( if_wsprotocol=>payload ).
      lo_payload_protocol->set_extended_xml_handling( abap_true ).

This adds a xsi:nil attribute to the node, and so it forces SAP to create the node.
xsi nil.jpg

There are two other possible values (sai_ctrl_initial and sai_ctrl_none) but I don' have experiences with them. sai_ctrl_nil worked for me.

Maybe this helps.


Re: How to deal with OPTIONAL BOOLs in SAP Soap Clients?

PostPosted: Fri Jul 06, 2018 6:13 am

according to my knowledge and experience there is no real issue. It is more or less a semantic topic.

First of all a technical hint for SAP: it is possible to implement transformations into a Proxy to fix issues or to avoid certain circumstances (e.g. like the behavior you have described).

The root cause (in my humble opinion) is, that amount of payload is a part of TOC. By this, wizards generated Proxys are omitting optional attributes when there is no value sent from consumer. This is o.k. as far as the attribute is not type BOOL and service provider has the same understanding of false (equals initial). The problem occurs, when service provider has internal defaults for omitted attributes in contradiction to consumer, as your player was facing!

As no one likes to think deeply about an interface (more over likes to develop complete Proxys by hand and even a lot of transformations), all of us appreciate having a WSDL and delegating generation to a wizard. And here it comes: if developer does not know, that there are contradictions between Proxy (service consumer) and service provider, he could not implement suitable transformations! At the end service provider and Proxy are not wrong - but response for request may not be as expected and it takes a lot of effort to find out why!

Remark: I do not know how Proxys generated by dotNet/dotCom workbenches are working with BOOLEAN attributes e.g. constructionStep. So my answer bases on experiences with SAP and JAVA-based applications like SOAPUI.

Hope that helps

Re: How to deal with OPTIONAL BOOLs in SAP Soap Clients?

PostPosted: Fri Jul 06, 2018 6:57 am
by Bernd Welter
Hi guys,

thank you very much for your feedback about that issue. At least the thread could give the other SAP based players a valuable hint of an issue they could run into (worst case without recognizing it because you get a result, but a poor one). Hopefully your responses also provide solutions or potential approaches.

If I was a ABAP developer I'd be very glad for that initial input.

And this is why I love the community!

C u soon,