In part1 of this tutorial, the old way to create OData service on top of CDS view is introduced.

In SAP Help Generate Service Artifacts From a CDS View a new annotation is described:

@OData.publish: true

Just add this annotation to your CDS view and the odata service is automatically created, no need for you to go to code SEGW any more.

/wp-content/uploads/2016/03/clipboard1_906377.png

Once activated, the odata service with naming convention “<your CDS view name>_CDS” is available for registration in tcode /IWFND/MAINT_SERVICE:

/wp-content/uploads/2016/03/clipboard2_906378.png

Metadata retrieval test ok:

/wp-content/uploads/2016/03/clipboard3_906379.png

So the question here is: How does this annotation work? How can we research the service generation process through debugging?

Here below is how I figure it out.

First check what objects have been generated: three additional artifacts are highlighted below.

  • IWMO: SAP Gateway Business Suite Enablement – Model
  • IWSV: SAP Gateway Business Suite Enablement – Service
  • CLAS: provider class ZCL_ZJERRYTEST20160311 is generated

/wp-content/uploads/2016/03/clipboard4_906380.png

If I remove the annotation, or change the annotation to @OData.publish: false, and the two are gone:

/wp-content/uploads/2016/03/clipboard5_906381.png

So it means the annotation @OData.publish: true will trigger table entry insertion for type IWMO, IWSV and CLAS during view activation. Then again I switch on ST05 trace and easily find the ABAP code where the table insertion is done.

/wp-content/uploads/2016/03/clipboard6_906382.png

Set breakpoint on the code and observe the callstack in the runtime.

/wp-content/uploads/2016/03/clipboard7_906383.png

The highlighted callstack frames are essential for odata service generation.

/wp-content/uploads/2016/03/clipboard8_906384.png

Let’s have a deep look at stack frame 21:

CL_WB_DDLS_SECOBJ_HNDLR_SINGLE->IF_DDIC_WB_DDLS_SECOBJ_HANDLER~ON_ACTIVATION

It will first identify which objects must be created based on delta state.

/wp-content/uploads/2016/03/clipboard9_906385.png

For example, if I add @OData.publish: true to an existing CDS view and activate it, the corresponding entry will have flag N ( New ) while other existing annotation has type “U” ( Unchanged ).

/wp-content/uploads/2016/03/clipboard10_906318.png

Inside this method, if annotation ODATA.PUBLISH is found,

/wp-content/uploads/2016/03/clipboard11_906319.png

and the annotation value is true, then it is considered that the odata service must be created.

/wp-content/uploads/2016/03/clipboard14_906388.png/wp-content/uploads/2016/03/clipboard12_906386.png

/wp-content/uploads/2016/03/clipboard13_906387.png

The odata service creation is implemented in CL_SADL_GTK_ODATA_SERVICE_GEN~CREATE_VIA_EXPOSURE below.

/wp-content/uploads/2016/03/clipboard14_906388.png

Complete callstack:

/wp-content/uploads/2016/03/clipboard15_906390.png

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply