You know the ABAP console of ADT that allows to use out->write
in the main
method of classes that implement interface if_oo_adt_classrun
in order to write the content of ABAP data objects to a text console.
You might also know the interface if_demo_output
implemented by class cl_demo_output
that also offers a method write
that does mostly the same.
What you might don’t know is the fact that the implementations of the ABAP console in ADT and of cl_demo_output
are two sides of the same coin. When the ABAP console was introduced some years ago, its internal implementation was copied from cl_demo_output
and cl_demo_output_stream
(the latter produces an output-friendly XML). But since ADT used an early stage of cl_demo_output
, it missed its continuous improvements that took place in the meantime. An example is the implicit retrieval of the data object’s name if no name is passed explicitly.
Recently, cl_demo_output
was invigorated significantly by being able to handle any ABAP data object including complex types like nested structures or tables and data as well as object references (see the blog CL_DEMO_OUTPUT invigorated). In the blog it is still stated that the new features are available in HTML mode of cl_demo_output
only. And even that has changed. A clever working student (a physicist) has done it and “reprogrammed a browser in cl_demo_output_text
“! With other words, the content of arbitrary ABAP data objects can be displayed in a console-type text format.
Thus, with Releases 2308/2023, what belongs together grows together. The ABAP console of ADT skipped the old implementation and calls the implementation of cl_demo_output
instead. As a result, you don’t have to care about your data types anymore. And the best is, you have to do nothing for that. The enhancement comes for free.
Old release:
As of 2308/2023:
And in fact, everything goes and the output can become quite complex. Try it.
If you know if_demo_output
, you might also know that it contains much more methods than if_oo_adt_classrun
that is the standard type of parameter out
which allows to call methods WRITE
and GET
only. In order to stay compatible, the interface if_oo_adt_classrun
was not changed. Nevertheless, if_demo_output
can also be used for the ABAP console; Instead of implementing if_oo_adt_classrun
in your class, you can inherit from the new abstract class cl_demo_classrun
and redefine its method main
. In cl_demo_classrun
you have access to an intance attribute out
of type if_demo_output
and thus you can use all methods of cl_demo_output
. cl_demo_classrun
and if_demo_output
are released for ABAP Cloud with 2311/2023.
Most example programs of the ABAP Keyword Documentation have been switched to classes following that pattern and thus were made executable by F9:
The console output is better than nothing. But note, that the examples of the documentation can also be executed from the documentation display in ADT resulting in an HTML output (also note the new documentation design):
(Maybe it is also time for a generally available ABAP HTML console in ADT?)
Last but not least: SE80/SE24-users might ask how to run the new documentation examples from good old class builder. Well, SE80/SE24 was also connected to cl_demo_classrun
(but not to if_oo_adt_classrun
). Simply press F8 and you get the HTML-output in one go:
And there is also an executable program ABAP_DOCU_DEMO_CLASSRUN for calling the main method of such demo classes.
If you find any errors or miss anything, feel free contact us under [email protected] (Yes, it’s the ABAP F1 Help team that makes all this possible).