ABAP: Stay logged into SAPGUI indefinitely

Sometimes you’re doing something midway on your system, and you’re interrupted for a meeting or lunch or whatever. You come back and you’ve been automatically logged out, losing whatever you were working on earlier.

Prior to our upgrade to ECC6, you can simply keep yourself logged in by making timed calls to function module SAPGUI_PROGRESS_INDICATOR. Once upgraded however, the code has changed, causing it to no longer extend your GUI session.

For those who missed out on the old code that does this, here it is:

FUNCTION Z_SAPGUI_PROGRESS_INDICATOR.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(PERCENTAGE) DEFAULT 0
*"     VALUE(TEXT) DEFAULT SPACE
*"----------------------------------------------------------------------

	DATA : OUT_TEXT LIKE SY-UCOMM,
	PERC     TYPE I,
	MODNO    TYPE I.
	IF SY-BATCH <> SPACE.
		EXIT.    "do nothing in batch
	ENDIF.
	IF PROG_INDI_CHECKED = SPACE.
		GET PARAMETER ID 'SIN' FIELD PROG_INDI_MODE.
		PROG_INDI_CHECKED = 'X'.
	ENDIF.
	IF PROG_INDI_MODE = '0'.
		EXIT.    "do nothing if turned off via SPA/GPA
	ENDIF.
	OUT_TEXT = TEXT.
	PERC     = PERCENTAGE.
	MODNO    = SYST-MODNO.
	IF PERC < 0.   PERC = 0.   ENDIF.
	IF PERC > 100. PERC = 100. ENDIF.
	
	CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
		DESTINATION 'SAPGUI'
		KEEPING LOGICAL UNIT OF WORK
		EXPORTING TEXT       = OUT_TEXT
			  PERCENTAGE = PERC
			  MODN       = MODNO
		EXCEPTIONS SYSTEM_FAILURE
			   COMMUNICATION_FAILURE.
	SYST-SUBRC = 0.
ENDFUNCTION.

 

Leave a Reply