Advertisement
Jaehoon

EXT202_4.2.1

Feb 11th, 2020
1,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 2.87 KB | None | 0 0
  1. CLASS zcl_output_test_xxx DEFINITION
  2.   PUBLIC
  3.   FINAL
  4.   CREATE PUBLIC .
  5.  
  6.   PUBLIC SECTION.
  7.      INTERFACES if_oo_adt_classrun.
  8.   PROTECTED SECTION.
  9.   PRIVATE SECTION.
  10. ENDCLASS.
  11.  
  12.  
  13.  
  14. CLASS zcl_output_test_xxx IMPLEMENTATION.
  15.  
  16.   METHOD if_oo_adt_classrun~main.
  17.  
  18.  
  19.     " ABAP source code for type definition for BAPI_EPM_PRODUCT_HEADER
  20.     " generated on: ...
  21.  
  22.     TYPES : BEGIN OF ty_bapi_epm_product_header,
  23.               productid     TYPE c LENGTH 10,
  24.               typecode      TYPE c LENGTH 2,
  25.               category      TYPE c LENGTH 40,
  26.               name          TYPE c LENGTH 255,
  27.               description   TYPE c LENGTH 255,
  28.               supplierid    TYPE c LENGTH 10,
  29.               suppliername  TYPE c LENGTH 80,
  30.               taxtarifcode  TYPE int1,
  31.               measureunit   TYPE c LENGTH 3,
  32.               weightmeasure TYPE p LENGTH 7 DECIMALS 3,
  33.               weightunit    TYPE c LENGTH 3,
  34.               price         TYPE p LENGTH 12 DECIMALS 4,
  35.               currencycode  TYPE c LENGTH 5,
  36.               width         TYPE p LENGTH 7 DECIMALS 3,
  37.               depth         TYPE p LENGTH 7 DECIMALS 3,
  38.               height        TYPE p LENGTH 7 DECIMALS 3,
  39.               dimunit       TYPE c LENGTH 3,
  40.               productpicurl TYPE c LENGTH 255,
  41.             END OF ty_bapi_epm_product_header.
  42.  
  43.     TRY.
  44.  
  45.         DATA(lo_rfc_dest) = cl_rfc_destination_provider=>create_by_cloud_destination(
  46.           i_name = |S70_RFC_000|
  47.           "
  48.           i_service_instance_name = |OutboundComm_for_RFCDemo_000|
  49.  
  50.                               ).
  51.         DATA(lv_rfc_dest_name) = lo_rfc_dest->get_destination_name( ).
  52.  
  53.  
  54.         "variables needed to call BAPI
  55.  
  56.         DATA lt_product TYPE STANDARD TABLE OF  ty_bapi_epm_product_header.
  57.         DATA ls_product TYPE ty_bapi_epm_product_header.
  58.         DATA msg TYPE c LENGTH 255.
  59.  
  60.         "Exception handling is mandatory to avoid dumps
  61.         CALL FUNCTION 'BAPI_EPM_PRODUCT_GET_LIST'
  62.           DESTINATION lv_rfc_dest_name
  63.           EXPORTING
  64.              max_rows              = 25
  65.           TABLES
  66.             headerdata            = lt_product
  67.           EXCEPTIONS
  68.             system_failure        = 1 MESSAGE msg
  69.             communication_failure = 2 MESSAGE msg
  70.             OTHERS                = 3.
  71.  
  72.         CASE sy-subrc.
  73.           WHEN 0.
  74.             LOOP AT lt_product INTO ls_product.
  75.               out->write( ls_product-name && ls_product-price && ls_product-currencycode ).
  76.             ENDLOOP.
  77.           WHEN 1.
  78.             out->write( |EXCEPTION SYSTEM_FAILURE | && msg ).
  79.           WHEN 2.
  80.             out->write( |EXCEPTION COMMUNICATION_FAILURE | && msg ).
  81.           WHEN 3.
  82.             out->write( |EXCEPTION OTHERS| ).
  83.         ENDCASE.
  84.  
  85.       CATCH cx_root INTO DATA(lx_root).
  86.         out->write(  lx_root->get_longtext( ) ).
  87.  
  88.     ENDTRY.
  89.   ENDMETHOD.
  90. ENDCLASS.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement