Advertisement
Guest User

Untitled

a guest
Mar 14th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 1.74 KB | None | 0 0
  1. *&---------------------------------------------------------------------*
  2. *& Report ZBC401_09_MAIN
  3. *&---------------------------------------------------------------------*
  4. *&
  5. *&---------------------------------------------------------------------*
  6. REPORT zbc401_09_main.
  7.  
  8. "Create Local Class EXC 2
  9.  
  10. CLASS lcl_airplane DEFINITION.
  11.   PUBLIC SECTION.
  12.     "Define public instANCE METHOD uses "methods"
  13.     METHODS: set_attribute
  14.       IMPORTING iv_name      TYPE string
  15.                 iv_planetype TYPE saplane-planetype.
  16.  
  17.     METHODS: display_attributes.
  18.  
  19.     "Defining a static method uses class-method
  20.     CLASS-METHODS DISPLAY_N_O_AIRPLANES.
  21.  
  22.   PRIVATE SECTION.
  23.     "define variables, these are private attributes
  24.     DATA: mv_name      TYPE string,
  25.           mv_planetype TYPE saplane-planetype.
  26.  
  27.     "Creates static attribute uses class-data syntax
  28.     CLASS-DATA: gv_n_o_airplanes TYPE i.
  29.  
  30. ENDCLASS.
  31.  
  32. CLASS lcl_airplane IMPLEMENTATION.
  33.   "implementation must have method and endmethod
  34.  
  35.   "implementation method for set_attribute
  36.   METHOD set_attribute.
  37.     "assign instance attribute to the importing parameters
  38.     MV_NAME = IV_NAME.
  39.     MV_PLANETYPE = IV_PLANETYPE.
  40.  
  41.     "increment the gv_n_o_airplanes counter by 1
  42.     gv_n_o_airplanes = gv_n_o_airplanes + 1.
  43.  
  44.   ENDMETHOD.
  45.  
  46.   "implementation method for display_attributes
  47.   METHOD display_attributes.
  48.     "Output these two instances in an abap list
  49.     "basically just write out the statement
  50.     WRITE: /'Name of airplane is ', MV_NAME.
  51.     WRITE: /'Type of airplane is ', MV_PLANETYPE.
  52.  
  53.   ENDMETHOD.
  54.  
  55.   "implementation method for display_no_o_planes
  56.   method display_n_o_airplanes.
  57.     "display the counter number
  58.     write: gv_n_o_airplanes.
  59.   ENDMETHOD.
  60. ENDCLASS.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement