Inserting and updating records in an SAP OData dataset
The following Job aims at inserting records into an existing SAP OData dataset, then
updating some records in the same dataset with the help of the SAP OData search and filter
capabilities.
Linking the components
Procedure
Drag and drop the following components from the Palette:
tFixedFlowInput, 2
tSAPODataInput, 2 tLogRow,
tMap and 2 tSAPODataOutput.
Connect the tFixedFlowInput to the first
tSAPODataOutput component using a Row > Main connection.
Connect the tFixedFlowInput to the
tSAPODataInput component using an Trigger
> On SubJob OK connection.
Connect the tSAPODataInput, the
tLogRow and the second tMap using
a Row > Main connection, and the
tMap to the second
tSAPODataOutput using a Row >
FLOW connection.
Configuring the components
Procedure
Double-click the tFixedFlowInput component and click the
three-dot button next to the Edit schema field to define
it.
In this use case, the schema contains 11 columns: Kunnr
(String), Name1 (String), Name2
(String), Text (String) Street
(String), Pstlz (String), City
(String), Waers (String), Erdat
(Date), Ertim (Date), SAP__Messages
(String).
Propagate the changes to the next components.
In the Mode area of the component, select Use
inline table and click the plus icon to add three records:
Double-click the tSAPODataOutput component and configure
it to insert the records in your SAP OData service.
Enter the URL address of your SAP OData service, as well as the catalog service
path and the credentials used to access them.
In this use case, the SAP OData search capabilites are used to filter the
services on the API group ID named ZB_CUSTOMER.
Select the Entity set, and in the Output
action make sure to select Insert, as you
want to insert new records in this dataset.
Double-click the tSAPODataInput component and configure
it to only retrieve the records inserted in the first subJob.
Fill the same connection parameters, API group ID, and entity set that you
defined in the tSAPODataInput component.
In this use case, the Use $filter option is used to
filter on records in the Text column that contains
"+pid+" characters, and the Use
$select option is used to filter on the following columns:
Select Record in the Return type
field, as you want to retrieve records and not raw data.
Double-click the first tLogRow component and select
Table and Print content with
log4j in order to print the results as a table in the Job execution
console at runtime.
Double-click the tMap component to open its editor.
Ensure that only the records you want to update are mapped.
Double-click the second tSAPODataOutput component and
configure it to patch the records in your SAP OData service.
Fill the same connection parameters, API group ID, and entity set that you
defined in the tSAPODataInput component.
In the Output action make sure to select
Update and in the Update type,
select Patch, as you want to patch records in this dataset
and not replace them.
Double-click the second tSAPODataInput component and
configure it the same way you configured the first
tSAPODataInput.
Double-click the second tLogRow component and select
Table and Print content with
log4j in order to print the results as a table in the Job execution
console at runtime.
Executing the Job
Procedure
Press Ctrl + S to save your Job.
Press F6 to execute it.
Results
The results of the insert operation are printed in the first table, and the result of
the update (patch) operation are printed in the second table. You can see the three
inserted and updated records.