May 20

OData Basics – Part 4 (Insert Operation)

In this blog, let us see how to handle the Insert Operation. As discussed in previous blogs, any enhancement regarding business logic is done in Data provider extension class. DPC is highlighted in below screenshot:

2017-05-20 10_58_25-183.82.114.111_3333 - Remote Desktop Connection

In the blog OData Basics – Part 2 (Read Operation), we have enhanced the method SCARRSET_GET_ENTITY to retrieve the data..

2017-05-20 10_59_24-183.82.114.111_3333 - Remote Desktop Connection

To handle insertion operation, let us redefine the method SCARRSET_CREATE_ENTITY

2017-05-20 10_59_45-183.82.114.111_3333 - Remote Desktop Connection

 

The data that we get from request can be read using the importing parameter IO_DATA_PROVIDER as shown below:

2017-05-20 11_02_36-183.82.114.111_3333 - Remote Desktop Connection

 

All the metadata related to our service is available in Model Provider class..

2017-05-20 11_09_29-183.82.114.111_3333 - Remote Desktop Connection

In the first step, to define a work area – I have referred the DPC ZCL_ZRZ_SCARR_DEMO_MPC=>TS_SCARR

2017-05-20 11_14_22-183.82.114.111_3333 - Remote Desktop Connection

  • Transaction /IWFND/MAINT_SERVICE – Activate and Maintain Services [We can activate and maintain service in SEGW transaction only – like we did in previous blogs]
  • Transaction /IWFND/GW_CLIENT – Gateway client

2017-05-20 11_22_58-183.82.114.111_3333 - Remote Desktop Connection

First, read a record and use it as request for inserting fresh record:

2017-05-20 11_27_28-183.82.114.111_3333 - Remote Desktop Connection

Modify the record with values you want to insert into table as shown below..

2017-05-20 11_30_53-183.82.114.111_3333 - Remote Desktop Connection

Record is captured as shown below:

2017-05-20 11_32_30-183.82.114.111_3333 - Remote Desktop Connection

Execute POST method to insert the record:

2017-05-20 11_34_59-183.82.114.111_3333 - Remote Desktop Connection

Table got updated successfully..

2017-05-20 11_37_19-183.82.114.111_3333 - Remote Desktop Connection