ODATA SERVICE SETUP+CRUDs
ODATA SERVICE SETUP+CRUDs
ODATA SERVICE SETUP+CRUDs
CONTENTS
CREATING THE SERVICE
TCODE= SEGW
CLICK ON FINISH,
CLICK ON PROPERTIES,
method ETEMPSET_GET_ENTITY.
endmethod.
Save code.
And execute,
ERROR 1
ERROR 2
Method not implemented,
If we go for a full entity set query or try to
read the entire table using GET,
As the ETEMPSET_GET_ENTITYSET from
this ZCL_ZAS_CRUD1_DPC_EXT isnt
implemented
Or it has no definition. So this request will
not work.
The method has to be implemented first,
then activated and then used.
method ETEMPSET_GET_ENTITYSET.
endmethod.
And execute,
The table ZAS_DEPT has 10 records, all 10 records
are fetched.
Also in json format, if needed
Get in JSON
/sap/opu/odata/SAP/ZAS_CRUD1_SRV/ETE
MPSet?$select=EmpName&$format=json
We can also get more than 1 field, like Employee
name and Employee Designation .
/sap/opu/odata/SAP/ZAS_CRUD1_SRV/ETE
MPSet?$select=EmpName,EmpDesig&$form
at=json
Now, write code for the CREATE Operation.
IO_DATA_PROVIDER-
>READ_ENTRY_DATA( IMPORTING ES_
DATA = ls_employee ).
ER_ENTITY = ls_employee.
method ETEMPSET_UPDATE_ENTITY.
*updating
UPDATE ZAS_DEPT from ls_empupdate.
endmethod.
Redefine,
method ETEMPSET_DELETE_ENTITY.
data(del_employee) = value #(
IT_KEY_TAB[ NAME = 'EmpNo' ]-
VALUE OPTIONAL ).
endmethod.