Skip to Content
Product Information

Monitoring Synchronous Outbound messages with SAP Application Interface Framework

Since the release of OnPremise1809, SAP Application Interface Framework is better integrated into Proxy/Webservice technology which makes it now possible to easier monitor synchronous message within one interface.

This blog post describes how to set up an SAP Application Interface Framework interface to monitor Synchronous outbound Web Service or PI messages.

The main step is create a local Metadata Repository data type with same component of INPUT/OUTPUT in consumer proxy.

How does it work?

  • Generate synchronous proxy service

Generate the inbound / outbound service proxy/web service interface

  • Check Message Type in Proxy

Check the message type of proxy input/output parameters

  • Define Metadata Repository namespace

Define MDR namespace for creating local data type

  • Create Metadata Repository Date Type for Output Message Type

Create local data type with same structure of output message type

  • Create Metadata Respository Date Type for Input Message Type

Create local data type with same structure of input message type

  • Create Metadata Respository Data Type for Monitoring

Create local data type embed input / output parameters

  • Create Interface

Create SAP Application Interface Framework interface

  • Create Test Data Report for outbound

Create test data report

  • Generate test data

Create test data.

  • Monitoring in Error Handling

Monitor data in AIF Error handling /AIF/ERR.

Example

This example uses a synchronous PI interface to demonstrate the monitoring of SAP Application Interface Framework.

1.1    Generate synchronous proxy service

Run transaction SPROXY, expand the ‘ESR’ type service consumers,

Select one of synchronous proxy, generate and activate it, for example: OSMultiOperSyn

Generate the corresponding inbound service for testing:

Double click the implementing class ZM111_CL_ISMULTI_OPER_SYN

Select the method ZM111_II_ISMULTI_OPER_SYN~ISMULTI_MATERIAL

Click the ‘Source Code’ button, activate below code

  method zm111_ii_ismulti_oper_syn~ismulti_material.
*** **** INSERT IMPLEMENTATION HERE **** ***
*  BREAK-POINT.
    output-rep_material-matnr = 'Test001'.
    output-rep_material-matkt = 'Test Material 0001'.
    output-rep_material-message = 'Get Material 00001 Successufully'.
  endmethod.

 

Select the method ZM111_II_ISMULTI_OPER_SYN~ISMULTI_ORDER

Click the ‘Source Code’ button, activate below code

method zm111_ii_ismulti_oper_syn~ismulti_order.
*** **** INSERT IMPLEMENTATION HERE **** ***
*** **** This just an example code
    output-rep_sales_order-doc_num = '0059'.
    output-rep_sales_order-message = 'Get Sales order 0059 successfully'.
    if input-so_create-header-sales_org = '9999'.
      output-rep_sales_order-doc_num = '9999'.
    endif.
  endmethod.

Make sure the class ZM111_CL_ISMULTI_OPER_SYN was activated.

1.2    Check Message Type in consumer Proxy

Double click the outbound proxy

Switch to External view,

Double click the request name ‘Output’,

Get the

Message type Name: reqMatCrd

Namespace: http://www.aif.com

Check the message type: reqMatCrd

Get Global Data Type with Elements:

Name: reqMatCrd_TT

Abap type: ZM111_REQ_MAT_CRD_TT

Namespace: http://www.aif.com

Double click the request name ‘Input’,

Get Message type Name: RepMaterial 

Check the message type: RepMaterial

Get Global Data Type with elements:

Name: ResponseMaterial

Abap type: ZM111_RESPONSE_MATERIAL

Namespace: http://www.aif.com

1.3  Define Metadata Repository namespace

Run transaction SPXNGENAPPL,

Create new BACKENDMDR type namespace entry if it does not exist.

For example: http://www.aif.com/MDR/###

1.4 Create MDR Date Type for Output Message Type

Run SPROXY, expand the SWCs-> Local->Namespace:

http://www.aif.com/MDR/M111

Right click on the namespace,

Click the ‘Create New Object’,

Select ‘Data Type’,

Select ‘Backend’,

Input Data type name: MTreqMatCrd _DT

Select package ZAIF_TEST_M111, proper change request and prefix ZM111_

Continue and Complete it

For new Date type MTreqMatCrd_DT, switch to external view:

Right click the external name: MTreqMatCrd_DT,

Select ‘Switch to Complex content type’

Right click the external name: MTreqMatCrd_DT,

Select ‘Add Element’

Input name: reqMatCrd(same to output message type name) and continue,

Right click on ‘reqMatCrd‘

Select ‘Set Global Type Reference’

Select ‘Select Existing Global Type’

Input Namespace: http://www.aif.com

Select the Abap type: ZM111_REQ_MAT_CRD_TT

Activate it.

 

1.5    Create Metadata Repository Date Type for Input Message Type

Run transaction SPROXY, expand the SWCs-> Local->Namespace:

http://www.aif.com/MDR/M111

Right click on the namespace,

Click the ‘Create New Object’,

Select ‘Data Type’,

Select ‘Backend’,

Input Data type name: MTRepMaterial_DT

Select package ZAIF_TEST_M111, proper change request and prefix ZM111_

Switch to External view,

Right click the external name: MTRepMaterial_DT,

Select ‘Switch to Complex content type’

