10-07-2009 10:30 AM
Hi,
How to run ALV report in Background which is created using cl_gui_alv_grid. I am getting error ,
Control Framework: Fatal error - GUI cannot be reached
Regards,
Balavardhan
10-07-2009 10:44 AM
Hello -
You can use this in background. All you need is to add this piece of code:
IF gv_alv_cont1 IS INITIAL.
CALL METHOD cl_gui_alv_grid=>offline
RECEIVING
e_offline = gv_offline.
IF gv_offline IS INITIAL.
* Create object for ALV.
CREATE OBJECT gv_alv_cont1
EXPORTING
container_name = gc_cc_alv1.
ENDIF.
CREATE OBJECT gv_alv_grid1
EXPORTING i_parent = gv_alv_cont1.
* Display ALV grid
CALL METHOD gv_alv_grid1->set_table_for_first_display
EXPORTING
is_variant = gwa_variant
i_save = gc_a
is_layout = gwa_layout
it_toolbar_excluding = lt_exclude
CHANGING
it_outtab = gt_data
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
This will work in background.
Thanks,
Vijay
10-07-2009 10:35 AM
10-07-2009 10:40 AM
>
> Anything which is GUI dependent will not work in background.
Hello,
There you are mistaken my friend we have a workaround for this
@OP: You can get details in this [link|;.
P.S->BETTER to use REUSE_ALV_GRID_DISPLAY as it can in foreground or background. If we use OO ALV controls, we won't be able to run the program in background.
FYI, REUSE_ALV_GRID_DISPLAY is also converted to list when executed in background. Difference is that for REUSE_ALV_GRID_DISPLAY we donot have to code for it but if we use CL_GUI_ALV_GRID, we have to explicitly handle the situation.
Hope i am clear.
Suhas
10-07-2009 10:47 AM
Hi Suhas,
I too know that.. :). Just giving the information that OO ALV(CL_GUI_ALV_GRID) won't work in background where as REUSE_ALV_GRID_DISPLAY works. anyways thanks.
Regards,
Nagaraj
10-07-2009 10:50 AM
Hello Nagaraj,
I presume OO ALV will work in background, if we use the code i have shown above.
Thanks,
10-07-2009 10:50 AM
Thanks for letting me know that there a few exceptions to my statement. I should have searched before posting.
10-07-2009 10:53 AM
Hi,
Yes you are right whatever code you wrote is correct..But if we don't write that code then the error will come. OO ALV won't work without the code you wrote...
Regards,
Nagaraj
10-07-2009 10:39 AM
10-07-2009 10:44 AM
Hello -
You can use this in background. All you need is to add this piece of code:
IF gv_alv_cont1 IS INITIAL.
CALL METHOD cl_gui_alv_grid=>offline
RECEIVING
e_offline = gv_offline.
IF gv_offline IS INITIAL.
* Create object for ALV.
CREATE OBJECT gv_alv_cont1
EXPORTING
container_name = gc_cc_alv1.
ENDIF.
CREATE OBJECT gv_alv_grid1
EXPORTING i_parent = gv_alv_cont1.
* Display ALV grid
CALL METHOD gv_alv_grid1->set_table_for_first_display
EXPORTING
is_variant = gwa_variant
i_save = gc_a
is_layout = gwa_layout
it_toolbar_excluding = lt_exclude
CHANGING
it_outtab = gt_data
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
This will work in background.
Thanks,
Vijay