REPORT Z_METHOD_PARA.
CLASS vehicle DEFINITION.
PUBLIC SECTION.
METHODs:accelerate IMPORTING rate type i, 方法参数必须是在定义的时候定义,这边指定输入一个参数
show_speed.
PRIVATE SECTION.
data speed type i VALUE 0.
ENDCLASS.
CLASS vehicle IMPLEMENTATION.
METHOD accelerate.
speed = speed + rate. 方法的实现只需写实现的代码
ENDMETHOD.
METHOD show_speed.
WRITE: / 'Speed:',speed.
ENDMETHOD.
ENDCLASS.
DATA o_vehicle TYPE REF TO vehicle.
START-OF-SELECTION.
CREATE OBJECT o_vehicle.
CALL METHOD o_vehicle->accelerate EXPORTING rate = 2. 调用方法 传入的参数是2.
CALL METHOD o_vehicle->accelerate EXPORTING rate = 2.
CALL METHOD o_vehicle->show_speed.