Skip to Content
Author's profile photo Former Member

Making a payload preview without sending the message to PI

Quite often I have to deal with reports that list some documents and from where the user can start other business processes by sending a message via PI. The information available in the payload might require some complex calculations. As a user, wouldn’t it be interesting to have a message preview before actually sending such a message?

The following screenshots shows an example:

Here the user can choose a line and decide between sending the message or just making a preview.


A preview is just a popup with the XML but no message is actually sent.


This has turned out to be quite useful for the key users in production but also for the development team while testing.

How to do it? You just need to calculate the message payload and then, instead of calling the proxy, you need to transform the abap structure into an XML and finally display it.  Something like this where <fs_rmb_msg> contains the same structure as when calling the proxy.


Method map_payload_from_proxy handles the conversion between ABAP and XML and is generic enough to support any message format. You just need to pass the name of your interface and the method. SAP creates automatically an XSLT for each proxy that converts back and forward between XML<->ABAP so this method just need to find the XSLT and execute it. The following code shows how to do it:





      !IS_PAYLOAD type ANY


      value(RV_XML_STRING) type STRING



      ZCX_GU_PI_MSG .

  METHOD map_payload_from_proxy.

    DATA : lr_request TYPE REF TO if_sxmlp_data_st.

    DATA : lr_root TYPE REF TO cx_root.

    DATA : lr_payload TYPE REF TO if_ws_payload.

    DATA : lr_payload_data TYPE REF TO data.

    DATA: lt_bindings TYPE abap_trans_resbind_tab,

          ls_binding  TYPE abap_trans_resbind.

* ———- Check mandatory parameters ———————————————————–

    mandatory_param_generic iv_proxy_class  ‘IV_PROXY_CLASS’.

    mandatory_param_generic iv_proxy_method ‘IV_PROXY_METHOD’.

    mandatory_param_generic is_payload ‘IS_PAYLOAD’.

    TRY .

        cl_proxy_st_part=>create_for_clas_method( EXPORTING class         = iv_proxy_class

                                                                                                   method        = iv_proxy_method

                                              IMPORTING request_part = lr_request ).

        CLEAR ls_binding.

             ls_bindingname  = ‘OUTPUT’.

        GET REFERENCE OF is_payload INTO lr_payload_data.

             ls_bindingvalue = lr_payload_data.

        APPEND ls_binding TO lt_bindings.

             lr_payload = serialize( part     = lr_request

                                                        bindings = lt_bindings ).

             rv_xml_string = lr_payload->get_xml_text( ).

      CATCH cx_root INTO lr_root.

                  RAISE EXCEPTION TYPE zcx_gu_pi_msg


                      textid   = zcx_gu_pi_msg=>conversion_error

                      previous = lr_root.



where method serialize is a local copy of method CL_WS_PAYLOAD_HANDLER=>serialize.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Are you trying to mention the enhancement done by you here to the Moni screen?

      if not how the options are appearing and which point your logic is being incorporated

      Can you elaborate more on this ? As inbound payload option is available to see the xml sent which stage this option is being used in your case ?



      Author's profile photo Former Member
      Former Member
      Blog Post Author


      The idea is to offer the possibility of verifying a message before is actually generated and sent and it's not an enhancement but something you can add to your custom development. That is, you can display the XML but there is no new message in the system, I don't even call the proxy object and the database is not updated.