Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLASS zcl_product_via_rfc_xxx DEFINITION
- PUBLIC
- FINAL
- CREATE PUBLIC .
- PUBLIC SECTION.
- INTERFACES if_rap_query_provider.
- PROTECTED SECTION.
- PRIVATE SECTION.
- ENDCLASS.
- CLASS zcl_product_via_rfc_xxx IMPLEMENTATION.
- METHOD if_rap_query_provider~select.
- DATA lt_product TYPE STANDARD TABLE OF ZCE_PRODUCT_XXX .
- "In the trial version we cannot call RFC function module in backend systems
- DATA(lv_abap_trial) = abap_false.
- "Set RFC destination
- TRY.
- data(lo_rfc_dest) = cl_rfc_destination_provider=>create_by_cloud_destination(
- i_name = 'S70_RFC_000'
- i_service_instance_name = 'OutboundComm_for_RFCDemo_000'
- ).
- DATA(lv_rfc_dest_name) = lo_rfc_dest->get_destination_name( ).
- "Check if data is requested
- IF io_request->is_data_requested( ).
- DATA lv_maxrows TYPE int4.
- DATA(lv_skip) = io_request->get_paging( )->get_offset( ).
- DATA(lv_top) = io_request->get_paging( )->get_page_size( ).
- lv_maxrows = lv_skip + lv_top.
- IF lv_abap_trial = abap_true.
- lt_product = VALUE #(
- ( productid = 'HT-1000' name = 'Notebook' )
- ( productid = 'HT-1001' name = 'Notebook' )
- ( productid = 'HT-1002' name = 'Notebook' )
- ( productid = 'HT-1003' name = 'Notebook' )
- ( productid = 'HT-1004' name = 'Notebook' )
- ( productid = 'HT-1005' name = 'Notebook' )
- ).
- ELSE.
- "Call BAPI
- CALL FUNCTION 'BAPI_EPM_PRODUCT_GET_LIST'
- DESTINATION lv_rfc_dest_name
- EXPORTING
- max_rows = lv_maxrows
- TABLES
- headerdata = lt_product
- .
- ENDIF.
- "Set total no. of records
- io_response->set_total_number_of_records( lines( lt_product ) ).
- "Output data
- io_response->set_data( lt_product ).
- ENDIF.
- CATCH cx_rfc_dest_provider_error INTO DATA(lx_dest).
- ENDTRY.
- ENDMETHOD.
- ENDCLASS.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement