Skip to end of metadata
Go to start of metadata

Now let's create an ODATA service based on a CDS view:

ZROOSATTR_CDS                            A

@AbapCatalog.sqlViewName: 'ZROOSATTR_CDS'

define view ZROOSATTRD as select from roosattr {

  key oltpsource as ODPExtractor,

  expose_external as IfExpose

}

Created DB view

ZROOSATTR_CDS


  1. Create new project - TCode.SEGW



  2. Import DDIC Structure - the name of the DB view ZROOSATTR_CDS




    Click 'Next'


    Click 'Finish'


  3. Create Entity Set




  4. Map Entity Set to Datasource






    Drag the columns of Datasource from right to left side


    Then 'Save' it.


  5. Generate the service
    2 Classes will be generated: MPC & DPC




  6. Register the service to the Gateway
    Expend node 'Service Maintenance' → double click GW_HUB




    The last column 'Registration Status' is changed to GREEN:


  7. Maintain and Activate the service




    You can also add a new System Alias for the service by clicking 'Add System Alias':



    The old Alias can be deleted by clicking: 

  8. Gateway Client test

    /sap/opu/odata/sap/ZSAP_GW_ZROOSATTR_CDS_SRV/?$format=xml

  9. Gateway Client - check the metedata

    Append $metadata to the URI i.e., /sap/opu/odata/sap/ZSAP_GW_ZROOSATTR_CDS_SRV/$metadata


    Name of EntitySet can be seen from the result : ExposedODPSet


  10. Gateway Client - check the entity set

    /sap/opu/odata/sap/ZSAP_GW_ZROOSATTR_CDS_SRV/ExposedODPSet

    All Entries can be returned:

    Check 'Data Explorer':


    Totally 252 entries which's the same with the CDS view and the source table ROOSATTR: