Posting the data of a XML message using XSLT transformation
Hello Experts Hope everyone is doing well ,
I was wondering how I am going to post the DATA in ECC of a XML MESSAGE received from PI with a successful message status in SXMB_MONI.
In some scenarios it may happen that there might be a programming bug in the Provider class method which actually processes the payload content of the XML message.
This bug may lead to inconsistency like the actual posting of the data is incomplete Or not done at all and the messages ID status is still Successful in SXMB_MONI.
Now how are we going to reprocess the Successful message again? One option is that the source system should resend the data OR there should be a mechanism which processes such kind of messages.
There is some custom program available to regenerate the same XML payload with a different XML message ID and then Process it within the ECC system itself. This approach leads to multiple XML ID with same payload.
What if I could just extract XML payload from such message ID and process them using the provider class method .
I carried out the below steps to achieve same.
- Read the XML Content (Payload) of the XML message from the message ID.
- Call the XSLT transformation for the XML string obtained in step one.
- The XSLT transformation will give you the data formatted in INPUT structure (i.e. Importing parameter) of the method of the provider class which actually posts the data in ECC.
- Create an instance of the Provider Class of the interface.
- Pass the Input structure to the appropriate provider class method and invoke the same.
- The message will post the data into the system.
This would be just like you are testing the Interface using transaction SPROXY and posting data. This won’t create any temporary XML ID.
ABAP Code for same would somewhat look like this :
DATA : persist_main TYPE REF TO cl_xms_persist.
DATA : xmb_msg_main TYPE REF TO if_xms_message_xmb.
DATA : payload TYPE sxms_mmfpayloads.
DATA : wa_payload LIKE LINE OF payload.
DATA : abc TYPE REF TO if_sxmlp_data_st.
DATA : xslt_t TYPE cxsltdesc.
CALL METHOD persist_main->read_msg_all ” Read Messages attibuts
im_msgguid = wa_idtab-msgguid “ Message ID
im_pid = wa_idtab-pid
im_version = wa_idtab-rest_vers
ex_message = xms_msg_main.
xmb_msg_main ?= xms_msg_main. ” Type casting
CALL METHOD xmb_msg_main->get_main_payloads ” Get the payload object reference
return = payload.
READ TABLE payload INTO wa_payload INDEX 1. ”read at index one coz we are processing one xml id at a time
“Fetched the payload of XML ID
CALL METHOD wa_payload-mainpayload->gettextcontent ” extract the text contents form the play load
return = wa_str. ” This string contains the actual pay load xml data in text format
CALL METHOD cl_proxy_st_part=>create_for_intf_method
request_part_name = ‘<Interface name space>’
* request_part_nsuri =
* response_part_name =
* response_part_nsuri =
interface = ‘<Interface Name>’
method = ‘<Actual posting provider class method Name >’
* for_serialize_request = ABAP_FALSE
* for_deserialize_request = ‘X’
* for_serialize_response = ‘X’
** for_deserialize_response = ‘X’
** force_st_generation = ‘X’
* extended_xml_handling = ‘X’
* param_tab_in = abap_parmbind_tab
request_part = abc “ Get the reference
* response_part = pqr
** request_param =
** request_type =
** request_msg =
** request_xml =
** response_param =
** response_type =
** response_msg =
** response_xml =
** param_tab = abap_parmbind_tab
CATCH cx_xms_system_error .
CALL METHOD cx_xms_system_error->if_message~get_text
result = error_msg.
log_msg wa_idtab-msgguid error_msg.
“ Get the actual transformation
CALL METHOD abc->get_transformation_deserialize
rval = xslt_t.
“ Where is input_d is the passig parameter of your Provider class method which actually posts the data into system .
”Call transformation where input_d has same data type as the provider class posting method importing parameters.
CALL TRANSFORMATION (xslt_t) SOURCE XML wa_str
RESULT input = input_d.
“Where ref_providr_class is the Instence of your provider class object
“Invoke the method which process the actual data and pas input_d as input
CALL METHOD ref_provider_class->interface_name~provider_class_method”Actual Method invoking starts.
input = input_d
“And reposting done