Application Programming Interfaces (APIs) allow developers to interact with SAP Gateway services and perform various operations, including creating, updating, and retrieving data. Through this practical scenario, we aim to shed light on the capabilities of the transaction /n/IWFND/GW_CLIENT and on how to leverage it effectively.
Transaction /n/IWFND/GW_CLIENT
Upon launching the t-code /n/IWFND/GW_CLIENT you will see a screen composed by three main sections. Above you have the HTTP Request URI where you can give the Service you wish to trigger. On your left side HTTP Request frame gives you the option to place your XML payload with the actual document or query. On the right side, you will see the response from the system after executing that payload.
In our example scenario, we wish to create a Purchase Order through the API service API_PURCHASEORDER_PROCESS_SRV. First the HTTP Method “POST” should be selected, then the Request URI /sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/A_PurchaseOrder. As a last step, you will have to copy/paste your actual payload into the left frame blank spaces:
{
"CompanyCode": "0001",
"PurchaseOrderType": "NB",
"Supplier": "Your_TestSupplier",
"DocumentCurrency": "EUR",
"PurchasingOrganization": "0001",
"PurchasingGroup": "001",
"to_PurchaseOrderItem": [
{
"PurchaseOrderItem": "1",
"PurchaseOrderItemText": "OData API test",
"Plant": "0001",
"OrderQuantity": "1",
"OrderPriceUnit": "EA",
"AccountAssignmentCategory": "K",
"PurchaseOrderQuantityUnit": "EA",
"DocumentCurrency": "EUR",
"NetPriceAmount": "1",
"NetPriceQuantity": "1",
"Material": "Your_TestMaterial",
"to_AccountAssignment": [
{
"Quantity": "1",
"GLAccount": "Your_Test_GL",
"CostCenter": "Your_Test_CC"
}
]
}
]
}
Debugging the API-call
Just like in case of any other HTTP request, the ABAP Debugging of the API-call can be done through external breakpoints. Go to the place you wish to stop the code and place an external breakpoint on the user executing the test scenario.
In our example a good place to start is the method PO_PROCESS (class CL_PO_HANDLER_MM). This place will call the “normal” SAP Function MEPO_DOC_PROCESS. The include LMEPOF2I, PO_PROCESS will call the subsequent Functions MEPO_DOC_HEADER_PROCESS and MEPO_DOC_ITEM_PROCESS.
In case you have a Badi-specific problem, you could also stop the method IF_FLUSH_TRANSPORT_MM~START (class CL_PO_HEADER_HANDLE_MM). That place will call the BAdI-Functions MEPOBADI_PROCESS_HEADER (implementation IF_EX_ME_PROCESS_PO_CUST~PROCESS_HEADER ) and MEPOBADI_PROCESS_ITEM ( impl. IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM ).
Creating test data for SAP cases
In case you wish to save an existing or successfully executed HTTP Request, you can simply click the “Save” button in the upper menu of the transaction. In the next selection screen, you can enter the Test group/Test case name to save your predefined set of data.
In case you already have a predefined test scenario, you can import it. On the main screen of the transaction /n/IWFND/GW_CLIENT right click in the “Test group” field and hit “Select Test case” or hit the F9 button. It will give you the same selection screen, where you can get your test HTTP request payload.
Complete XML files can also be added to the HTTP Request if you click “Add File”.
Related Content
Related SAP Notes/KBAs
To obtain more information about the structure of the OData Service for Purchase Order please consult our SAP Help link or see the SAP Knowledge Base Article 3360429 Differences Between OData API V2 API_PURCHASEORDER_PROCESS_SRV and V4 API_PURCHASEORDER [no code inside].
(Our test scenario is based on S4 Hana version SAPK-10703INS4CORE.)