You are on page 1of 3

ALV Fatal Error - GUI Cannot be reached

By Suresh Kumar Parvathaneni

This Tutorial gives us a procedure to track most common occurring error in ALV and in
an easy way.

Purpose: This document details about the common problem faced by many consultants:
“Fatal Error – GUI cannot be reached” in ALV Grid Control.

Pre-requisites: The reader of this Tutorial is assumed to have some basic knowledge
regarding ALV and ALV grid controls.

The problem:

SAP® has provided us with some demo programs on ALV. We would use one of them in
our scenario. BCALV_GRID_DEMO is the demo program provided by SAP® for ALV
Grid Control. When you execute the program in foreground, you get the similar
following output:
When you schedule the same program in background, your job is cancelled due to an
error. Screenshot of the same is shown below:

Reason:

ALV Grid control is based on the custom controls on the screen. When the program is
scheduled in background, it tries to create GUI related front-end objects and hence the
error “Fatal Error – GUI cannot be reached”. This type of problem is common with all the
programs that use the ALV grid control to display the output.

Solution:

Whenever we execute this type of programs in background, we should be passing a blank


docking container instead of the custom container as parent to our grid control.

The docking container doesn’t need any of the custom controls on the screen; instead it
attaches an area to any or all of the four edges of the screen (top, left, right or bottom).
The behavior of the areas in the container is determined by the sequence in which they
are initialized. Docking Containers are attached to the screen from the inside out. This
means that when you create a second container, it is attached to the edge of the screen,
and the container that was already there is pushed outwards.

Let us modify the standard program (by taking a copy of it) to enable it to execute it in
background.

Following modifications have to be made:

• Define a docking container in the program

data: or_doc type ref to cl_gui_docking_container .


• At the time of creating a custom container, check if the program is being executed in
background or foreground. If the program is scheduled in background, then create a
docking container instead of custom container.

if cl_gui_alv_grid=>offline( ) is initial.

create object or_custom_container

exporting container_name = c_container.

create object or_grid

exporting i_parent = or_custom_container.

else .

create object or_grid

exporting i_parent = or_doc .

endif .

Now test executing the program in background. The report would be generated.

Have a problem??. Click here for the complete modified program

You might also like