This is a test message to test the length of the message box.
Login
|
Structuring a report
Created by Software-Heroes

ABAP - Structuring a report

1339

What's next after the virtual end of the form? How should you build a report, what should be considered and what is there for useful things. More you can read in this article.

Advertising


In the last article, we looked at the ways in which we implement classes in the report and thus get away from the now obsolete forms. Today we want to show you, what else you can do to change the structure to generate clean and clear code.

 

Classes

When implementing the class, you will first be faced with the question of how should the class be implemented. Do you want to create them locally or globally? Should it be static, work with an instance or singleton principle?

Of course, each of these implementations has its own pros and cons, and you should be aware of this when choosing the appropriate implementation method.

  1. If you are thinking that you would like to use the class again or if it is so static that it only fits this one case, then create a local class directly in the program.
  2. If you want to reuse the class and use it slightly modified in other reports, then use a non-final global class.
  3. With a local class you can decide according to your own taste. If you want an instance, then create the class as an instance during initialization or during the load-of-program.

 

Structure

When creating a new report, a good structure is the first part of the goal. The clarity and navigation in the report is also important for your colleagues, who later have to take over or maintain the report.

Therefore, at the very beginning, you should think about how you want to structure your reports in general. We therefore want to give you a suggestion.

 
Entry

Immediately after entering the program you should offer direct navigation options. The whole thing with the example of a static/local class.


*----------------------------------------------------------------------*
*--- Includes
*----------------------------------------------------------------------*
INCLUDE:
  ztest_01_top,
  ztest_01_sel,
  ztest_01_c01.

*----------------------------------------------------------------------*
*--- ABAP Events
*----------------------------------------------------------------------*
INITIALIZATION.
  lcl_prog=>init_program( ).

AT SELECTION-SCREEN OUTPUT.
  lcl_prog=>pbo_1000( ).

AT SELECTION-SCREEN.
  lcl_prog=>ucomm( sscrfields-ucomm ).

END-OF-SELECTION.
  lcl_prog=>start( ).

In the example shown, the program starts with the includes of the report, everything that belongs to data and further definitions for the report. This is followed by the report events of the individual processing steps. In each include and each method of events, you can jump with a forward navigation and view the code directly.

 

Includes

The includes ensure a neat structuring of the program and the individual components.

  • The TOP include (_TOP) defines the program header and the message class. Furthermore, all global variables and types are defined. Normally, however, only the reference to the screen fields (sccrfields) is required, which passes the user command (see example above).
  • In the selection include (_SEL) are all the selection screens that are required for the report.
  • In the class include (_Cxx) all class definitions and implementations of a class are used to separate the resources from the rest of the program.
  • Furthermore, there could be a form include (_Fxx), which is actually only used for module routines of dynpros.

 

Selection screen

When transferring the data from the selection screen to the class, there are two basic concepts:

  • You use the global parameters and select options directly in the class and access them as if they were external data sources.
  • You pass the parameters directly to the processing routine at the start of the process.

 

The second case would actually be the cleanest, but also the most time-consuming, since you would have to typify the individual select options in the input.

 

Data management

The global data in a program would disappear for the most part, but this is not always possible because certain values need to be kept global. Here are some examples:

  • Screenfields for passing the user command to the method for evaluation
  • Auxiliary fields for select options of the selection screen
  • Global tables for screens for data storage and processing
  • Global typifications

 

All other values would migrate into the class, since the processing also takes place here. Thus, for example ...

  • Constants
  • Data
  • Typifications

... all in the class.

How exactly the individual class is implemented is up to you as a developer and should be carefully thought out, whether this fits your concept and whether this is also easily expandable and maintainable.

 

Conclusion

This should just be an example of structuring a report and is not an obligation for you. Maybe we could use the concept to bring you something new ideas and approaches that you can now incorporate into your daily work.


Included topics:
New ABAPReportFORM
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Tuesday and Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


ABAP - XCO Logging

Category - ABAP

The XCO classes are part of the ABAP Cloud APIs and offer numerous functions that aren't always easy to understand. In this article, we'll take a detailed look at the logging object.

12/16/2025

ABAP - The right Key

Category - ABAP

What about the use of internal tables? Is it still just TYPE TABLE in ABAP, and the table is fully defined?

11/14/2025

ABAP - XCO Regular Expressions

Category - ABAP

Let's take a look at the XCO classes for regular expressions and how you can easily use them to execute REGEX against text and input in ABAP Cloud. We'll also compare them with classic ABAP.

11/07/2025

ABAP - Escape

Category - ABAP

In this article, let's take a closer look at different escape variants that you need for ABAP development and system security.

10/07/2025

ABAP - Date and Time

Category - ABAP

In this article, let's take a closer look at the data types for dates and times in ABAP. Have any changes been made between the various releases, and what should you still use today?

10/03/2025