cancel
Showing results for 
Search instead for 
Did you mean: 

Produce an empty xml tag from ABAP proxy

0 Kudos

Hi all,

I have a scenario where when a field, say <type>, contains a blank value from an ABAP proxy, the XI output is not producing an empty tag because the proxy cant send a blank value and thats xml's way of staying light by not producing a bunch of empty tags. But that is our goal is to produce an empty tag when <type> is blank. Therefore, we have decided to pass the value 'blank' to XI when there is no value found in the field. How would one create the mapping inside of XI to produce an empty tag when the value is 'blank' and if not 'blank' produce whatever the value may be?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Why not using node function mapWithDefault? This will create an empty tag, when the source field is missing. So you need not pass a value in ABAP proxy.

0 Kudos

So for example if I create the mapping of

ns0:type -----> mapWithDefault[] -----> ns0:type

that would produce an empty xml tag when a missing value is passed through the proxy?

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Ryan,

The answer is yes.

Regards,

Mark

Answers (2)

Answers (2)

navneeta
Employee
Employee

Hi ,

As you are saying the fields left blank do not get passed to PI . The request payload XML does not have blank value tag in it .

For this purpose we need to use if_wsprotocol_payloadinterface protocol ,

Actually With protocols, you can use additional runtime services.

The different runtime supports different protocols.

In our Proxy service .

Every Structure has an extra field of type PRXCTRLTAB .

we need to append our Blank value fields with initial value .

You Only need to include Bold font code in your existing code rest of the code are for understanding purpose .

Use Below Code To send Blank XML tag through Proxy :-

****************************************Beginning Of Code *********************************

DATA lo_service TYPE REF TO ZNAVCO_EMPLOYEE_DETAILS . "The object declaration for the proxy ABAP object .
DATA lt_inputs TYPE ZNAVDT_DETAILS_OUTBOUND_TAB . "internal table of Data structure
data ls_input TYPE ZNAVDT_DETAILS_OUTBOUND_STR . "work area of Data Structure

data ls_record TYPE ZNAVMT_DETAILS_OUTBOUND_STR. " the output parameter for the proxy

DATA lo_payload_protocol TYPE REF TO if_wsprotocol_payload. "payload Interface

*DATA lt_controller TYPE PRXCTRLTAB. " Controller Tab
DATA ls_controller TYPE PRXCTRL. " Controller Structure

CREATE OBJECT lo_service .

lo_payload_protocol ?= lo_service->get_protocol( if_wsprotocol=>payload ). " get proxy Protocol

CALL METHOD lo_payload_protocol->set_extended_xml_handling( abap_true ). "Active Extended XML handling .

ls_controller-field = 'EMP_LOCATION'. "field has blank value
ls_controller-value = sai_ctrl_initial. " This will send initial value
append ls_controller to ls_input-controller.

ls_controller-field = 'EMP_BANK_AC_NO'. "field has blank value
ls_controller-value = sai_ctrl_initial. " This will send initial value
append ls_controller to ls_input-controller.

ls_input-NAME = 'NAVNEET' . “Normal firlds having data

ls_input-DOJ = '10.01.2019' .

append ls_input to lt_inputs .

clear ls_input .

ls_controller-field = 'EMP_BANK_AC_NO'. "field has blank value
ls_controller-value = sai_ctrl_initial. " This will send initial value
append ls_controller to ls_input-controller.

ls_input-NAME = 'Anand'

ls_input-DOJ = '12.05.2016' .

ls_input-emp_location = 'India' .

append ls_input to lt_inputs .

ls_record -mt_sender_emp_details_templ-record = lt_inputs .

TRY.
lo_service->send_employee_data( output = ls_record ).

CATCH cx_root INTO Data(lr_excep).

MESSAGE lr_excep->get_text( ) TYPE 'E'.
ENDTRY.

************************************* End of Code ****************************************

Remember One thing :-

  • Include only fields have blank values in Controller table if you want to have blank XML tags in service request .
  • If you include any field in controller table then it will sent as blank XML tag whether they have data or not .

Thanks and Regards

Navneet Anand .

former_member246634
Active Participant
0 Kudos

Hi, thank you for your answer. It works fine while sending a request, but I get exception SOAP:1027 SRT: Serialization / Deserialization failed and a success message from service. Here's screenshot from SRT_UTIL:

In SE80 in service definition datatype for field "relationNumber" is STRING. Should it be INT4 or INT8?

markangelo_dihiansan
Active Contributor

Hi Ryan,

You can produce a blank output in an ABAP proxy by using extended xml handling.

Activating Extended XML Handling - ABAP Web Services - SAP Library

's suggestion is way easier

Regards,

Mark