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

603

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.



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 Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


ABAP - Type Casting

Category - ABAP

How do you actually get the original type of a class or instance if it is passed in a generic table? In this article we examine the possibilities.

04/16/2024

ABAP - RETURN value

Category - ABAP

After all these years, the “real” return in ABAP has finally arrived. In this article we will show you how it works and what it can do.

02/13/2024

ABAP Deep Dive - FOR (Loops)

Category - ABAP

Let's take a closer look at the FOR loop. How does it work? What do I have to consider and what can I do with it?

04/14/2023

ABAP Deep Dive - Table access (internal)

Category - ABAP

In this article, let's take a look at table access to internal tables and how they replace READ TABLE.

02/03/2023

ABAP Developer still relevant

Category - ABAP

In this article we look at whether ChatGPT can already replace an ABAP developer or whether it can be used as a help in everyday life.

01/06/2023