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 to get a user which send an request to odata in dpc?

BergOff
Explorer
0 Kudos
230

Hi, experts.
How to understand who sent an odata request in dpc mine service?
I've found only this, and i don't think it's good to write like this.
how to do it correctly?

types:
    begin of ty_s_parameter,
        name type string,
        value type ref to data,
      end of ty_s_parameter .
  data:
   ty_t_parameter type hashed table of ty_s_parameter with unique key name,
   ls_param type ty_s_parameter.
  data : mine_obj type ref to /IWBEP/IF_MGW_CORE_SRV_RUNTIME=>TY_S_MGW_REQUEST_CONTEXT.
  FIELD-SYMBOLS: <fs_value> TYPE any.


  mo_context->GET_PARAMETERS( IMPORTING ET_PARAMETER = ty_t_parameter ).
  read table ty_t_parameter into ls_param WITH TABLE KEY name = 'request_user'.
  ASSIGN ls_param-value->* TO <fs_value>.

 

3 REPLIES 3

Raifloresca
Explorer
0 Kudos
145

Hi,

As far as I know, the OData request is linked to an authentication in the SAP system, so there is a user that you can retrieve. Why can't you use the next piece of code to retrieve it?

cl_abap_context_info=>get_user_technical_name( ).

Regards.

0 Kudos
126

cause mine service is at one system and dpc is at another.
So at  /IWFND/MAINT_SERVICE  SAP System Allisas is not 'LOCAL'.  it's destination to erp system ( with dpc classes ).
And sy-uname would be the user wich is saved in destination (logon & Security )

0 Kudos
113

Okey. So the user in destination is correct for OData requests. Maybe you are testing it and you get your user.

But for real case scenarios, the user should be one related to the OData request's authentication. What's the problem there?