2010 Dec 01 12:31 AM
Hello all,
Is there a way to determine that a program is running in foreground, without adding code to the program to lock the program?
If the program in question was a custom program, I would add FM ENQUEUE_ESINDX and check the return code. I need to check whether a standard SAP program, RFFOUS_C, is running in foreground.
Thanks
Bruce
Hello all,
Is there a way to determine that a program is running in foreground, without adding code to the program to lock the program?
If the program in question was a custom program, I would add FM ENQUEUE_ESINDX and check the return code. I need to check whether a standard SAP program, RFFOUS_C, is running in foreground.
Thanks
Bruce
2010 Dec 01 12:57 AM
CALL FUNCTION 'BP_JOB_SELECT_SM37B'
EXPORTING
JOBSELECT_DIALOG =
* JOBSEL_PARAM_IN = ' '
* ENDDATE = ' '
* ENDTIME = ' '
* IMPORTING
* JOBSEL_PARAM_OUT =
TABLES
* JOBSELECT_JOBLIST =
JOBSELECT_JOBLIST_B =
* EXCEPTIONS
* INVALID_DIALOG_TYPE = 1
* JOBNAME_MISSING = 2
* NO_JOBS_FOUND = 3
* SELECTION_CANCELED = 4
* USERNAME_MISSING = 5
* OTHERS = 6
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Use the above function module. In function group BTCH or any other similar one in BTCH.Give no to dialog mode.
In JOBSEL_PARAM_IN supply the jobname which the report will use if run in back ground and .
In ABAPNAME give the report name. Date give a the presnt dates and times.
Check the active flag.
Then run the module.Check the JOBSELECT_JOBLIST table
If it reurns your report as active it means running in background else
You report may run in fialog or may not even be running.
These FMs have a doccumentation 'BP_JOB_SELECT_SM37B' and 'BP_JOB_SELECT_SM37C' in fg BTCH go through them.
Edited by: Vighneswaran CE on Dec 1, 2010 2:02 AM
2010 Dec 01 5:04 AM
One way is to check this is run the sm50 transaction if your report is running in dialog mode it should be displayed in one of the dialog work prosesses.
To do the above using function modules.
DATA: LT_WPLIST like standard table of WPINFO,
LS_WPLIST like line of LT_WPLIST .
CALL FUNCTION 'TH_GET_WPINFO'
* EXPORTING
* SRVNAME =
* WITH_CPU =
TABLES
WPLIST = LT_WPLIST
* EXCEPTIONS
* SEND_ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at LT_WPLIST into LS_WPLIST where WP_TYP EQ 'DIA' and WP_REPORT EQ 'RFFOUS_C'.
WRITE:/ 'REPORT currently running in dialog or foreground at the very moment of this check :)'.
ENDLOOP.Edited by: Vighneswaran CE on Dec 1, 2010 6:04 AM
Edited by: Vighneswaran CE on Dec 1, 2010 6:08 AM
2010 Dec 01 6:10 PM
Vighneswaran ,
Thanks for you answer. It gave me a solution. But not 100%. The following is what I observed.
The code must be actively accessing a processor. If the program has
been swapped out, or a wait statement is active, the program will
not show up in the WPLIST table.
*
I have seen examples of the 1st character returned in table field
WP_REPORT is a '!'.
*
So, if the program has started in foreground, but not stopped, there
is no guarantee that it will show up in table WPLIST.
Bruce
2010 Dec 03 4:18 AM
Hi Bruce,
Here are some of the ways that I thought of which may solve your problem.
Try to debug the program to check if it uses any DB table in which it populates entries while it is running and once the program finishes running it flushes this table.
You can evaulate this DB table for entries to know if this program is active.
Or you try to see if it uses any lock objects.I kindoff caught up to work.So I am unable to check for the existance of any DB tables used by this prog etc.
Thanks
Edited by: Vighneswaran CE on Dec 3, 2010 5:55 PM
2010 Dec 01 6:30 AM
Hi Bruce,
Simply call the FM 'GUI_IS_AVAILABLE' which has only a single exporting parameter (having value 'X' or space).
Best regards,
Ozcan.