Technology Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
retired_member
Product and Topic Expert
Product and Topic Expert
2,127

The class CL_DEMO_OUTPUT and its interface IF_DEMO_OUTPUT format ABAP data and other data as output for demonstration and test purposes. Since its appearance, the following evolutionary steps took place:

The latter already introduced the implicit usage of CL_DEMO_OUTPUT to ABAP Cloud. Either by implementing IF_OO_ADT_CLASSRUN or by inheriting from CL_DEMO_CLASSRUN, CL_DEMO_OUTPUT can be invoked in order to produce console output. Here, CL_DEMO_CLASSRUN offers more methods than IF_OO_ADT_CLASSRUN.

When using IF_OO_ADT_CLASSRUN or CL_DEMO_CLASSRUN, the instantiation and the handling of the output data are done internally by ADT. Since neither IF_DEMO_OUTPUT nor CL_DEMO_OUTPUT can be released as an API, they cannot be used directly in ABAP Cloud.

To close this gap, with ABAP 2408, IF_DEMO_OUTPUT_CLOUD and CL_DEMO_OUTPUT_CLOUD were released as APIs for usage in test and demonstration programs in ABAP Cloud. They wrap CL_DEMO_OUTPUT and make only those features available that are suitable for ABAP Cloud. The main restrictions are:

  • There are no static methods. Only instance methods can be used via the interface IF_DEMO_OUTPUT_CLOUD.
  • There are no DISPLAY methods. The output produced by CL_DEMO_OUTPUT can be retrieved by method GET for further processing instead.
  • Some highly specialized methods of CL_DEMO_OUTPUT are not supported.
  • The output formats HTML, TEXT, JSON and XML are specified by enumerated constants.

Now you can write code in an ABAP class with ABAP language version "ABAP for Cloud Development" as follows:

 

    DATA:
      BEGIN OF struc,
        col  TYPE i VALUE 333,
        itab TYPE TABLE OF i WITH EMPTY KEY,
      END OF struc.

    struc-itab = VALUE #( FOR i = 1 UNTIL i = 4 ( i * 111 ) ).

    FINAL(dref) = REF #( struc ).

    FINAL(html) =
      cl_demo_output_cloud=>new( cl_demo_output_cloud=>html
        )->begin_section( 'HTML Output'
        )->get( dref ).

    FINAL(text) =
      cl_demo_output_cloud=>new( cl_demo_output_cloud=>text
        )->begin_section( 'Text Output'
        )->get( dref ).

    FINAL(json) =
      cl_demo_output_cloud=>new( cl_demo_output_cloud=>json
        )->begin_section( 'JSON Output'
        )->get( dref ).

    FINAL(xml) =
      cl_demo_output_cloud=>new( cl_demo_output_cloud=>xml
        )->begin_section( 'XML Output'
        )->get( dref ).

    "Do what you want ...

 

As the comment says, you can do what you want with the output strings returned by GET in HTML-, TEXT-, JSON- or XML-format.