Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How can we edit IO_TECH_REQUEST_CONTEXT in the GET_EXPANDED_ENTITY Method of Odata

9,219

Hi Experts,

I have a requirement to Edit the Importing parameter IO_TECH_REQUEST_CONTEXT inside method

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITY.

My purpose is to change the key Values (MR_REQUEST -> KEY_TAB ) of Importing Parameter IO_TECH_REQUEST_CONTEXT. From UI side, I am getting all the Key values separated by Commas, I just want to split it and call the below method in a loop.

cl_rtst_rp_document=>get_instance( )->get_expanded_entity(
exporting
io_tech_request_context = io_tech_request_context
io_expand = io_expand
importing
ers_entity = data(ert_document_entity)
changing
ct_expanded_tech_clauses = et_expanded_tech_clauses
cs_response_context = es_response_context
).

Please suggest. Thanks in Advance.
7 REPLIES 7

arthursilva
Active Participant
0 Kudos
4,241

Hello Nisha, hope you're well.

You cannot edit IO_TECH_REQUEST_CONTEXT simply because it's an importing parameter. In OO pattern, importing parameter should not be edit.

In case you need to use key/values pairs, try the following statement below. Once the key/vales are stored in an internal table, you're able to perform any treatment on it.

DATA(lt_keys) = io_tech_request_context->get_source_keys( ) .

KR,
Arthur Silva

0 Kudos
4,241

Hi Arthur,

Thanks for your response!

I can create a copy of the IO_TECH_REQUEST_CONTEXT e.g. LO_REQUEST and use it. That will be fine.

But before I call Method :

CL_RTST_RP_DOCUMENT=>GET_INSTANCE( )->GET_EXPANDED_ENTITY, I want to pass the changed LO_REQUEST with different entries for KEY_TAB.

Is it feasible?

Regards,

Nisha

Anju_MD
Discoverer
0 Kudos
4,241

Did you find a solution for this?

former_member717718
Discoverer
0 Kudos
4,241

Yes, you can “add values” to the values of IO_TECH_REQUEST_CONTEXT...

Do the following (at least BASIS 750, should also work with higher versions)

  • Define a class inheriting from /IWBEP/CL_MGW_REQUEST (IO_TECH_REQUEST_CONTEXT is instance of type /IWBEP/CL_MGW_REQUEST), let’s call it LCL_ MGW_REQUEST (possible because not final)
  • As the parameter IO_TECH_REQUEST_CONTEXT is an import parameter, clone the object with /IWBEP/CL_MGW_REQUEST->CLONE()
    * Remark: cast IO_TECH_REQUEST_CONTEXT to /IWBEP/CL_MGW_REQUEST to be able to use CLONE()
  • Define your method LCL_ MGW_REQUEST ->ADD_ADDITIONAL_VALUE_TO_KEY_TAB() to add values
    Example
Data(original_key_values) = your_clone->mr_request->key_tab
APPEND value#(<>) to original_key_values
  • Instead of IO_TECH_REQUEST_CONTEXT, use your_clone to request the data

Note

Of course, the usuall conditions/terms/caution apply concerning robustness, errorhandling and use of not released API's.

0 Kudos
4,241

Hi Andre,

How would you downcast from /IWBEP/CL_MGW_REQUEST to LCL_ MGW_REQUEST since you cannot use ?= unless the parent was narrowcasted from the child?

Alex

0 Kudos
4,241

Hi Alex,

I guess you are referring to step 3?

No need for a down cast: In a class, inheriting from /iwbep/cl_mgw_request, you have access to the protected members of class- and objects of type /iwbep/cl_mgw_request, especially mr_request

gustavo_lagreca
Associate
Associate
0 Kudos
3,384

Hello,
You can change the IO_TECH_REQUEST_CONTEXT using the method /IWBEP/IF_MGW_CORE_SRV_RUNTIME~READ_ENTITYSET

in my case it was necessary to stop using a search field coming from a fiori app.

 METHOD /iwbep/if_mgw_core_srv_runtime~read_entityset.
    
    DATA(ls_request_detailsis_request_details. """"SAME THAN IO_TECH_REQUEST_CONTEXT
    IF iv_entity_name  'APAROpenItem' AND iv_source_name =  'APAROpenItem'.
      IF line_existsls_request_details-parameters[ name 'search' ).
          ls_request_details-parameters[ name 'search' ]-value ''.
      ENDIF.
    ENDIF.

    TRY.
        CALL METHOD super->/iwbep/if_mgw_core_srv_runtime~read_entityset
          EXPORTING
            iv_entity_name               iv_entity_name
            iv_source_name               iv_source_name
            is_paging                    is_paging
            it_order                     it_order
            it_filter_select_options     it_filter_select_options
            is_request_details           ls_request_details
            iv_do_return_provider_format abap_false
          CHANGING
            cv_response_body             cv_response_body
            ct_headers                   ct_headers
            cr_entityset                 cr_entityset
            cr_deleted_entityset         cr_deleted_entityset
            cs_response_context          cs_response_context
            ct_inline_info               ct_inline_info.
      CATCH /iwbep/cx_mgw_busi_exception.
      CATCH /iwbep/cx_mgw_tech_exception.
    ENDTRY.
  ENDMETHOD.