The following article shows how to pass tables as input parameters to Transaction services.
The depicted example application uses the transaction VA02 to change a sales order in SAP, see Working with Transaction VA02.
Prerequisites #
Use an SAP dialog user with sufficient access rights to edit sales orders for the SAP connection assigned to the service.
Tip: The transaction feature of yunIO offers the same functionalities as the SAP GUI.
Selecting a Table as an Input Parameter #
- Create a transaction service that uses tables.
The depicted example uses a service that changes sales orders via transaction VA02, see Working with Transaction VA02. - Click
to open the service.
- Click on the documented actions in the section GUI Steps to navigate to the screen that contains the table you want to parameterize.
- Click on the fields and tables that you want to parameterize. The window “Parameterize Element” opens.
All fields that can be parameterized are highlighted in green when hovering over them.
- In the window “Parameterize Element”, select Input to override the content of the table when running the service.
- Enter a custom name for the parameter, e.g., ITEMS.
- Click [OK] to save the parameter. The window “Parameterize Element” closes.
- Click [Save] to save the service.
Note: When defining input parameters, make sure to parameterize fields before they are submitted in the GUI steps. If you define an input parameter after a submit, the input is not submitted to SAP.
Format of Input Tables #
Table parameters are passed to the service in the http request body.
In the request body, the columns of the table are represented by their SAP technical name, e.g., RV45A-MABNR
= Material column, RV45A-KWMENG
= Order Quantity column, etc.
You can look up the description of the SAP technical names in the OpenAPI/Swagger definition, e.g., Swagger Editor.
Table structure in the http request body | Table structure in OpenAPI/Swagger definition |
---|---|
"ITEMS": [ { "selected": false, "cells": { "VBAP-POSNR": "", "RV45A-MABNR": "", "RV45A-KWMENG": "", ... } }, { "selected": false, "cells": { "VBAP-POSNR": "", "RV45A-MABNR": "", "RV45A-KWMENG": "", ... } } ] |
ITEMS: type: array items: type: object properties: selected: type: boolean cells: type: object properties: VBAP-POSNR: description: Item type: string RV45A-MABNR: description: Material type: string RV45A-KWMENG: description: Order Quantity type: string ... |
When passing a table to yunIO, only pass fields with values assigned. Delete all table fields that are not subject to change from the request body.
Correct: "RV45A-KWMENG": "5"
Incorrect: "RV45A-KWMENG": ""
Running a Service with Table Parameters #
- Click
to copy the URL of the service definition or click
to download the service definition.
- Open the service in a tool that supports OpenAPI/Swagger definitions, e.g., Swagger Inspector.
- Use the
POST
method when integrating the service. TheGET
method does not support table parameters. - Open the request body of the service. All input parameters are listed in the request body.
- Delete all table entries that are not subject to change.
- Enter values for all fields that you want to overwrite, e.g.,
"RV45A-MABNR": "M-01"
,"RV45A-KWMENG": "5"
, etc. The http request body must only contain table fields with valid input values. The depicted example changes the order quantity of the first two items to 1 and 2:{ "ITEMS": [ { "selected": false, "cells": { "RV45A-KWMENG": "1" } }, { "selected": false, "cells": { "RV45A-KWMENG": "2" } } ] }
- Run the service. If the service run is successful, the response body contains a confirmation that the order was saved.
- Open SAP to check if the changes in the sales order.
Adding new Items to a Table
When adding new items to a table, the existing table rows must be passed as empty to avoid overwriting existing content.
The depicted example adds a new item at the 4th row of the table:
"ITEMS": [
{
"selected": false,
"cells": { }
},
{
"selected": false,
"cells": { }
},
{
"selected": false,
"cells": { }
},
{
"selected": false,
"cells": {
"VBAP-POSNR": "40",
"RV45A-MABNR": "M-01",
"RV45A-KWMENG": "5",
"VBAP-VRKME": "PC"
}
}
]