3 weeks ago
Hi, RAP Expert,
I run into failure in the first query. Would you please help me on this how to resolve it ?
I tried annotation with ObjectModel.query.implementedBy:'ABAP:ZCL_FO_QUEQRY' and the code is in the following box. But it doesn't resolve the issue .
CLASS zcl_fo_queqry DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_rap_query_provider .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_fo_queqry IMPLEMENTATION.
METHOD if_rap_query_provider~select.
DATA(lv_offset) = io_request->get_paging( )->get_offset( ).
DATA(lv_page_size) = io_request->get_paging( )->get_page_size( ).
DATA(lv_max_rows) = COND #( WHEN lv_page_size = if_rap_query_paging=>page_size_unlimited
THEN 0 ELSE lv_page_size ).
DATA(lt_req_elements) = io_request->get_requested_elements( ).
DATA(lv_req_elements) = concat_lines_of( table = lt_req_elements sep = `, ` ).
DATA(lv_sql_filter) = io_request->get_filter( )->get_as_sql_string( ).
TRY.
CASE io_request->get_entity_id( ).
WHEN 'ZR_FORDER_ITEMS' .
IF io_request->is_data_requested( ).
DATA lt_fo_items_response TYPE STANDARD TABLE OF ZR_FORDER_ITEMS.
SELECT (lv_req_elements) FROM ZR_Forder_ITEMS
WHERE (lv_sql_filter)
ORDER BY transportation_order_item
INTO CORRESPONDING FIELDS OF TABLE @LT_fo_items_response
OFFSET @LV_offset UP TO @LV_max_rows ROWS.
io_response->set_data( it_data = lt_fo_items_response ).
* CATCH cx_rap_query_response_set_twic.
ENDIF .
IF io_request->is_total_numb_of_rec_requested( ).
**select count
SELECT COUNT( * ) FROM ZR_FORDER_ITEMS
WHERE (lv_sql_filter)
INTO @DATA(lv_count).
**fill response
io_response->set_total_number_of_records( lv_count ).
ENDIF.
WHEN 'ZR_FREIGHTORDER' .
IF io_request->is_data_requested( ).
DATA lt_fo_headers_response TYPE STANDARD TABLE OF ZR_FREIGHTORDER.
SELECT (lv_req_elements) FROM ZR_FREIGHTORDER
WHERE (lv_sql_filter)
ORDER BY transportationorder
INTO CORRESPONDING FIELDS OF TABLE @LT_fo_headers_response
OFFSET @LV_offset UP TO @LV_max_rows ROWS.
io_response->set_data( it_data = lt_fo_headers_response ).
ENDIF.
IF io_request->is_total_numb_of_rec_requested( ).
**select count
SELECT COUNT( * ) FROM ZR_FREIGHTORDER
WHERE (lv_sql_filter)
INTO @DATA(lv_count1).
**fill response
io_response->set_total_number_of_records( lv_count1 ).
ENDIF.
ENDCASE.
CATCH cx_root INTO DATA(exception).
DATA(exception_message) = cl_message_helper=>get_latest_t100_exception( exception )->if_message~get_longtext( ).
ENDTRY.
ENDMETHOD.
ENDCLASS.
Best Regards!
Jacky Liu
Hello Jacky,
Can you please refer to the below code and adapt yours accordingly. You have replace the method call zcl_itapc_epm_employee=>get_instance( )->get_list_epm_employee_via_bapi with your select statement .
METHOD if_rap_query_provider~select.
DATA(query_filter) = io_request->get_filter( ).
DATA(query_sort_elements) = io_request->get_sort_elements( ).
DATA(query_requested_elements) = io_request->get_requested_elements( ).
DATA(is_data_requested) = io_request->is_data_requested( ).
DATA(is_total_numb_of_rec_requested) = io_request->is_total_numb_of_rec_requested( ).
DATA(page_size) = io_request->get_paging( )->get_page_size( ).
DATA(page_offset) = io_request->get_paging( )->get_offset( ).
DATA max_rows TYPE zcl_itapc_epm_employee=>ty_max_rows.
DATA sel_param_employee_id TYPE zcl_itapc_epm_employee=>ty_t_sel_param_employee_id.
DATA sel_param_first_name TYPE zcl_itapc_epm_employee=>ty_t_sel_param_first_name.
DATA sel_param_last_name TYPE zcl_itapc_epm_employee=>ty_t_sel_param_last_name.
DATA sel_param_lr_status TYPE zcl_itapc_epm_employee=>ty_t_sel_param_lr_status.
DATA employee_data TYPE STANDARD TABLE OF zcl_itapc_epm_employee=>ty_employee_data WITH DEFAULT KEY.
DATA return TYPE zcl_itapc_epm_employee=>ty_t_return.
" Filters
TRY.
DATA(filters) = io_request->get_filter( )->get_as_ranges( ).
CATCH cx_rap_query_filter_no_range INTO DATA(lx_no_sel_option).
" Simple request processing using ranges is impossible.
ENDTRY.
LOOP AT filters INTO DATA(filter).
CASE filter-name.
WHEN 'EMPLOYEE_ID'.
sel_param_employee_id = CORRESPONDING #( filter-range ).
WHEN 'FIRST_NAME'.
sel_param_first_name = CORRESPONDING #( filter-range ).
WHEN 'LAST_NAME'.
sel_param_last_name = CORRESPONDING #( filter-range ).
ENDCASE.
ENDLOOP.
" Pagination
DATA(lo_pagination) = io_request->get_paging( ).
" Requested elements
DATA(lt_requested_elements) = io_request->get_requested_elements( ).
" Dispatch the query
IF is_data_requested EQ abap_true OR is_total_numb_of_rec_requested EQ abap_true.
* READ LIST (GET) SCENARIO
*get Employees
max_rows-bapimaxrow = zcl_itapc_epm_employee=>gc_select_all_rows.
zcl_itapc_epm_employee=>get_instance( )->get_list_epm_employee_via_bapi(
EXPORTING
max_rows = max_rows
CHANGING
sel_param_employee_id = sel_param_employee_id
sel_param_first_name = sel_param_first_name
sel_param_last_name = sel_param_last_name
sel_param_lr_status = sel_param_lr_status
employee_data = employee_data
return = return
).
DATA Employees TYPE ty_t_emp.
Employees = VALUE ty_t_emp( FOR <employee> IN employee_data
FOR <txt> IN gender_texts WHERE ( Id = <employee>-**bleep** ) "FROM line_index( status_texts[ Id = <lr>-status ] )
LET emp = VALUE zitapc_c_employee(
sex_txt = | { <txt>-Text } ({ <employee>-**bleep** })| )
IN ( CORRESPONDING #( BASE ( emp ) <employee> ) ) ).
* Employees = VALUE #( FOR <employee> IN employee_data ( CORRESPONDING #( <employee> ) ) ).
io_response->set_total_number_of_records( lines( Employees ) ).
IF page_size GE 0. " Default value set for unlimited is -1.
SELECT * FROM @Employees AS lrs
ORDER BY employee_id ",from_timestamp DESCENDING
INTO TABLE @DATA(paged_data)
UP TO @page_size ROWS
OFFSET @page_offset .
io_response->set_data( paged_data ).
ELSE.
io_response->set_data( Employees ).
ENDIF.
ENDIF.
ENDMETHOD.
Best Regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
11 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.