Advertisement
Jaehoon

EXT202_5.3.1

Feb 11th, 2020
1,303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 2.35 KB | None | 0 0
  1. CLASS zcl_product_via_rfc_xxx DEFINITION
  2.   PUBLIC
  3.   FINAL
  4.   CREATE PUBLIC .
  5.  
  6.   PUBLIC SECTION.
  7.     INTERFACES if_rap_query_provider.
  8.   PROTECTED SECTION.
  9.   PRIVATE SECTION.
  10. ENDCLASS.
  11.  
  12. CLASS zcl_product_via_rfc_xxx IMPLEMENTATION.
  13.   METHOD if_rap_query_provider~select.
  14.  
  15.     DATA lt_product TYPE STANDARD TABLE OF  ZCE_PRODUCT_XXX .
  16.  
  17.     "In the trial version we cannot call RFC function module in backend systems
  18.     DATA(lv_abap_trial) = abap_false.
  19.  
  20.     "Set RFC destination
  21.     TRY.
  22.  
  23.       data(lo_rfc_dest) = cl_rfc_destination_provider=>create_by_cloud_destination(
  24.             i_name = 'S70_RFC_000'
  25.             i_service_instance_name = 'OutboundComm_for_RFCDemo_000'
  26.  
  27.         ).
  28.  
  29.       DATA(lv_rfc_dest_name) = lo_rfc_dest->get_destination_name(  ).
  30.  
  31.  
  32.         "Check if data is requested
  33.         IF io_request->is_data_requested(  ).
  34.  
  35.             DATA lv_maxrows TYPE int4.
  36.             DATA(lv_skip) = io_request->get_paging( )->get_offset(  ).
  37.             DATA(lv_top) = io_request->get_paging( )->get_page_size(  ).
  38.             lv_maxrows = lv_skip + lv_top.
  39.  
  40.                 IF lv_abap_trial = abap_true.
  41.                     lt_product = VALUE #(
  42.                               ( productid = 'HT-1000' name = 'Notebook' )
  43.                               ( productid = 'HT-1001' name = 'Notebook' )
  44.                               ( productid = 'HT-1002' name = 'Notebook' )
  45.                               ( productid = 'HT-1003' name = 'Notebook' )
  46.                               ( productid = 'HT-1004' name = 'Notebook' )
  47.                               ( productid = 'HT-1005' name = 'Notebook' )
  48.                               ).
  49.  
  50.                 ELSE.
  51.                   "Call BAPI
  52.                   CALL FUNCTION 'BAPI_EPM_PRODUCT_GET_LIST'
  53.                        DESTINATION lv_rfc_dest_name
  54.                        EXPORTING
  55.                          max_rows   = lv_maxrows
  56.                        TABLES
  57.                          headerdata = lt_product
  58.                          .
  59.  
  60.                 ENDIF.
  61.                   "Set total no. of records
  62.                   io_response->set_total_number_of_records( lines( lt_product ) ).
  63.                   "Output data
  64.                   io_response->set_data( lt_product ).
  65.  
  66.         ENDIF.
  67.  
  68.     CATCH  cx_rfc_dest_provider_error INTO DATA(lx_dest).
  69.     ENDTRY.
  70.  
  71.  
  72.   ENDMETHOD.
  73. ENDCLASS.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement