- In this post will create OData project for read operation
Ø Step 1: Execute SEGW Transaction
Ø Step 2: Provide
OData Project Name, Description and Project Type as below:
Ø Step 3: Right
click on Data Model, Click on Import where we can see the multiple options for
creating Entity Set (Since we are creating Declarative data model) will click
on entity type as shown in Step 4).
Ø Step 4: In
this example we will create Entity type manually by Right click on Entity
Types, provide Entity type name (in Camel case) and click on Create Related
Entity Set Check box for creating Entity Set Entity Set
Note: One Entity Type we can used in
many Entity Set
Ø Step 5: Click
on Property, click on Append Row or Insert Row button and add field name, data
type, length etc. as below (This is called as Declarative data model since we
are declaring manually all the field name and length etc.):
- Note: Entity type also has to have at least one
property marked as the Key property.
- Note: In case of date field, quantity and amount
field always click on the Nullable check box. To avoid error in case of blank
value in this field.
- Note:
For better metadata
readable always provide all the details, ex. Max field length, filterable value
like which field have filterable value etc.
- Note: In case of Date format
kindly follow below details, provide date field name, click on Enter and click
on ABAP type editor as below:
- Provide Mode as Explicit
Assignment, Category as Date Element and Associated Type as Date Element so
that date timestamp value will automatically convert to Date format
Ø Step 6: Select
Project and click on Generate Runtime Object Button so that Run time artifacts will
create
- Note:
When we perform any Date model or Entity type related activity like create new
entity type, add new field in entity, modify field length, assign any key field
then always Re-generate Runtime object.
Ø Step 7: Here
we can see the Run time artifacts details, click on continue and provide
package name
Ø Step 8: We
can see the run time artifacts details as below:
Ø Step 9: Click
on Service Implementation and Redefine the required method, In this scenario we
are going to Redefine the GetEntity (Read) as below:
- Step
to Redefine method:
- Go
to DPX_EXT class: ZCL_ZODATA_PROJECT_DPC_EXT
- Find
the method: SALESHEADERSET_GET_ENTITY
- Click
on Redefine as below:
- See
the Redefine method as below:
- Save
check and activate method and check into the Service implementation
- Note:
For best practices, always create one Global class in SE24 (called as API
class) and write all your logic inside that global class/method and call API global class
inside the DPC_EXT, method. So that we can reuse that logic in another API as
well.
Ø Step 10: Go
to the Project, Copy the Service Suffix <_SRV> as se in the below Project
Ø Step 11: Execute transaction /IWFND/MAINT_SERVICE or /N/IWFND/MAINT_SERVICE and click on Add
Service button
Ø Step 12: Select
the System Alias as “LOCAL” (If Deployment type is “Central Hub
Deployment” then provide the RFC system name as Alias name), provide
the service name and click on enter, one
Service show below select the service and click on “Add Selected
Service” button
Ø Step 13: Popup
show as below, select package and click on continue
Ø Step 14: Once
click on continue, Information popup message show as “Service loaded
successfully”
- Note:
If you see the Service registered successfully but the service is not active
then pls activate the service as below:
- Again,
Execute the Transaction /IWFND/MAINT_SERVICE or /N/IWFND/MAINT_SERVICE, filter your
service and see the ICF Node, If ICF Node status not show as green color as
below then activate the service
- Click
on ICF Nodes button and select the Activate, provide the package name and
continue
- Once
the service is activated, we can see the status as Green Signal
- We
can activate service using SICF Transaction as well
Ø Step 15: GetEntity (Code)
Ø Step 16: Output