This website is not affiliated with, sponsored by, or approved by SAP AG.

ALV grid layouts

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

ALV grid layouts

Postby kcosha » Mon Feb 03, 2003 4:50 am

Hi,

Does anyone know how to get at the layout stored with an ALV gird?

Are client wants to be able to run a report in background and in foreground. In background mode we are just going to write the data out in a list.

At the moment the user is able to choose the list layout on the initial selection screen and have that used with his ALV. He wants to be able to do the same when running the report in background.

I thought maybe if I just instantiated the ALV without displaying it... I would be able to call the method get_frontend_layout but this still causes background abap dumps.

Thanks for any ideas/suggestions/solutions
kcosha
 
Posts: 37
Joined: Fri Nov 15, 2002 5:30 am

Postby skarkada » Mon Feb 03, 2003 10:34 am

Use REUSE_ALV_GRID_DISPLAY and you will be able to run the report in foreground or background.

If you must use OO ALV controls, you won't be able to run the program in background. In this scenario, I would check SY-BATCH and if it is set, I run REUSE* FM and if not I do CALL SCREEN.
Sudhi Karkada
skarkada
 
Posts: 701
Joined: Mon Oct 21, 2002 1:12 pm
Location: Houston, TX, USA

Postby Tim van Steenbergen » Mon Feb 03, 2003 11:15 am

.. and to be able to save a layout when you use REUSE_ALV_GRID_DISPLAY, check out topic http://www.sapfans.com/forums/viewtopic.php?p=52847&highlight=#52847
Best regards, Tim van Steenbergen
Tim van Steenbergen
 
Posts: 346
Joined: Tue Dec 17, 2002 7:52 am
Location: Amsterdam, The Netherlands

Postby kcosha » Tue Feb 04, 2003 3:20 am

ok,

This all sounds good but I still get the feeling that I am going to get an ABAP dump when I run in background. At the moment SM37 keeps showing the jobs cancelling with the following message
"Control Framework: Fatal error - GUI cannot be reached"

and this is even when I am only instantiating the ALV and then calling the method to get the front end layout.

How with the solutions you are suggesting am I not going to get this error??

Thanks
kcosha
 
Posts: 37
Joined: Fri Nov 15, 2002 5:30 am

Postby skarkada » Tue Feb 04, 2003 9:56 am

REUSE_ALV_LIST_DISPLAY and REUSE_ALV_GRID_DISPLAY are function modules that do not look for SAPGui (or presentation server) to perform their task.

You might still get a short dump for some other reason - but you won't get one just because it is running in background.

The OO classes you are currently using require custom controls that are currently instantiated in a SAPGui session. In a background job there is no such thing, so you are getting a short dump.

Using those FMs is extremely easy - if only you had tried them, you would have saved a lot of time by now.
Sudhi Karkada
skarkada
 
Posts: 701
Joined: Mon Oct 21, 2002 1:12 pm
Location: Houston, TX, USA

Alv control frame error

Postby shoba » Wed Feb 05, 2003 10:34 am

Hi,

The Container object has to be instansiated only once..ie Create object of container has to be in between IF not initial of container obj ..and end if.

Try this may work.
shoba
 

Postby mbutcher » Mon Mar 06, 2006 7:29 pm

If you are using the ABAP Grid Control (OO object), you can still create the ALV list as a spool listing for the background job.

The easiest way to do this is to put all the create object statements and method calls for the custom container and ALV grid object inside a subroutine (for example, present_grid).

All that is required is a simple check of the sy-batch variable to determine if the program is being executed in the foreground or background.

e.g. if sy-batch is initial.
call screen 0100.
else.
perform present_grid.
endif.

In a PBO module of screen 0100, the subroutine present_grid is also performed.

The set_table_for_first_display method will be invoked in the routine present_grid, however, due to the job being executed in the background, the ALV list output will be written as spool output for the background job.

Regards,

Marty
mbutcher
 
Posts: 1
Joined: Mon Mar 06, 2006 7:11 pm

OO ALV Grid works okay

Postby ajt » Fri Mar 30, 2007 4:35 am

You can easily use an ALV grid in back ground, but you need to suppress the "Control Framework: Fatal error - GUI cannot be reached". Have a look at example code: BCALV_GRID_01, where they suppress the error by catching it.

Code: Select all
IF CUSTOM_CONTAINER IS INITIAL.
* create a custom container control for our ALV Control
    CREATE OBJECT CUSTOM_CONTAINER
        EXPORTING
            CONTAINER_NAME = MYCONTAINER
        EXCEPTIONS
            CNTL_ERROR = 1
            CNTL_SYSTEM_ERROR = 2
            CREATE_ERROR = 3
            LIFETIME_ERROR = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5.
    IF SY-SUBRC NE 0.
* add your handling, for example
*  >>> Capturing this error is what allows the
*  >>> program to run in background
      CALL FUNCTION 'POPUP_TO_INFORM'
           EXPORTING
                TITEL = G_REPID
                TXT2  = SY-SUBRC
                TXT1  = 'The control could not be created'(010).
    ENDIF.
* create an instance of alv control
    CREATE OBJECT GRID1
          EXPORTING I_PARENT = CUSTOM_CONTAINER.
*
* Set a titlebar for the grid control
*
    GS_LAYOUT-GRID_TITLE = 'Flights'(100).

* § 5. In case of PRINT_END_OF_PAGE, you must set 'reservelns' to
*      the number of reserved lines at the end of a page.
*
* reserve two lines for the PRINT_END_OF_PAGE event
*
    GS_PRINT-RESERVELNS = 2.

    CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
         EXPORTING I_STRUCTURE_NAME = 'SFLIGHT'
                   IS_PRINT         = GS_PRINT
                   IS_LAYOUT        = GS_LAYOUT
         CHANGING  IT_OUTTAB        = GT_SFLIGHT.
--
"It's not magic, it's work!"
ajt
 
Posts: 1
Joined: Fri Mar 30, 2007 4:12 am


Return to ABAP

Who is online

Users browsing this forum: No registered users and 6 guests





This website is not affiliated with, sponsored by, or approved by SAP AG.