Technical Articles
Testing SAP PI interfaces in ABAP – part II
Introduction
In the last blog post I presented the problem I had and described the tool I created to solve this problem.
Link to previous post: https://blogs.sap.com/2019/12/13/interface-testing-in-the-sap-pi-system/
In a nutshell, the tool allows you to test the result of PI mapping and to test response from the synchronous message.
Today I would like to announce that I have made this tool available to everyone.
Link to github: https://github.com/tobiaszgithub/EITT
Installation and configuration
Requirements:
ECC: SAP_BASIS 740 and higher versions
PI/PO: 7.31 and higher versions with sap note 2437778
Installation:
1. Install Abap-Logger from https://github.com/epeterson320/ABAP-Logger.git using abapgit
2. Clone the EITT repository using abapgit
3. Perform initial configuration
Initial configuration
1. Tcode: SLG0: Create object ZEITT and subobject EXECUTION
2. SNRO: Edit intervals for number range object ZEITT (new number range number needs to be 01 and 02)
3. PI configuration.
More info in this blog post: https://blogs.sap.com/2014/02/17/howto-send-test-messages-to-the-adapter-engine-to-an-integrated-configuration/
Create two objects in the Integration Directory:
- SOAP sender channel that is configured to use the XI protocol. This channel will be used to test sender channel of the ICO you actually want to test
- Integration Configuration that references this channel.
You can choose any (dummy) Interface and Namespace (use dummy values in Receiver, Receiver Interface and Receiver Channel)
4. Tcode: SM59: RFC destination to PI system and more precisely to the dummy channel that was created in the previous step
Path prefix – use communication component and SOAP Sender channel that was created before: /XISOAPAdapter/MessageServlet?channel=:BS_D_EXAMPLE:CC_GLOBAL_TestMessagesAAE_SENDER
Ping RFC destination
5. Tcode SE80: Configure service consumer proxy ZEIT9_CO_ADAPTER_MESSAGE_MONIT. This consumer proxy is used to read messages from the PI system.
Unfortunately, before configuring the proxy, we need to regenerate it. I think it has to do with using abapGit to move the webservice consumer.
The WSDL file “DOC_CLAS_ZEIT9_CO_ADAPTER_MESSAGE_MONIT.WSDL” is in the github repository.
6. After regeneration and activation the proxy we can configure Logical Port:
- http://<host>:<port>/AdapterMessageMonitoring/basic?style=document
- Next ping consumer proxy and check if everything is ok
7. Tcode SM30: table ZTEIT_PROJECTS. Projects and subprojects group test cases.
8. Tcode SM30: table ZTEIT_SYSTEMS. Use previously created destination and logical port
9. Tcode SM30: table ZTEIT_INTERFACES. In this table, enter the actual interfaces that you want to test.
System name: System that was defined in the previous step
Interface name: Internal name of the interface
Service: Communication component from the PI
Name: Interface from the PI
Namespace: Interface namespace from the PI
How to use the EITT tool – the first test case
1. Open tcode ZEITT
2. Append new row
3. Fill in Explanation field
4. In the last column “Description” select Subproject or Project
5. Select Test Type: PM (PI Mapping)
6. Select System name
7. Select Interface
8. Use F4 help to find test message in the PI system
9. Select line and click Download Payloads (this action download payload before mapping and after mapping)
It is possible to display message before mapping
and message after mapping
10. Execute test and compare results
11. If any fields are not to be taken into account you must create a class “zcl_eitt_user_exit”. Here is example implementation:
CLASS zcl_eitt_user_exit DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES: zif_eit1_exit.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_eitt_user_exit IMPLEMENTATION.
METHOD zif_eit1_exit~get_ignore_expressions.
IF iv_interface EQ 'InvoiceExample_Out'.
rt_expressions = VALUE #(
( expression = '/ns1:BAPI_ACC_INVOICE_RECEIPT_POST/DOCUMENTHEADER/PSTNG_DATE'
ns_decls = 'ns1 urn:sap-com:document:sap:rfc:functions' )
( expression = '/n0:BAPI_ACC_INVOICE_RECEIPT_POST.Response/OBJ_KEY'
) .
ENDIF.
ENDMETHOD.
METHOD zif_eit1_exit~get_replace_expressions.
IF iv_interface EQ 'InvoiceExample_Out'.
rt_expressions = VALUE #(
( expression = '/ns0:invoice-header/ns0:invoice-number'
ns_decls = 'ns0 urn:example.com:External:Invoice' )
) .
ENDIF.
ENDMETHOD.
ENDCLASS.
Conclusion
Initial configuration may not be the most pleasant things but it is a one-time operation (unless you want to test a larger number of PI systems). After completing the configuration, you can test any number of interfaces for particular PI system. In addition to mapping testing, it is also possible to test replies from a synchronous message. Maybe next time I will discuss this case.