abap中的casting及?=
REPORT AA. TYPES: BEGIN OF T_LINE, COL1 TYPE CHAR5, COL2 TYPE CHAR10, COL3 TYPE CHAR15, END OF T_LINE. DATA: GV_ADDR(30) TYPE C VALUE 'CHINA BEIJING TWIN BUILDING'. FIELD-SYMBOLS: <FS> TYPE T_LINE. "若不使用Casting,则会产生数据类型不一致的错误,因为是结构类型,gv_addr是字符类型。 ASSIGN GV_ADDR TO <FS> CASTING. WRITE:/ <FS>-COL1, <FS>-COL2, <FS>-COL3. FIELD-SYMBOLS:<FS1> TYPE ANY. ASSIGN GV_ADDR TO <FS1> CASTING TYPE T_LINE. WRITE:/ <FS>-COL1, <FS>-COL2, <FS>-COL3. CLASS VEHICLE DEFINITION . PUBLIC SECTION. METHODS:DRIVE. PROTECTED SECTION. DATA:SPEED TYPE I VALUE '100'. ENDCLASS. CLASS PLAN DEFINITION INHERITING FROM VEHICLE. PUBLIC SECTION. METHODS:FLY. ENDCLASS. CLASS VEHICLE IMPLEMENTATION. METHOD DRIVE. SPEED = SPEED + 100. WRITE:/ 'Driving is possible,','Current Speed:',SPEED. ENDMETHOD. ENDCLASS. CLASS PLAN IMPLEMENTATION. METHOD: FLY. SPEED = SPEED + 1000. ENDMETHOD. ENDCLASS. START-OF-SELECTION. DATA:CAR TYPE REF TO VEHICLE. DATA:AIR TYPE REF TO VEHICLE. DATA:AIR1 TYPE REF TO VEHICLE. DATA:AIR2 TYPE REF TO VEHICLE. CREATE OBJECT:CAR. "里面的初始speed是100 CREATE OBJECT:AIR1."里面的初始speed是100 AIR2 = CAR."里面的初始speed是200 ,相当于已经执行一遍的CAR AIR ?= CAR."里面的初始speed是100 相当于根据类创建了一个与CAR相同的实例 CALL METHOD AIR->DRIVE( ). CALL METHOD AIR1->DRIVE( ). CALL METHOD AIR2->DRIVE( ).