cancel
Showing results for 
Search instead for 
Did you mean: 

Use Custom Business Object Data for CDS Views in Eclipse

filipagatic
Explorer

Hello together, 

i have following use case: I need to use some of the fields of my custom business object in Eclipse to create a new view and do further calculations with these values. I have already maintained the catalogues for the CBO and created an other cds view on the basis of the CBO like a workaround, but it did not help. I always get the error in Eclipse IDE that the usage of the CDS-Entity is not allowed.

Is there a possible solution for this?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Oleg_Vokh
Product and Topic Expert
Product and Topic Expert

Hello,

yes, it is possible. In order to retrieve data from the CBO, you need to create a Custom Business Scenario for it and obtain the data through the API(http request). The same method can be used for CRUD operations to manage the Custom Business Object.

Step-by-step guide:

Find the ‘Custom Communication Scenarios’ app in customizing tenant,

click ‘New’ and provide name and description of the new communication scenario.

OlegVokh_0-1710235757777.png

After creating, click on ‘Add’ in the ‘Outbound Services’ tab. Provide all necessary fields.

OlegVokh_1-1710235757783.png

click on ‘Add’ in the ‘Inbound Services’ tab and iput the name CBO.

OlegVokh_7-1710236088325.png

After that save and publish communication scenario.

When status is published click the button ‘Create Arrangement’

OlegVokh_2-1710235757790.png

Choose an appropriate Communication System and User for that. Click “Save”.

OlegVokh_3-1710235757800.png

 

OlegVokh_4-1710235757810.png

Go to the ‘Communication Arrangement’ app in development tenant and create a new arrangement by selecting the ID of the scenario earlier created.

OlegVokh_5-1710235757812.png

Select the communication system and user for outbound communication and save the arrangement.

OlegVokh_6-1710235757825.png

After creating the Communication Arrangement, you have a link and a login with a password that you can use to connect to the API.

If you need this data in the CDS, you can use a CDS Custom Entity.

BR,

Oleg Vokh

 

filipagatic
Explorer
0 Kudos

Hello,

thanks for your answer. 

I already had created the communication scenario, but not the outbound communication. Now i created the outbound communication in the customizing tenant and then i went to the dev tenant to create the arrangement. The Communciation System and user that i have used in the Customizing Tenant were not saved there, i had to create new ones. But i have now access to the api, i have checked it in postman. I can access the data. But how do i use it in eclipse with ADT? It always says that the usage of the Entity is not permitted. 

Best regards

Oleg_Vokh
Product and Topic Expert
Product and Topic Expert

In ADT, it is necessary to use this API and retrieve data from it. Then parse the response that will be returned.

Below is an example class in ABAP that you can use to retrieve data. Replace the hardcoded data (url, user, pass) with your own.

CLASS zcl_api_test DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    TYPES:
      BEGIN OF ts_status,
        code   TYPE i,
        reason TYPE string,
      END OF ts_status.


    METHODS     method_get
      EXPORTING
        ev_resp_satus      TYPE ts_status
        ev_resp_satus_text TYPE string.


    INTERFACES if_oo_adt_classrun .

  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS zcl_api_test IMPLEMENTATION.



  METHOD if_oo_adt_classrun~main.

    method_get(  ).

  ENDMETHOD.

  METHOD method_get.
    DATA lv_url TYPE string VALUE 'url'.

    TRY.
        DATA(lo_dest) = cl_http_destination_provider=>create_by_url( lv_url ).
      CATCH cx_http_dest_provider_error.

    ENDTRY.

    TRY.
        DATA(lo_invoice_client) = cl_web_http_client_manager=>create_by_http_destination( i_destination = lo_dest ).
      CATCH cx_web_http_client_error.

    ENDTRY.

    DATA(lo_req_invoice) = lo_invoice_client->get_http_request( ).

    lo_invoice_client->get_http_request( )->set_authorization_basic( i_username = 'user'
                                                                     i_password = 'pass' ).

    lo_invoice_client->set_authn_mode( if_a4c_cp_service=>service_specific ).

    lo_req_invoice->set_header_fields( VALUE #( ( name = 'Content-Type' value = 'application/json' )
                                                ( name = 'Accept'       value = 'application/json' )
                                                ( name = 'X-CSRF-Token' value = 'fetch' ) ) ).

    TRY.
        DATA(lv_token) = lo_invoice_client->execute( i_method = if_web_http_client=>get )->get_header_field( 'X-CSRF-Token' ).
      CATCH cx_web_http_client_error cx_web_message_error.

    ENDTRY.

    lo_req_invoice->set_header_field( i_name = 'x-csrf-token' i_value = lv_token ).

    DATA(lv_header_response) = lo_req_invoice->get_header_fields( ).
    DATA(lo_request) = lo_invoice_client->get_http_request( ).

    TRY.
        DATA(lo_resp) = lo_invoice_client->execute( i_method = if_web_http_client=>post ).
      CATCH cx_web_http_client_error.

    ENDTRY.

    DATA(lv_resp_satus) = lo_resp->get_status( ).
    DATA(lv_resp_satus_text) = lo_resp->get_text( ).

  ENDMETHOD.
ENDCLASS.

 You will get the body with the necessary information in the variable lv_resp_status_text, and then you will need to parse this body to get the data.

BR,
Oleg

filipagatic
Explorer
0 Kudos
Sorry for the dumb question, but how do i run it in eclipse or better said
filipagatic
Explorer
0 Kudos

Hello @Oleg_Vokh , sorry for the dumb question, but how do i run it in eclipse or better said how do i get the response and parse it? I have implemented the class with my own custom values now but i dont know how to go on further.

 

best regards

Oleg_Vokh
Product and Topic Expert
Product and Topic Expert
0 Kudos
hi, I replied in a private message

Answers (0)