2019 Jun 26 12:52 PM
I have a method which calls a subroutine 'USER_COMMAND' in Program 'MYPROGAM'. In foreground this works fine the code in the subroutine is executed. Is there a way to do this in background? When I run in background the code in the subroutine is not executed.

All help greatly appreciated.
2019 Jul 05 4:02 PM
I have solved this using the advice of Raymond Giuseppi i.e. rewrite the whole Code. For some reason I cannot 'accept' his answer. All of the other answers though also helped me a lot!
2019 Jun 26 12:59 PM
Handling user commands in background does not make sense, does it?
2019 Jun 26 1:08 PM
Hi Thomas,
sorry, left out the part where i force the user_command:

2019 Jun 26 1:37 PM
2019 Jun 26 1:55 PM
Hi Raymond,
I have commented that out but it doesn't work either.
What I would like to do is execute the code in subroutine 'USER_COMMAND' of program 'MYPROGAM' when the program is run in background. Not sure if this can be called from a method in background mode?
At the moment when the program is run in foreground, the USER_COMMAND subroutine is called and the user can then click on a button called 'BOOK' to make a booking. I want to change the program so that it runs in background and forces the booking.
2019 Jun 26 2:06 PM
Assertion 'At the moment when the program is run in foreground, the USER_COMMAND subroutine is called and the user can then click on a button called 'BOOK' to make a booking.' is false!
In foreground the ALV grid is displayed, and when user interacts with screen the user_command and other events are triggered so the form would be executed. the SET_PF_STATUS form is only executed in foreground in the PBO of screen...
In background, a spool is génerated by REUSE_ALV_LIST_DISPLAY and bye, Bye. (look for cl_gui_alv_grid=>offline( ) in the FM execution)
So use a print event such as TOP_OF_PAGE and check if sy-batch is set. Or rewrite youw whole code for better reusability...
2019 Jul 07 8:24 AM
2019 Jun 26 2:10 PM
I vote for Raymond answer : "... or rewrite your whole code for better reusability"
2019 Jun 26 2:52 PM
Rewrite your code so you use CL_GUI_ALV_GRID or CL_SALV_TABLE directly.
2019 Jun 26 3:48 PM
Thank you to all of you so much for your help. 😞
2019 Jun 28 4:11 PM
You could try using the parameter IS_PRINT_LVC. I believe that's what I used. However, it's been a long time. If you have the time, the best thing to do is to use one of the classes suggested above. They are actually a lot easier to work with than the function module.
2019 Jul 05 4:02 PM
I have solved this using the advice of Raymond Giuseppi i.e. rewrite the whole Code. For some reason I cannot 'accept' his answer. All of the other answers though also helped me a lot!
2019 Jul 05 7:20 PM
raymond.giuseppi please convert your comment into an answer 🙂