`

abap_oo小例子

阅读更多

*类定义
class application definition.
  public section.   "类方法
    methods: show_text.
    methods: show_jia.
  private section.  "类属性
    data text(100) type c value '输出1'.
endclass.
"类实现
class application implementation.
  method show_text.
    write text.
  endmethod.
  method show_jia.
    write '输入2'.
  endmethod.
endclass.
*全局数据声明
data ob_app type ref to application.

start-of-selection.
  create object ob_app.
    call method ob_app->show_text.
    call method ob_app->show_jia.

 

1) 使用type ref to来表示引用某一具体类以声明新的对象。

2)使用create ojbect语句创建类实例化对象

3)通过'->'或者'=>'运算符访问类对象或组件。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics