cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Request Payload for Create_Entity Method when called in ABAP Program

0 Kudos

Hi Experts

We have a requirement to perform a POST operation on OData in a ABAP Report,we have our request payload in a string variable and we are trying to call the Create_entity method in our Zreport.

Presently, we are calling the OData URL (http client call) for the post operation, but if the number of HTTP calls are more, it causes a dump.

Please suggest a solution to achieve the same using standard methods.

Accepted Solutions (0)

Answers (1)

Answers (1)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Hi Pallabi,

you can try the transaction SECATT_ODATA.

https://help.sap.com/viewer/b5e82726f51340a6aad908a8f762b54d/7.51.5/en-US/2fa11d6103c44607afe5d2cc7e...

Running the wizard would generate classes for each entity set of your OData service.

Instead of creating tests you can have a look at the generated coding.

When using the service /sap/opu/odata/IWBEP/GWSAMPLE_BASIC you would get for example a class ZCL_GWSAMPLE_BASI_SC_BUSINESSP with a method INSERT_BUSINESSPARTNER.

Regards,

Andre



method INSERT_BUSINESSPARTNER.

*--------------------------------------------------------------------*

  DATA lp_ecatt_odata_client      TYPE REF TO cl_ecatt_apl_odata_client.

  DATA l_url_ressource_path       TYPE string.

  DATA l_edm_abap_mapping         TYPE string.

  DATA l_query_str                TYPE string.

*--------------------------------------------------------------------*





* Prepare ressource path for URL



  IF ip_url_ressource_path IS NOT INITIAL.

    "from caller, maybe with navigation steps

    l_url_ressource_path = ip_url_ressource_path->get_ressource_path( ).

  ENDIF.

  IF l_url_ressource_path IS INITIAL.

    "or canonic ressource identifier of EntitySet

    l_url_ressource_path = `BusinessPartnerSet`.

  ENDIF.





* Create eCATT OData client



  lp_ecatt_odata_client = me->get_ecatt_odata_client( ).



  IF lp_ecatt_odata_client IS BOUND.



    "get EDM Metadata Model

    l_edm_abap_mapping = me->get_edm_abap_field_mapping( ).



    lp_ecatt_odata_client->get_service_metadata(

      EXPORTING i_edm_abap_mapping_stream = l_edm_abap_mapping ).





* Call the service



    "insert entity

    CALL METHOD lp_ecatt_odata_client->insert_entity(

      EXPORTING

        i_entity_set_name         = `BusinessPartnerSet` "#EC NOTEXT

        i_entity_container        = co_service_container "#EC NOTEXT GWSAMPLE_BASIC_Entities

        i_url_ressource_path      = l_url_ressource_path  "#EC NOTEXT

        "i_url_query_options       = l_query_str

        ip_request_options        = ip_request_options

        i_property_selection_mode = i_property_selection_mode

        it_selected_properties    = it_property_selection

      CHANGING

        cs_entity_data            = cs_businesspartner

                                    ).

  ENDIF.



  endmethod.