---
title: "abap_oo小例子"
author: "e6621887"
date: "2010-12-28T10:09:00Z"
tags: []
categories: ["编程语言"]
slug: "abap-oo"
draft: false
lastmod: "2010-12-30T14:09:47Z"
id: 853570
url: "https://e6621887.iteye.com/blog/853570"
---

\*类定义  
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-&gt;show\_text.  
    call method ob\_app-&gt;show\_jia.

 

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

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

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