Control Framework: Fatal error - GUI cannot be reached
I have written a program that uses the cl_gui_alv_grid class to display data. The program works fine when run in the foreground but if a user tries to run it in the background they get the above error.
I understand that this is because the program is unable to access gui components when running in the background. I therefore need to test for background processing and either:
1. terminate the program
2. have some fallback procedure within the program to deal with background processing.
My question is therefore in two parts:
1. How do I find out if the program has been set to run in the background?
2. What do I need to do to allow my program to work in the background? i.e. is there a function/class that I can pass the data to that will do this or do I have to re-write the report in full as if I wasn't using the grid viewer at all?
You should check the CL_GUI_ALV_GRID=>OFFLINE as Ravi said and the force the print.
You can do it setting the IS_PRINT-PRINT of method SET_TABLE_FOR_FIRST_DISPLAY.
In this way you program should generate a spool.