ABAP自定义类的构造方法详解编程语言

REPORT ytest_011.  
 
*----------------------------------------------------------------------*  
*       CLASS zcl_eventsreceive DEFINITION  
*----------------------------------------------------------------------*  
* 
*----------------------------------------------------------------------*  
CLASS zcl_eventsreceive DEFINITION . 
  PUBLIC SECTION. 
    METHODS : 
      say ,  
      constructor 
        IMPORTING  
          input TYPE char10. 
    DATA data_type TYPE char10 . 
ENDCLASS.                    "zcl_eventsreceive DEFINITION  
*&---------------------------------------------------------------------*  
*&       Class (Implementation)  zcl_eventsreceive  
*&---------------------------------------------------------------------*  
*        Text  
*----------------------------------------------------------------------*  
CLASS zcl_eventsreceive IMPLEMENTATION . 
  METHOD constructor.  
    data_type = input. 
  ENDMETHOD.                    "constructor 
 
  METHOD say.  
    MESSAGE s000(oo) WITH data_type . 
  ENDMETHOD.                    "SAY 
ENDCLASS.               "zcl_eventsreceive 
 
START-OF-SELECTION. 
  DATA lcl_cls_1 TYPE REF TO zcl_eventsreceive. 
  DATA lcl_cls_2 TYPE REF TO zcl_eventsreceive. 
 
  CREATE OBJECT lcl_cls_1 
    EXPORTING  
      input = 'SVICE1'.  
  CREATE OBJECT lcl_cls_2 
    EXPORTING  
      input = 'SVICE2'.  
 
  WRITE:/ '== GO =='. 
  CALL METHOD lcl_cls_1->say. 
  CALL METHOD lcl_cls_2->say. 
  WRITE:/ '== END =='. 

以后写一个用同一个类响应多个ALV的事件的用法会用到自定义构造方法

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/19205.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论