ABAP Blog Posts
cancel
Showing results for 
Search instead for 
Did you mean: 

Introduction:

In this Blog, I want to walk through the detailed steps to create OData Web API Service for a standard storage Bin table:/SCWM/LAGP with low-code/no-code.

The main idea is to expose a standard database table as an OData Web API Service using the ABAP RESTful Application Programming Model (RAP), the fastest and most automated approach is to use the Generate ABAP Repository Objects wizard in ABAP Development Tools (ADT).
 
This method automatically generates the entire RAP stack—including the CDS Data Definitions, Behavior Definitions, Service Definition, and Service Binding

Target Audience and prerequisites:

  • ABAP developers who are new to RAP
  • Basic knowledge of CDS Views and ABAP Development Tools (ADT)
  • System used: SAP S/4HANA (On-Premise)

    Step 1. Create an ABAP package.

    This ABAP package will contain all the artefacts related to the OData Web API Service.

    In ADT, go to the Project Explorer, right-click on the System Instance, and select New > ABAP Package from the context menu.

    simmalakshman_0-1787336507352.png

     Maintain the required information, then Click Next >

    simmalakshman_1-1787587799107.png       simmalakshman_0-1787587786447.png  simmalakshman_2-1787587817730.png

    Select a transport request and click Finish

    simmalakshman_4-1787336576741.png

     Add the package created: “ZEWM_RAP_ST_BIN_DATA” to the favorite packages, using select Favorite Packages > ADD Package from the context menu.

    simmalakshman_5-1787336585318.png

     The package adds Under Favorite Packages:

    simmalakshman_7-1787336615012.png

     

    Step 2. Add Standard table to the favorite objects

    (no need to add if the table is already available in the Favorite Objects, just search for it).

    Right-click on Favorite Objects and select Add Object from the context menu

    simmalakshman_8-1787336639045.png

    Search for standard table :/SCWM/LAGP and click OK

    simmalakshman_3-1787587924088.png

    The Table /SCWM/LAGP adds under Favorite Objects

    simmalakshman_10-1787336663809.png

     

    Step 3. Create your OData v4 based WEB API service with the built-in ADT generator.

    Right-click the standard database table /SCWM/LAGP under favorite objects and select Generate ABAP Repository Objects from the context menu.

    simmalakshman_4-1787587953930.png

    Select OData Web API Service and click Next >.

    simmalakshman_5-1787587972564.png

    Provide the ABAP Package and click Next >.

    simmalakshman_13-1787336705896.png

    Maintain the required information on the Configure Generator dialog to provide the name of your data model, Behavior, Service Definition etc. 

    and click Next > to generate them.

    simmalakshman_14-1787336727604.pngsimmalakshman_15-1787336734610.png

    Select a transport request and click Finish

    simmalakshman_16-1787336761210.png

    Go to the Project Explorer, select your package refresh it by pressing F5, and check all generated ABAP repository objects

    simmalakshman_17-1787336778289.png

    The service binding is not generated due to inactive service definition, The conversion errors in the entity LC_LAGP00 are the cause for the inactive service definition.

    simmalakshman_18-1787336795085.png

    In SAP RAP (ABAP RESTful Application Programming Model), OData services block most standard DDIC conversion exists including ALPHA routines because they can cause runtime and formatting errors. 

    simmalakshman_19-1787336814179.png

    To resolve this, use a custom CDS type cast in your Core Data Services (CDS) view. After removing the errors in CDS View, activate the service definition and create the service Binding,

    Right click the service definition ‘ZAPI_LAGP_O4’ and select New Service Binding. Provide the Service Binding details and click Next >

    simmalakshman_20-1787336825755.png simmalakshman_21-1787336834640.png


    Select a transport request and click Finish

    simmalakshman_22-1787336853930.png

    Select the service Binding and Activate it.

    simmalakshman_23-1787336871759.png

    Right Click the CDS view and Select data Preview to display the filled database entries

    simmalakshman_24-1787336882105.png  simmalakshman_25-1787336890626.png

    Step 4. Publish the local service endpoint of your service binding

    Open your service binding ‘ZSB_API_LAGP_O4 and click Publish.

    simmalakshman_26-1787336915524.png

     A local publish failure for OData V4 service bindings in ADT typically stems from backend gateway synchronization gaps, transport/client restrictions or an ADT/BTP Trial environment regression bug. You can resolve this by manually publishing via SAP Gateway or switching protocols.

    In case of above error, click on the Menu button Run ABAP Development Object as ABAP Application in SAPGUI or press Alt+F8.

    simmalakshman_27-1787336930865.png

     Type /iwfnd/v4_admin as a search string and double-click on the entry /IWFND/V4_ADMIN (Transaction).

    simmalakshman_28-1787336943613.png

    Click the button Publish Service Groups to get a list of service groups that can be published

    simmalakshman_29-1787336967560.png

    Enter following values to search for the service group of your service and press the button Get Service Groups:

    • System Alias: LOCAL
    • Service Group ID: ZSB_API_LAGP_O4

       simmalakshman_30-1787336980853.png

      Select the entry ZSB_API_LAGP_O4 from the list and press the button: Publish Service Groups. 

       Confirm the success message and press Enter. The service will be published

        simmalakshman_34-1787337090384.png

      Once the service is published, we get the service URL.

      Add your SAP Host and Port (http://<host>:<port>) to the Service URL (/sap/opu/odata4/sap/zsb_api_lagp_o4/srvd_a2x/sap/zapi_lagp_o4/0001/) to test the URL.

       we can use the URL in below ways:

      1. Paste the URL into a tool like Postman or your web browser to view the service metadata or data feeds.

      2. Connect the URL to SAP Business Application Studio or SAP UI5 projects to build user interfaces.

      3Use the URL in non-SAP software or custom apps that need your data.

       
       Conclusion:

      We learned how to create OData Web API Service using the Generate ABAP Repository Objects wizard in ABAP Development Tools (ADT) to generate the entire RAP stack i.e., CDS Data Definitions, Behavior Definitions, Service Definition, and Service Binding automatically.

     

     

1 Comment
Labels in this area