Skip to main content Skip to complementary content

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

  1. Drag and drop the following components from the Palette: tFixedFlowInput, 2 tSAPODataInput, 2 tLogRow, tMap and 2 tSAPODataOutput.
  2. Connect the tFixedFlowInput to the first tSAPODataOutput component using a Row > Main connection.
  3. Connect the tFixedFlowInput to the tSAPODataInput component using an Trigger > On SubJob OK connection.
  4. 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.
    Overview of the Job in the Studio.

Configuring the components

Procedure

  1. 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.

  2. In the Mode area of the component, select Use inline table and click the plus icon to add three records:
    Configuration of the tFixedFlowInput component.
  3. 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.
    Basic settings view of the tSAPODataOutput component.
  4. 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:
    Kunnr,Name1,Name2,Street,Pstlz,City,Waers,Erdat,SAP__Messages
    Select Record in the Return type field, as you want to retrieve records and not raw data.
    Basic settings view of the tSAPODataInput component.
  5. 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.
  6. Double-click the tMap component to open its editor.
    Ensure that only the records you want to update are mapped.
    View of the tMap editor with mapped records.
  7. 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.
    Basic settings view of the tSAPODataOutput component.
  8. Double-click the second tSAPODataInput component and configure it the same way you configured the first tSAPODataInput.
  9. 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

  1. Press Ctrl + S to save your Job.
  2. 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.
View of the Execution tab showing the results of the insert and update operations.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!