Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
horst_keller
Product and Topic Expert
Product and Topic Expert
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. Meanwhile, 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_outputcl_demo_classrun and if_demo_outputare 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 to contact us under F1_Help@sap.com (yes, it's the ABAP F1 Help team that makes all this possible).
14 Comments
shais
Participant

Sounds great.

 

It seems that all the images are broken (refers to the inaccessible sap.stackenterprise.co)

horst_keller
Product and Topic Expert
Product and Topic Expert

Ouch! Thanks for notifying, now they should be properly implemented.

shais
Participant
Indeed!
Frank1
Participant
0 Kudos

That’s pretty cool for those output. By the way, it seems rarely use those in productive product or project for SAP S/4HANA cloud public edition and private edition, right?

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos
Right, it is not for productive usage. Only for demos and test programs. Just a console.
fwe1
Explorer

Hi,

thank you very much! The console output and the console interface are often underestimated in my opinion. To format output is one important aspect. Most web developers (me included) appreciate the rich interaction of the developer console within the chrome browser. That development tool is so powerful and helpful. I wish I had something similar for ABAP. At least, a minor console API (like this one https://developer.mozilla.org/en-US/docs/Web/API/console) would be awesome. I love the table / list and group formatted output features.

That video is a nice demonstration how helpful a dev console could be 🙂

https://developer.chrome.com/docs/devtools/console/

I am curious how the whole ADT evolves in the future.

All the best

Former Member
Very nice, thanks!

As for your question:

Maybe it is also time for a generally available ABAP HTML console in ADT?

Definitely YES !!!
0 Kudos
Hey ABAP Console Reloaded! 👋 We're absolutely thrilled to support your incredible work. Your dedication to innovation is truly inspiring. Keep rocking that ABAP world! 🚀💻 #ABAPConsoleReloaded #InnovationMasters
ChristianGünter
Contributor

Nice!

It would be also very nice if there was a way to clear the console programmatically.

Something like

out->clear( ).

or

cl_demo_output=>clear( ).

AFAIK there isn't?

P.S. Asking for a friend dominik.bigl2  😉

horst_keller
Product and Topic Expert
Product and Topic Expert
Hi Christian,

That demand is well known and we are discussing it already.

The problem is a bit how to achieve it.

Technically, at F9 the ADT backend calls the MAIN method of the class implementing IF_OO_ADT_CLASSRUN. During its execution, the output is collected and after returning from the method, the output is retrieved with GET. (It is just a frame that does the same as you would do it when working with CL_DEMO_OUTPUT directly). Only then it is sent from the ADT backend to the frontend.

I don't see a simple way, how to interact during the method execution from backend to ADT frontend to clear the console output. But we will look into that further.

Best,

Horst

 

 

 
ChristianGünter
Contributor
0 Kudos
Great, thank you very much for your fast response.
Jelena
Active Contributor
0 Kudos
Thank you for sharing! cl_demo_output is awesome sauce for quick output. Once you realize you can just give it any random internal table, you'll never go back to WRITE. 🙂
mryenthanh92
Participant
0 Kudos
As I understand the result was processed in ABAP Server and send back to eclipse to show in console.

So that means no luck for INPUT arguments, right?

Wanna use it for exercises like good old Pascal days
horst_keller
Product and Topic Expert
Product and Topic Expert
For input capabilities we need an HTML console.

As a POC, the demos of the ABAP Keyword Documentation reuse the browser of the documentation window and there CL_DEMO_INPUT works. It also works in SAP GUI. But as long as the ABAP console is implemented in text-only style in ADT, no input is possible.