The methods of class CL_DEMO_OUTPUT create simple outputs of data in example programs without the need of classical lists. The class can be used via static methods and instance methods. The following methods create output in an output stream:
类CL_DEMO_OUTPUT 在示例程序中创造了很多简单的数据输出的方法而不需要经典的list。这个类可以通过静态或实例
化的方式使用。下面这些方法在输出流中创建输出
Methods BEGIN_SECTION, NEXT_SECTION, and END_SECTION create headers and open or close header levels.
方法BEGIN_SECTION,NEXT_SECTION和END_SECTION创建标题和开始或结束标题级别
Methods WRITE_DATA, WRITE_TEXT, WRITE_XML, WRITE_JSON, and WRITE_HTML write different kinds of output into the output stream.
方法WRITE_DATA,WRITE_TEXT,WRITE_XML,WRITE_JSON和WRITE_HTML显示不同类型的输出。
With method WRITE_DATA you can write elementary data objects (no reference variables), structures with elementary components, and internal tables of such line types.
使用WRITE_DATA可以输出基本类型对象(不是引用类型),结构的组件和内表的行类型。
The other methods create formated outputs of texts, XML, JSON, or HTML data.
其它方法创建格式化的输出数据如xml ,json,HTML。
The most simple and common type of usage might look as follows:
程序如下:
SELECT *
FROM scarr
INTO TABLE @DATA(carriers).
cl_demo_output=>display( carriers ).
方法BEGIN_SECTION,NEXT_SECTION和END_SECTION创建标题和开始或结束标题级别。
SELECT *
FROM scarr
INTO TABLE @DATA(carriers).
CALL TRANSFORMATION id SOURCE carriers = carriers
RESULT XML DATA(xml).
CALL TRANSFORMATION 此方法可以适用于任何参数转化为XML 。适用与接口日志存储。
示例
cl_demo_output=>begin_section( `Some Text` ).
cl_demo_output=>write_text( |blah blah blah \n| &&
|blah blah blah| ).
cl_demo_output=>next_section( `Some Data` ).
cl_demo_output=>begin_section( `Elementary Object` ).
cl_demo_output=>write_data( carriers[ 1 ]-carrid ).
cl_demo_output=>next_section( `Internal Table` ).
cl_demo_output=>write_data( carriers ).
cl_demo_output=>end_section( ).
cl_demo_output=>next_section( `XML` ).
cl_demo_output=>write_xml( xml ).
cl_demo_output=>display( ).
SELECT *
FROM scarr
INTO TABLE @DATA(carriers).
CALL TRANSFORMATION id SOURCE carriers = carriers
RESULT XML DATA(xml).
cl_demo_output=>new(
)->begin_section( `Some Text`
)->write_text( |blah blah blah \n| &&
|blah blah blah|
)->next_section( `Some Data`
)->begin_section( `Elementary Object`
)->write_data( carriers[ 1 ]-carrid
)->next_section( `Internal Table`
)->write_data( carriers
)->end_section(
)->next_section( `XML`
)->write_xml( xml
)->display( ).
SELECT *
FROM scarr
INTO TABLE @DATA(carriers).
cl_demo_output=>new( 'TEXT'
)->display( carriers ).
SELECT *
FROM scarr
INTO TABLE @DATA(carriers).
DATA(html) = cl_demo_output=>get( carriers ).
cl_abap_browser=>show_html( html_string = html ).