Programming ABAP Reports
Programming ABAP Reports
Reporting Tool
- SAP Query
Retrieving Data
- Logical Database: global data retrieval programs. They provide database access, selection screen, and
perform authorization checks.
- Modularization Units
1. SAP Query
2. InfoSet Query
3. Quick Viewer
- Custom development
A reporting system, into which data is extracted from one or mre transactional systems. Non ABAP
written queries are used to create reports withing SAP BW system using a variety of specific tools.
Logical Databases
If you choose custom development (of reports) as your solution, check if you can use a logical database
to retrieve the data you need.
Standard Reports
Purpose: Provides solutions for the most common reporting requirements
Advantages:
1. Immediately usable
2. No development effort
Limitations:
1. Limited flexibility
InfoSet Query
Purpose:
1. Easy to use general SAP reporting tool for creating your own reports
Advantages:
2. Is easy to operate
3. No programming
Limitations:
1. You first need to define InfoSets and user groups in SAP Query
SAP Query
Purpose:
Advantages:
1. Flexible
2. No programming
6. Allows you to define a basic list and multiple statistics and ranked lists for each query
Limitations:
Purpose:
Advantages:
Limitations:
2. Involves the risk of programming issues, such as poor runtime, incorrect data retrieval, or incorrect
data interpretation.
Output formats for displaying report results (implement customer-defined interactive functions):
ALV: an output format to display mass data as a table or tree. It provides a range of standard functions,
making it a better alternative to the classic list. You can choose from two programming models:
Classic ABAP List: allows you to create lists with interactive functions. Does not meet accessibility
requirements.
Accessibility: the availability of information and the suitability of software for people with disabilities.
Include Programs:
Can be nested.
Naming convention:
List Generation
Selection Screens
Speical screens, which are generated by the system based on ABAP statements.
Use the decalrative statements PARAMETERS AND SELECT-OPTIONS to generate a standard selection
screen (screen 1000) with input fields.
Create variants to save selection screen values that you use frequently. If a report with a selection
screen runs in the background, a variant is always required.
Additions to the PARAMETER statement
OBLIGATORY addition: declare mandatory fields, which users cannot proceed without entering values in
these fields.
AS CHECKBOX addition
SAP Memory
A user-specific memory area in which simple data values are stored for SET/GET parameters.
The data values are stored for the duaration of a user session.
SET/GET parameters
Can be assigned to a data element. Fields based on this data element can then use the SAP Memory
mechanism.
SELECT-OPTIONS
Allows the use of a value range and complex selections instead of single input field.
Generate an internal table (the selection table) with a stadnard structure and a header line.
- Option (EQ, NE, LE, LT, GE, GT, BT, NB,CP, NP)
- Low
- High
The system automatically fills the internal table if a user enters data.
If no values are entered into the SELECT-OPTION, the system returns all rows from the database.
- NO-EXTENSION
- NO INTERVALS
NODES statement
Only processed once, before the selection screen is displayed for the first time
Appropriate for a dynamic preassignment of the input fields. You can assign default values for the
selection screen fields of a report or a logical database during this event.
You can provide values for the selection screen in this event. However, this event may be processed
multiple times.
SELECTION-SCREEN
BEGIN OF BLOCK addition: group logically related screen elements and WITH FRAME to frame them. You
can nest frames up to five levels.
BEGIN OF LINE addition: display multiple parameters and comments in the same output line.
The COMMENT addition: inclue text in the line. Comment texts must always have a format (position and
output length).
The standard selection screen always has the number 1000. Additional selection screens should have a
number higher than 1000.
If the user performs any action on the called selection screen, the AT SELECTION-SCREEN event is
processed. In this event, the sy-dynnr system field contains the number of the called selection screen.
- <left_col> and <upper_row> are the coordinates of the top-left corner of the screen
Tabstrips:
Define selection screens as subscreens, and then include them on other screens as tabs.
The definition of a subscreen area for a tabstrip on a selection screen begins with: SELECTION-SCREEN
BEGIN OF TABBED BLOCK
A structure is automatically created for every tabstrip block, which has the same name as the tabstrip
block. It contains the prog, dynnr, and activetab fileds.
AT SELECTION-SCREEN event
The ON addition: refer to specific selections. If an error occurs, only these fields become ready for input
again (ON <f>, ON <seltab>, ON RADIOBUTTON GROUP <grp>, ON BLOCK <block>).
F1 help (field help): AT SELECTION-SCREEN ON HELP-REQUEST FOR
Variants:
Variants are uniquely assigned to one program, and are not available in other programs. A user can
create any number of selection screen variants for a program.
If the program uses several selection screens, a variant can be created for all selection screens, or
individually for each selection screen.
You need to specify a name and a user command for the button.
You need to maintain the text that is to appear on the button separately during INITIALIZATION.
You can also use the ICON_CREATE function module to generate a text and an icon.
If the user chooses the button, the system triggers the user command assigned to it and places the user
command in the sscrfields-ucomm field at the begining of the AT SELECTION-SCREEN event. You need to
include the TABLES sscrfields statement in your program to be able to access this field.
For standard screen programming, the process logic can be implemented at the following event for each
screen:
Process Before Output (PBO): Immediately before the screen is displayed. For selection screens is
equivalent to AT SELECTION-SCREEN OUTPUT
Process After Input (PAI): Immediately after the screen has been displayed. For selection screens is
equivalent to AT SELECTION-SCREEN.
You control the fields using the name of the field or the group name.
To change whether a field is ready for input: assign 0 or 1 to the SCREEN-INPUT field.
You can address these screen fields in LOOP AT SCREEN....ENDLOOP using their names.
To ensure that you do not need to address each field individually, you can combine selections into
modification groups.
ALV
- Toolbar
- List Header
- Data Area
ABAP processor
SAP GUI Services: manage windows and their dialog box levels, data transfer, and so on.
Controls:
You can integrate on or more controls into your user dialogs and use the functions they make available.
An area is reserved on the screen to display a control. A container control is placed in this area. The ALV
Grid is then linked to the container and is displayed in the reserved screen area (Control Area ⬅️
Container Control ⬅️SAP Control).
You cannot program ABAP directly in the flow logic. Instead, you encapsulate ABAP commands in
modules.
Modules called during PBO are defined by the MODULE <module_name> OUTPUT statement.
Modules called during PAI are defined using the MODULE <module_name> INPUT statement.
GUI Status
Made of:
- Menu bar
- Standard toolbar
- Application toolbar
Status types:
- Normal screen
- Dialog box
- Context menu
GUI Title
LEAVE TO SCREEN 0 command: return to the point where the screen was called.
Creating Instances
CREAT OBJECT statement: create an instance of the class for which the object reference variable has
been assigned a type.
- If a class has a method with the name CONSTRUCTOR, it is automatically executed when the instance
is created.
CL_GUI_CUSTOM_CONTAINER
IMPORTING parameter container_name of the CONSTRUCTOR method: transfer the name of the area
reserved for the control on the screen.
Avoidance of multiple generation of contrrols: ensure that an instance is generated only the first time
the dynpro is called. You can stop unwanted instances from being created by checking that the
container reference is initial, before creating the object.
ALV Grid
Creating an instance of the ALV Grid after the container control instance is created and before the SAP
GUI windows is sent to the presentation server.
- SET_TABLE_FOR_FIRST_DISPLAY method: used to pass the list data, field catalog, and other
additional information.
- it_outtab parameter (obligatory): used to pass the list data that you want to display.
- i_structure _name parameter: used to pass the name of a global structure type from the ABAP
Dictionary. The representative instance automatically generates the corresponding field catalog.
- is_variants and i_save parameters: set the configuration options of the layout variants for the user.
- i_default parameter: set an existing layout variant as the initial variant. When saving a layout
variant, you can define it as the default variant if this parameter has the value X (the default value).
- is_layout and is_print parameters: pass default settings for the appearance of the ALV and print list
output
- it_special_groups parameter: pass the names of field groups defined in the field catalog.
- it_toolbar_excluding parameter: pass the names of the standard functions of the toolbar that are to
be hidden (deactivated).
- it_fieldcatalog parameter: pass a corresponding internal table to change the automatically created
field catalog or create it yourself.
- it_filter and it_sort parameters: pass default settings for filtering and sorting the data to be
displayed.
- REFRESH_TABLE_DISPLAY method: prompt the representative instance to send the list data and the
additional information to the instance on the presentation server again.
- i_soft_refresh parameter: specify if the current filter and sort criteria are kept and applied (assign
the value " ") or the current filter and sort criteria are kept but not applied (assign the value X).
- is_stable parameter: pass the corresponding filled structure to specify the condition that scroll
positions for rows or columns are retained when refreshing (row and col fields of a structure of the
lvc_s_stbl).
- SET_USER_COMMAND method: allow you to replace the standard functions of the ALV grid control
with your functions.
- GET_CURRENT_CELL method: returns the coordinates of and value of the current cell (current
position).
- GET_SELECTED_CELLS method: returns the coordinates of and values of the selected cells.
Releasing of Instances
FREE <object_name> instance method: explicitly release the resources. Every control wrapper has this
free method (inherited from CL_GUI_OBJECT).
CLEAR and FREE statements: releasing the object references, ensuring that the resources for ABAP
objects instance created in the program are released in memory the next time the garbage collector
runs.
Additional Information
Global data objects defined in the calling program that can be filled with additional information and
then passed to the representative instance.
Layout Info:
Data Info:
Normally, you do not create the filter and sort criteria in the program, because the user can change the
criteria interactively.
- Change (default)
is_variant = space
i_save = space
i_save = space
is_variant = <st_name>
To create or change standard layouts or to set them as the default setting, users require an
authorization for the authorization object S_ALV_LAYO with ACTVT value 23.]
disvariant structure
Steps:
- grid_title
- zebra
- cwidth_opt
- sel_mode
- excp_fname
- excp_led
Sort Criteria
- You can insert the fields in the required sequence in the internal table of sort criteria.
- To sort data using sort criteria, enter the column name in the fieldname field.
- Enter X in the up field if you wish to sort the entries in ascending order.
- If you want to sort the entries in descending order, enter X in the down field.
Pass the internal table to the it_sort parameter of the SET_TABLE_FOR_FIRST_DISPLAY method.
Line Colors
Steps:
1. Add an extra field to your data table that contains a code representing the color of the line. This is a
character field with length 4.
2. Add the field at the end of the line type of your internal table.
3. In the info_fname field, enter the component name of your color column for a strucutre of the
LVC_S_LAYO global type.
- Letter 'C'
- intensified display: 1 or 0
- Invers: 1 or 0
Steps:
1. Add an internal table of LVC_T_SCOL type to the line type of the output data table.
2. Fill the fileds fname (name of the field to be colored) and color (structure made of the col, int, and
inv components) of the internal table.
3. Loop through the internal table and write the work area back into the internal data table using the
MODIFY command.
4. Assign the name of the field color table to the field ctab_name of the layout structure.
INCLUDE TYPE statement: used to include Dictionary types, ABAP types, and self-defined types, directly.
FORMAT Command
Function Codes
The possible function codes are defined as constants of the CL_GUI_ALV_GRID class.
- MC_FC prefix constant (The constants for function codes have this constant)
- MC_FC_PRINT_BACK
- MC_FC_DETAIL
- FC_MB_SUM
You can display only a subset of the standard functions or hide the entire toolbar.
To hide individual functions, define an internal table with the ui_function line type. Fill the internal table
with the name of the functions that you need to keep inactive (not displayed).
To hide the entire toolbar, set the no_toolbar parameter of the layout structure to X.
Field Catalog
You can pass the display information to the representative instance using an additional internal table.
This additional table is called the field catalog. The global data type of this internal table is LVC_T_FCAT.
The corresponding structure type (for the work area) is called LVC_S_FCAT.
The field catalog must contain a row for every column of the data table that differs from an underlying
ABAP Dictionary structure or a row for every column that is not in the ABAP Dictionary structure at all.
This row must contain the technical properties and other formatting information for the column.
- All fields of a global structure exist in the data table with the same names, however, adjustments are
to be made to the specifications from the ABAP Dictionary, additional columns are to be output, or both.
In this case, create rows in the field catalog for the columns to be changed or added.
- The row type of the data table does not contain any reference to the ABAP Dictionary, individual
global structure fields, or data elements. In this case, you need to create the field catalog completely in
the calling program.
There is a situation when a field catalog may not be required; when all fields of a global structure type
exist in the data table with the same names. These fields should also be the output. In this case, you can
have the field catalog generated automatically by the representative instance. You only need to pass the
name of the global structure type to the parameter i_structure_name of method
SET_TABLE_FOR_FIRST_DISPLAY. Columns of the data table that are defined in the global structure type
are displayed.
Every column of the data table that you want to format must have a corresponding row in the field
catalog.
- Assign the name of a column from the data table to the fieldname field. This field assigns a row in the
field catalog to a column of the data table.
- Fill the fields of the work area for each affected column of your data table and add it to the internal
table for the field catalog.
Performing a consistency check: press the SHIFT key and double-click with the right mouse button in an
area of the ALV grid that contains no data
Used for the communication for all control in the same way.
Uses special services in the SAP GUI and the runtime system on the application server. These services
are the automation controller on the presentation server and the CFW service on the application server.
GUI Controls
Every GUI control that communicates with an application program represents an object, which is an
instance of a class, on the presentation server. The communication with the instances uses the method
calls and events of the objects.
There are representative classes (proxy classes) for all GUI controls in the class library. These are
referred to as control wrappers.
The communication between the ABAP program and a GUI control is performed as follows:
- The ABAP program communicates with the representative object only (method calls, operations on
the attributes). The representative object performs the associated operations on the presentation server
instances using the CFW.
- Actions performed on the presentation server control are forwarded to the representative object,
using the CFW. The representative object then communicates with the ABAP program.
To pass an event to a presentation server control, the following partner levels are involved:
- SAP GUI/Automation Controller: receives the event triggered by the presentation server control and
forwards the information about the event to the basis services
- Basis Services: forward the information to the representative object in the ABAP program.
- Representative Object: triggers an ABAP Objects event, informing the instances registered for the
event. These instances then handle the event with an appropriate method also known as a handler
method.
An Object
- Can trigger identified events (provided by the associated class for representative objects of the
control).
Basis Services
- DOUBLE_CLICK: triggered after a double-click with the mouse. If a column has been identified as a
hotspot, and the user presses the mouse button in the hotspot column of the data area, the
HOTSPOT_CLICK event is triggered in the calling program.
- TOOLBAR: triggered when the ALV grid control is created (during the SET_TABLE_FOR_FIRST_DISPLAY
method) or refreshed (during the REFRESH_TABLE_DISPLAY method), but can also be triggered explicitly
with the SET_TOOLAR_INTERACTIVE method. It allows you to change the composition of the toolbar.
Every event has an implicit parameter, called sender, which you can also receive by listing it in the
IMPORTING addition. This parameter allows handlers of instance events to access the instance that
triggered the event.
Handler Methods
To create a handler method for an event, first define a local class. The local class requires a public
method that is defined as a handler method for a particular event of a certain class.
The signature of an event handler method can only contain IMPORTING parameters. These parameters
are defined within the corresponding event.
The event handler method does not need to import all the parameters passed in the RAISE EVENT
statement.
IMPORTING <parameters>
The SET HANDLER statement links handler methods with the event triggers.
By default, an event hanlder is not processed when an event occurs. The event hanlder is only called if
you register the event at runtime.
Simple Syntax for Selecting Set of Columns of a Database Table and Storing the Results into
Corresponding Fields:
FROM <table_name>
If the user chooses an element of the menu button or menu type, the representative instance triggers
the MENU_BUTTON event. This has a parameter E_OBJECT with type REF TO CL_CTMENU. To add a
menu to the toolbar, you must also implement a handler method in which you create the menu in the
same way as a context menu.
If the user chooses a function element that has been added to the standard toolbar, the representative
instance triggers the USER_COMMAND event. This event contains the function code as its E_UCOMM
export parameter.
For each field to be displayed as button, create an entry in the internal table, in which you assign the
name of the field to the fieldname component and the constant
CL_GUI_ALV_GIRD=>MC_STYLE_BUTTON to the style component.
The name of the internal table that contains the information about the buttons is specified in the
stylefname component of the layout strucuture.
BUTTON_CLICK Event
The event returns the number of the row and name of the column in which the button was clicked.
By using print list events you can implement the same logical process steps as used in the classic ABAP
list layout.
You can use the SUBTOTAL_TEXT event to define additional texts for subtotals across columns whose
output has been suppressed.
You must set an indicator in the print structure to ensure that the user can format the control level
change in the print list. This print structure is controlled by the GRPCHGEDIT field of the IS_PRINT
transfer parameter, which is the LVC_S_PRNT structure type.
Context Menus
A context menu is displayed if a user presses the right mouse button (or Shift + F10) and the mouse
pointer is positioned over a GUI control.
When a user presses the right mouse button, the ALV grid control triggers the
CONTEXT_MENU_REQUEST event.
If the user selects a function from the context menu, the ALV grid control triggers the USER_COMMAND
event.
By default, the ALV grid control has a context menu that you can replace or extend.
- Enter the required function codes and their texts in the Menu Painter.
- To create a submenu, enter text but no code for a line in the Menu Painter (maximum of three
levels).
- To load the GUI status into the context menu, use the static method LOAD_GUI_STATUS (parameters:
program, status, disable, menu) of class CL_CTMENU.
- You can extend the context menu that you loaded, using the ADD_FUNCTION method of the
CL_CTMENU class.
-----------------
Retrieving Data
-----------------
Logical Databases
A logical database is an ABAP program that reads data from the database and passes it to other
programs.
The use of a logical database provides an alternative to programming your own database access.
Logical databases also provide a security advantage because they perform all the authorization checks in
the logical database program instead of in the report.
There are more than 250 logical databases in SAP ERP systems.
- Use the NODES <nodes> statement (recommended more than TABLES keyword) to specify the nodes
of the logical database that you want to use, it creates a structure corresponding to the node type.
- When the logical database reads the data records, it uses the PUT <node> keywod that triggers the
GET <node> event in the report program.
Nodes
The structure determines the hierarchy and the read sequence of the data records (the sequence in
which the GET events are processed).
Nodes types:
1. Table (T type): table or strucutre from the ABAP Dictionary. Name must be identical to the node
name.
2. ABAP Dictionary (DDIC) (S type): table or structure. Name can be different from the node name;
deep structures are possible.
3. Complex types from Type Groups (C type): type that has been defined in a type group.
START-OF-SELECTION: triggered when an executable program is run before control is transferred to the
read routine of the logical database.
END-OF-SELECTION: triggered after all GET events are processed (after all data records are read and
processed).
GET <node>: triggered when the logical database supplies data for this node. Each GET event block can
be processed several times, depending on how many records are supplied by the logical database.
GET <node> LATE: triggered when all subordinate nodes of the current node have been processed,
before the data is read for the next node (when a hierarchy level is completed).
STOP keyword: terminates the program processing. The END-OF-SELECTION processing block is
executed first, if it exists.
EXIT statement: exits the program immediately, without executing the END-OF-SELECTION event. The
list that has been generated so far is displayed.
REJECT statement: this data record is not processed further. When reading the next data record,
processing continues at the same hierarchy level.
Logical database programs have the DB<name>SEL include program, in which the selection screen of the
logical database is defined.
The FOR NODE addition (to PARAMETERS and SELECT-OPTIONS statements): assigns selections to
individual nodes.
If the SELECTION-SCREEN FIELD SELECTION FOR TABLE <node> statement: field selection is possible for
these nodes. This means that the application program can use the GET <node> FIELD <field list>
statement to restrict the amount of data retrieved.
Some logical databases provide dynamic selections for certain nodes using the DYNAMIC SELECTIONS
FOR <node> addition. If this is the case, the Dynamic Selections button appears on the selection screen
of your report to restrict the data retrieval further. You can determine the selection fields to be
displayed by using a Selection View.
Some large logical databases have multiple selection screen versions. You specify the selection screen
that you need to display by entering the version number of the selection screen in the program
attributes.
Selection Views
Determines which fields are displayed on the selection screen for nodes with dynamic selections.
Provided by SAP (of type SAP), or can be defined by the customer (type CUS).
- Assign the individual fields of a node to a field group by assigning the number of the relevant field
group to the field. You can also define whether these fields need to be immediately available when the
users want to work with dynamic selections.
There are other subroutines that are processed at the Process Before Output (PBO) and Process After
Input (PAI) events of the selection screen. Checks are performed during the PAI event.
The database accesses are programmed in the put_<node> subroutines. This subroutines can be
processed several times.
When a program which uses a logical database is started, control is initially passed to the database
program of the logical database. Each event has a corresponding subroutine in the database program,
for example, init subroutine in a logical database for the INITIALIZATION event.
During the interaction between the logical database and the associated report, first the subroutine is
processed and then the corresponding event block in the report (if it has been coded).
Logical database programs read data from the database according to the structure declared in the
logical database.
The logical database reads the data in the put_<node> subroutines. During the PUT event, control is
passed from the database program to the GET event of the associated report.
Data is made available in the corresponding work areas in the report. The processing block defined for
the GET event is executed.
Control then returns to the logical database. The next relevant subroutine will then be processed.
Data that is to be output in a list or ALV can be read from the database using:
Open SQL: a platform-independent SQL variant used in ABAP. Open SQL statements are translated into
the relevant Native SQL by the database interface.
Native SQL statements: for portability reasons, it is best to avoid Native SQL restrictions or
requirements.
Open SQL
Open SQL is not database-specific and ensures that your program is independent of the database
engine.
Open SQL allows portability between different RDBMS systems and allows your the change to a different
database system, without the need to change the code.
ABAP Open SQL is completely integrated into the ABAP Workbench, which has integrated syntax checks
for Open SQL syntax.
ABAP Open SQL also makes it possible to use the SAP table buffers, where buffering has been activated
for a particular table.
Native SQL
ENDEXEC.
Native SQL must not be used to change data in the SAP database.
If you need to use Native SQL, put the code in an INCLUDE so that it can be modified easily if your
RDBMS changes and restrict your Native SQL to Standard SQL.
Keep data transfer between the database server and the application server to a minimum.
Views
Inner Join
Outer Join
Join conditions are not limited to key fields. They can be declared using any fields for which a foreign key
relationship is defined, or in certain cases, between fields that have the same domain.
Use a LEFT OUTER JOIN statement when data from the table on the left is needed even if there are no
corresponding entries in the table on the right.
Initially, data is fetched from the first database table and collected in an internal table. You must then
evaluate the value of SY-SUBRC, to check whether the initial SELECT returned any data. If data was
retrieved, the SELECT...FOR ALL ENTRIES can then be used to retrieve data from a second database
table, based on the entries in the first internal table.
It is recommended that you use the FOR ALL ENTRIES addition when the first set of data is not being
read from the database and is already available in the program, for example, if the user has input the
data. Otherwise, a join is recommended.
DELETE ADJACENT DUPLICATES: remove duplicate entries from the internal table.
SELECT statement
SELECT <fields>
FROM <source>
INTO <target>
[WHERE <condition>]
[GROUP BY <fields>]
[HAVING <grouping_condition>]
[ORDER BY <sort_key>]
Aggregate Functions
DISTINCT addition: prevents values from occurring more than once in the result set.
GROUP BY
Combines rows that have the same value combinations for the columns specified, into a single row in
the result set.
Columns with the STRING and RAWSTRING data types cannot be used in the GROUP BY clause.
You cannot use the GROUP BY clause when selecting from a pool or cluster table.
Data types of the returned value from aggregate functions (ensure the target variable has an
appropriate type):
- MAX, MIN, and SUM: the data type of the corresponding colun in the ABAP Dictionary.
When any aggregate expression is used, the GROUP BY clause must include all other columns that are
selected, except for those in the aggregate expression.
HAVING Addition
Restricts the number of groups of combined results in the result set by using a logical expression for
these rows.
May only contain columns that also occur in the GROUP BY clause.
The condition of HAVING clause may contain aggregate functions for any columns of the database table
listed in the column list after SELECT.
ORDER BY
Sorts the result set on the basis of the contents of the entered columns.
For all columns not listed after ORDER BY, the order in the result set is undefined, and can be different if
the same SELECT statement is executed more than once.
ORDER BY PRIMARY KEY addition: the result set can be sorted by primary key in ascending order.
The result set can be sorted by any combination of selected columns. The column can be entered
direclty using the column indicators or using the alternative column name. The alternative column
names are necessary, if you want to sort by columns that are specified as aggregate expressions.
The system sorts in ascending order as default, if niether of ASCENDING and DESCENDING additions is
specified.
The priority of of the sorting follows the order in which the columns are specified.
The SELECT statement baypasss the SAP buffer in all cases except for ORDER BY PRIMARY KEY.
For performance reasons, only perform a sort in the database system if the sorting is supported by an
index.
---------------------------------------------------
---------------------------------------------------
You can call an ABAP program from another running ABAP program in the following ways:
Interrupt the current program to run the new program: The called program is executed, and processing
then returns to the calling program.
Synchronous Calling
Complete ABAP programs in a single user session can only run sequentially.
SUBMIT Statement
VIA SELECTION-SCREEN addition: the system displays the standard selection screen of the program (if
one has been defined).
AND RETURN addition: the system resumes processing at the first statement after the SUBMIT
statement, as soon as the called program is complete.
Allows you to insert an ABAP program with a transaction code into the call chain.
USING <gt_bdcdata> addition: execute the transaction using values from the internal table in the screen
fields. The internal table must have line type BDCDATA and it must be filled in the program before the
CALL TRANSACTION statement.
MESSAGES INTO <gt_messages> addition: specify an internal table in which all system messages are
written. The internal table must have line type BDCMSGCOLL.
LEAVE PROGRAM statement: terminates an ABAP program. If the statement occurs in a program that
you called using CALL TRANSACTION or SUBMIT <program_name> AND RETURN, the system resumes
processing at the next statement after the call in the calling program.
AND SKIP FIRST SCREEN addtion to the CALL TRANSACTION statement or LEAVE TO TRANSACTION
statement: prevent the system from displaying the contents of the first transaction screen. The system
still processes the flow logic.
UPDATE addition: specify the update technique that the program should use, if you start a transaction
with CALL TRANSACTION that uses update techniques. This technique can be asynchronous (default),
synchronous, or local.
CALL TRANSACTION <t_code> or SUBMIT <program> AND RETURN opens a new internal session that
creates a new program context. The internal sessions of an external session create a memory stack. The
new session is placed at the top of the stack.
At the end of the execution of a program, the internal session that is at the top of the stack is removed,
and the system continues processing the calling program (same for explicit LEAVE PROGRAM
statement).
LEAVE TO TRANSACTION removes all internal sessions from the stack, and opens a new internal session
that contains the program context of the calling program. After the program call, the ABAP memory is
reset. All the data in the ABAP memory is removed after the call.
SUBMIT <program> replaces the internal session of the program. This program performs the call with
the internal session of the program that the system calls. This action is according to the program code
written by the programmer. The new internal session contains the program context of the called
program.
The function group needs to be loaded in every internal session used. If a new internal session calls a
function, the called function group needs to be loaded in the new internal session
Ways to pass data to programs that run in separate internal sessions, which are as follows:
ABAP memory
SAP memory
Database tables
CL_GUI_FRONTEND_SERVICES
If you call an ABAP program with a standard selection screen, you can pass data for the input fields in
the call:
Create an internal table with the columns SIGN, OPTION, LOW, and HIGH using: DATA <data_object>
TYPE | LIKE RANGE OF.
Fill the table with the multiple selections and pass it to the executable program using the WITH
<sel_opt> IN <data_object> statement.
SAP Memory
A user-specific memory area for storing field values that relate to parameter IDs.
It is only suitable for passing data between internal sessions to a limited extent.
Values in SAP memory are retained for the duration of a user session.
The SAP memory can be used between different sessions of the same user session.
You can use the contents of the SAP memory as default values for screen fields
- Directly fill the memory area using the SET PARAMETER ID '<par_id>' FIELD <var> statement and read
from the memory using the GET PARAMETER ID '<par_id>' FIELD <var> statement.
ABAP Memory
User-specific.
The system cannot share the ABAP memory with other external sessions.
If the user ends an external session, the associated ABAP memory is automatically released.
EXPORT Statement
The data cluster stores ABAP variables with their current values in ABAP memory.
Another EXPORT… TO MEMORY statement for the same data cluster overwrites the old cluster.
IMPORT Statement
Copy data from the ABAP memory to the corresponding fields of your ABAP program.
---------------------------
Backgrounds Processing
---------------------------
Backgrounds Processing
Background execution takes place without user dialogs in special background work processes. This
allows parallel processing and ensures that dialog work processes remain free for foreground
processing.
1. When a program processes large datasets, the program may have a long runtime.
Job
Job Wizard
Job Status
Job Step
Job Selection
Job Log
Spool
Variants
Container Object: doesn't work in the background. If you try to instantiate a container control in the
nackground, an exception occurs. When an ALV is called in the background, a print list (Classic ALV) is
generated.
Checked to ensure that you do not exectue the CREATE OBJECT statement in case of instantiating a
container control in the background.
Will have the value 'X' if a program is run in the background, and space if not.
--------------------------
--------------------------
Calling Methods
When working with the ALV object model, you must, first. generate an instance of the class
CL_SALV_TABLE.
Each of the ALV properties or subobjects is itself represented by another ABAP class.
All of the class names start CL_SALV_*. If the name is plural, it refers to the properties of a group of ALV
Elements. If the name is singular, it relates to the properties of a single element.
CL_SALV_TABLE
Has GET methods for each property of ALV, which can be used to fetch the appropriate object.
FACTORY method
A static method.
Instantiates an object of the ALV main class. It returns an ALV instance and is used instead of CREATE
OBJECT.
You then use this instance for all other method calls relating to the ALV.
You must pass the internal table containing the data to be displayed. The display type is also passed
using a parameter of this method.
Important parameters:
- T_TABLE: name of the internal table that contains the display data.
- LIST_DISPLAY: if the value is X the ALV is displayed as a classic list. To display the ALV in full screen
mode assign the value a space to its value.
DISPLAY method
If there is changes in the data table, the changes need to be repeated in the ALV output.
REFRESH method of CL_SALV_TABLE is used to refresh the display.
All objects, such as sorting objects that are related to the previous strucutre, are deleted.
SAP_BOOL
Downcast operator ?=