cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP ABAP RAP Query String parameters not available to access

AbhishekSharma
Active Contributor
0 Likes
826

Hi Gurus,

I created service using Unmanaged scenario using ABAP RAP... Below are the details for reference. 

Issue : I am not able access Query String parameter in code: I need param1, param2, param3 values in code 

www.abc.com/GetData?param1=10&param2=20&param3=30

Created Custom Root entity with few fields and Implemented Interface if_rap_query_provider and added below code in Custom Root entity

@EndUserText.label: 'Shimano API-WOrder/WTask'
@ObjectModel: {
    query: {
        implementedBy: 'ABAP:ZCL_EWM_WAREHOUSE_TASK'
    }
}
define root custom entity ZCE_WAREHOUSEORDERTASK
  with parameters 
  @Consumption.hidden: true
        WHO1 : num10
{
  key WHO     : num10;
  key LGNUM   : /scwm/lgnum;
      TANUM   : numc12;
      HUIDENT : char20;
}

Below is my Query Provide Select Method code for reference :

DATA:ls_data TYPE /scwm/who,
         lt_data TYPE /scwm/tt_who.
    IF io_request->is_data_requested( ).
      DATA(lv_top)     = io_request->get_paging( )->get_page_size( ).
      IF lv_top < 0.
        lv_top = 1.
      ENDIF.
      DATA(lt_parameters) = io_request->get_parameters(  ).
      DATA(lv_search_string) = io_request->get_search_expression( ).
      DATA(lv_skip)    = io_request->get_paging( )->get_offset( ).
      DATA(lt_sort)    = io_request->get_sort_elements( ).
      DATA : lv_orderby TYPE string.
      LOOP AT lt_sort INTO DATA(ls_sort).
        IF ls_sort-descending = abap_true.
          lv_orderby = |'{ lv_orderby } { ls_sort-element_name } DESCENDING '|.
        ELSE.
          lv_orderby = |'{ lv_orderby } { ls_sort-element_name } ASCENDING '|.
        ENDIF.
      ENDLOOP.
      DATA(lv_conditions) =  io_request->get_filter( )->get_as_sql_string( ).
      SELECT * FROM /scwm/who INTO TABLE lt_data
              WHERE (lv_conditions).
      "IF io_request->is_total_numb_of_rec_requested(  ).
      io_response->set_total_number_of_records( lines( lt_data ) ).
      io_response->set_data( lt_data ).
      "ENDIF.
    ENDIF.
  ENDMETHOD.

WHO1 is Parameter name which I am trying to access value of. My expectation was to get value of WH01 at line number 8 in above code, which is not happening. I am getting blank internal table.

Need is to access parameter from Query String Only using GET method.

I am already able to access these parameters when Passed in Header, Body and by using POST method which is triggered using an Action.

Please help how can I access these parameters from Query String using GET method.

Thanks-

 

 

 

 

 

 

 

Accepted Solutions (0)

Answers (1)

Answers (1)

AbhishekSharma
Active Contributor
0 Likes

After doing much research and going through many more available blogs and SAP Help portal, I have to come to a conclusion it's not possible to pass parameter as Query String and access them in backend code. Example code on SAP Book also does not use "with Parameter" option in CDS View.

All parameters which needs to be accessed in backend should go with in Brackets (param1=10, param2=10) and all of these must be key fields.

Solution to this is create V2 service which allow Query String parameter and we can also access then easily in backend extension method of Service. Below is code for reference:

LOOP AT MR_REQUEST_DETAILS->T_URI_QUERY_PARAMETER INTO DATA(tab_parameters_line).
    WRITE: tab_parameters_line-NAME, tab_parameters_line-VALUE.
ENDLOOP.

I am still looking for solution to this requirement using V4 service.

Thanks-