Right click the external name: MTRepMaterial_DT,

Select ‘Add Element’

Input name: RepMaterial(same to input message type name) and continue,

Right click on ‘RepMaterial‘

Select ‘Set Global Type Reference’

Select ‘Select Existing Global Type’

Input Namespace: http://www.aif.com

Select the Abap type: ResponseMaterial

Activate it.

 

1.6    Create Metadata Repository Data Type for Monitoring

Run transaction SPROXY, expand the SWCs-> Local->Namespace:

http://www.aif.com/MDR/M111

Right click on the namespace,

Click the ‘Create New Object’,

Select ‘Data Type’,

Select ‘Backend’,

Input Data type name: MaterialMonitor_DT

Select package ZAIF_TEST_M111, proper change request and prefix ZM111_

Continue and complete it.

Switch to External view,

Right click the external name: MaterialMonitor_DT,

Select ‘Switch to Complex content type’

Add ‘INPUT’ and ‘OUTPUT’ elements

Right click on ‘INPUT‘

Select ‘Set Global Type Reference’

Select ‘Select Existing Global Type’

Input Namespace: http://www.aif.com/MDR/M111

Select the Name: MTRepMaterial_DT

Right click on ‘OUTPUT‘

Select ‘Set Global Type Reference’

Select ‘Select Existing Global Type’

Input Namespace: http://www.aif.com/MDR/M111

Select the Name: MTreqMatCrd_DT

Activate it

Generated structure ZM111_MATERIAL_MONITOR_DT.

1.7    Create Interface

Run transaction “/AIF/CUST”, click IMG node “SAP Application Interface Framework” -> “Interface Development-> “Define Interfaces”.

Input the namespace M111_0, then press continue button.

  • Namespace: M111_0
  • Interface Name: IF_2_2_6
  • Interface Version: 1
  • Description: Test Synchronous service with response/request data
  • Proxy Class Outbound: ZM111_CO_OSMULTI_OPER_SYN
  • Proxy Method: OSMULTI_MATERIAL

Press Enter,

The Raw Data Structure and Record type in Raw Structure will appear.

Input

  • SAP Data Structure: ZM111_MATERIAL_MONITOR_DT, this is the generated structure.

Save it.

1.8    Create Test Data Report for outbound.

Run SE38 to create test data report Z####_035  by reference below example code ZM111_ERIC_035.

*&---------------------------------------------------------------------*
*& Report  ZTEST_ERIC_034
*&
*&---------------------------------------------------------------------*
REPORT  ztest_eric_035.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-005. "'Default Value for Payloads'.
PARAMETERS: pv_matkx TYPE maktx DEFAULT 'Test for Synchronous service',
            pv_meins TYPE meins DEFAULT 'G',
            pv_mtart TYPE mtart DEFAULT 'A001',
            pv_syst  TYPE char3 DEFAULT 'XQX'.
SELECTION-SCREEN END OF BLOCK block1.
DATA:
  lr_proxy_syn     TYPE REF TO zm111_co_osmulti_oper_syn,
  ls_input_mat_syn TYPE zm111_rep_material,
  ls_material      TYPE zm111_req_mat_crd1,
  ls_line_material TYPE zm111_req_mat_crd.

DATA tsl TYPE timestampl.
GET TIME STAMP FIELD tsl.
ls_material-req_mat_crd-create_timestamp = tsl .
ls_material-req_mat_crd-matkl = pv_matkx.
ls_line_material-matnr = 'Test Material 1'.
ls_line_material-mbrsh = 'Test'.
ls_line_material-mtart  = pv_mtart.
ls_line_material-maktx = pv_matkx.
ls_line_material-meins = pv_meins.
ls_line_material-matkl  = pv_matkx.
ls_line_material-ntgew = 10.
ls_line_material-gewei = 'KG'.
ls_line_material-bismt = 'Older Material No.1 '.
ls_line_material-groes = '1.56'.
APPEND ls_line_material TO    ls_material-req_mat_crd-req_mat_crd_t .

IF lr_proxy_syn IS INITIAL.
  CREATE OBJECT lr_proxy_syn.
ENDIF.
TRY.
    CALL METHOD lr_proxy_syn->osmulti_material
      EXPORTING
        output = ls_material
      IMPORTING
        input  = ls_input_mat_syn.
  CATCH cx_ai_system_fault .
ENDTRY.

 1.9   Generate test data

In transaction SE38, run the new created program Z####_ 035 and use default parameters like following picture shows.

2    Monitoring in Error Handling

2.1    Monitor for Error Status Message

Run transaction /AIF/ERR, select one of error message and double click the next level of input/output structure node and check payload in the data content view.

[Check Point]: In interface M111_0 / IF_2_2_6 / 1, payload data for request data should be displayed there. And the response data is empty as the message failed with Error status.

Looks like below:

2.2    Monitor for Success Status Message

Run transaction /AIF/ERR, select one of error message and double click the next level of input structure node and check payload in the data content view.

[Check Point]: In interface M111_0 / IF_2_2_6 / 1, payload data for request and response data should be displayed there.

 

3 Conclusion

With the own created data structure in metadata repository, you can monitor the synchronous service interface in SAP Application Interface Framework now.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.