Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

oops ALV in background mode

Former Member
0 Likes
1,892

Hi Experts,

I know this topic is discussed several times but I still have a confusion.

I have created one ALV report using custom container like the usual way. As per my understanding this report shouldn't execute in background

but when I execute the report in background in development system, it's not throwing any error and I am able to get the spool.

Why is this happening? Is there a possibility that if I transport the object to other system I may get error?

Please share your thoughts.

Thanks,

Tiki

1 ACCEPTED SOLUTION
Read only

SimoneMilesi
Active Contributor
0 Likes
1,514

It's not true.. it dependes by how you developed the code.

i use CL_GUI_GRID class and manage the background option without any problem.

It's not true.. it dependes by how you developed the code.

i use CL_GUI_GRID class and manage the background option without any problem.

6 REPLIES 6
Read only

former_member201275
Active Contributor
0 Likes
1,514

ALV list is possible in background, but ALV grid not.

The FM automatically handles the background mode & switches to ALV list, without you doing anything.

Read only

SimoneMilesi
Active Contributor
0 Likes
1,515

It's not true.. it dependes by how you developed the code.

i use CL_GUI_GRID class and manage the background option without any problem.

Read only

0 Likes
1,514

Ok... I saw lot of threads about this and thought to try if using custom container works in background mode or not. I was surprised that it worked.

So It shouldn't have any problem if I transport the code to next environment right?

And in which case it's supposed to throw error in background mode, asking just for understanding.

you have any idea??

Read only

0 Likes
1,514

This is my "common code" i use to manage CL_GUI_GRID in background without touching the output screen to define a container

CLASS lcl_event_handler DEFINITION DEFERRED.
DATA: gr_event_handler      TYPE REF TO lcl_event_handler.
*---- ALV Grid instance reference
DATA: gr_alvgrid            TYPE REF TO cl_gui_alv_grid.
*---- Custom container instance reference
DATA: gr_splitter_container TYPE REF TO cl_gui_splitter_container,
       gr_container          TYPE REF TO cl_gui_container.
*---- Header container
DATA: gr_docking_container  TYPE REF TO cl_gui_docking_container,
       gr_document           TYPE REF TO cl_dd_document.

IN PBO
IF sy-batch = 'X'.

*---- Creating ALV grid within a docking container
       CREATE OBJECT gr_alvgrid
         EXPORTING
           i_parent = gr_docking_container.

     ELSE.

*---- Creating Splitted Containers
*   
       CREATE OBJECT gr_splitter_container
         EXPORTING
           parent  = cl_gui_container=>screen0
           rows    = 1
           columns = 1.
       CALL METHOD gr_splitter_container->set_border
         EXPORTING
           border = cl_gui_cfw=>false.
       CALL METHOD gr_splitter_container->set_row_mode
         EXPORTING
           mode = gr_splitter_container->mode_relative.
       gr_container =
         gr_splitter_container->get_container( row = 1 column = 1 ).


*---- Creating ALV Grid instance
       CREATE OBJECT gr_alvgrid
         EXPORTING
           i_parent = gr_container.


*---- Preparing document header

       PERFORM prepare_header.

     ENDIF.

*-- Creating an instance for the event handler
     CREATE OBJECT gr_event_handler.
*-- Registering handler methods to handle ALV Grid events
*   NOTA: Qua vanno registrati eventuali metodi aggiunti per gestire
*   altri eventi della classe CL_GUI_ALV_GRID.
     SET HANDLER gr_event_handler->handle_double_click  FOR gr_alvgrid.
     SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid.
     SET HANDLER gr_event_handler->handle_data_changed  FOR gr_alvgrid.
     SET HANDLER gr_event_handler->handle_data_changed_finished
                                                        FOR gr_alvgrid.
     SET HANDLER gr_event_handler->handle_toolbar       FOR gr_alvgrid.
     SET HANDLER gr_event_handler->handle_user_command  FOR gr_alvgrid.

*-- Preparing layout structure
     PERFORM prepare_layout.

*-- Preparing print structure
     PERFORM prepare_print.

*-- Preparing field catalog
     PERFORM prepare_field_catalog.

*-- Preparing sort criteria table
     PERFORM prepare_sort_criteria.

*-- Prepating filter criteria table
     PERFORM prepare_filter_criteria.

*-- Preparing function codes to exclude from the toolbar
     PERFORM prepare_toolbar_exclude.

*-- Preparing the output for the ALV grid list
*-- NOTE: set I_BUFFER_ACTIVE = 'X' to speed to the list display
*-- if the ALV grid uses statically always the same field catalog
     CALL METHOD gr_alvgrid->set_table_for_first_display
       EXPORTING
*       i_buffer_active               = 'X'
*       i_structure_name              = 'GS_OUTTAB'
         is_variant                    = gs_variant
         i_save                        = 'A'
         i_default                     = 'X'
         is_layout                     = gs_layout
         is_print                      = gs_print
*       IT_SPECIAL_GROUPS             =
         it_toolbar_excluding          = gt_exclude[]
*       IT_HYPERLINK                  =
*       IT_ALV_GRAPHICS               =
       CHANGING
         it_outtab                     = gt_outtab[]
         it_fieldcatalog               = gt_fieldcat[]
         it_sort                       = gt_sort[]
         it_filter                     = gt_filter[]
       EXCEPTIONS
         invalid_parameter_combination = 1
         program_error                 = 2
         too_many_lines                = 3
         OTHERS                        = 4.

*-- Allows to edit the toolbar
     CALL METHOD gr_alvgrid->set_toolbar_interactive.
Read only

0 Likes
1,514

Hi Tiki,

actually, all ALV, SALV, OO or functiuonal do encapsuling of the grid object. I remember the difference is if it is full-screen (in background converted to list) or not.

If background works in development, then it will work everywhere 🙂

Regards

Clemens

Read only

0 Likes
1,514

Thanks Clemens:)