How to deal with OPTIONAL BOOLs in SAP Soap Clients?

This space is dedicated to SAP users - administrators and programmers who want to integrate the xServers. Topics which require specific SAP based knowhow or which deal with SAP based mechanisms will be collected here.

How to deal with OPTIONAL BOOLs in SAP Soap Clients?

Postby Bernd Welter » Thu Jul 05, 2018 4:02 pm

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">
    <complexContent>
    <extension base="tns:PlanningParams">
    <sequence>
    <element maxOccurs="1" minOccurs="0" name="goalImportance" nillable="true" type="tns:GoalImportance"/>
    </sequence>
    <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"/>
    </extension>
    </complexContent>
    </complexType>
  • 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!

Bernd
Bernd Welter
Manager Technical Consulting & Requirement Engineering
Senior Technical Consultant Developer Components
PTV GROUP - Germany

Bernd at Youtube
User avatar
Bernd Welter
Site Admin
 
Posts: 1152
Joined: Mon Apr 14, 2014 10:28 am

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

Postby jasci01 » Fri Jul 06, 2018 5:39 am

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 ).
    ENDIF.


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.

Regards,
Frederik
jasci01
 
Posts: 5
Joined: Mon Feb 12, 2018 3:49 pm

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

Postby MISTERX » Fri Jul 06, 2018 6:13 am

Cheers

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
Last edited by MISTERX on Fri Jul 06, 2018 8:48 am, edited 1 time in total.
Mr. X
  • Integration PTV <> SAP
  • Senior Consultant
________________________________________________

Optimism is only a lack of data!
User avatar
MISTERX
 
Posts: 29
Joined: Mon Jun 02, 2014 11:50 am

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

Postby Bernd Welter » Fri Jul 06, 2018 6:57 am

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,

Bernd
Bernd Welter
Manager Technical Consulting & Requirement Engineering
Senior Technical Consultant Developer Components
PTV GROUP - Germany

Bernd at Youtube
User avatar
Bernd Welter
Site Admin
 
Posts: 1152
Joined: Mon Apr 14, 2014 10:28 am


Return to PTV xServer meets SAP

cron