ABAP 使用IF_DEMO_OUTPUT类演示输出
这种输出样式并没有什么特别之处,不过个人感觉这种写法 可(kan) 读(zhe) 性(niu) 强(bi) 一点
CLASS:
CLASS DEMO DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
MAIN,
CLASS_CONSTRUCTOR.
PRIVATE SECTION.
CLASS-DATA:
BEGIN OF STRUCT,
A1 TYPE STRING ,
A2 TYPE STRING ,
END OF STRUCT,
ITAB LIKE STANDARD TABLE OF STRUCT WITH EMPTY KEY.
ENDCLASS.
CLASS DEMO IMPLEMENTATION.
METHOD MAIN.
DATA(OUT) = CL_DEMO_OUTPUT=>NEW( ).
OUT->BEGIN_SECTION( `ABAP 用IF_DEMO_OUTPUT类演示输出`
)->WRITE( ITAB ).
OUT->DISPLAY( ).
ENDMETHOD.
METHOD CLASS_CONSTRUCTOR.
ITAB = VALUE #(
( A1 = `展示数据11` A2 = `展示数据12` )
( A1 = `展示数据21` A2 = `展示数据22` ) ).
ENDMETHOD.
ENDCLASS.
调用:
CASE E_UCOMM.
WHEN 'BT_8'.
demo=>main( ).
WHEN OTHERS.
ENDCASE.
效果展示: