Logging- Off Users from the system using ABAP program
We had an issue that the process chain for Demand Planning which loads data from BW to APO would frequently fail because users would login to planning area in APO which would cause a lock.
In order to avoid this I implemented an ABAP program in the first step, which will check if any user has entered the planning area – TCODE ‘/SAPAPO/MSDP_ADMIN’.
If yes it will give a Popup ‘Please logout of the planning area as the Process chain will now start’ and if user doesn’t logout it will force logout the user from APO system after ’20 seconds’.
Pro’s- 1. The process chain will not fail due to locking issue as the ABAP program will handle it.
2. The program is efficient enough and doesn’t consume lot of time to execute so it will not hamper the current scenario
Con- If the user is in planning area the program will throw the user out of the APO system completely after 20 seconds rather than just throwing out of the particular Transaction code ‘/SAPAPO/MSDP_ADMIN’.
Function Modules Used –
TH_LONG_USR_INFO – To get the list of Users logged in to the system with the Transaction codes.
TH_POPUP – To give popup to the User.
TH_DELETE_USER – To logout the User.
Here is the ABAP program, you can include any TCODE as per your convenience.
DATA : it_uinfo TYPE TABLE OF uinfo2,
wa_uinfo LIKE LINE OF it_uinfo.
DATA: flag_found TYPE c VALUE ‘ ‘,
done TYPE c VALUE ‘ ‘.
.
CALL FUNCTION ‘TH_LONG_USR_INFO’
EXPORTING
user = ‘*’
TABLES
user_info = it_uinfo.
LOOP AT it_uinfo INTO wa_uinfo.
IF wa_uinfo–tcode = ‘/SAPAPO/MSDP_ADMIN‘.
CALL FUNCTION ‘TH_POPUP’
EXPORTING
client = sy–mandt
user = wa_uinfo–user
MESSAGE = ‘Please logout of the planning area as the Process chain- Session will be closed after 20 seconds’
* MESSAGE_LEN = 0
* CUT_BLANKS = ‘ ‘
EXCEPTIONS
user_not_found = 1
OTHERS = 2.
flag_found = ‘X’.
ENDIF.
ENDLOOP.
CLEAR wa_uinfo.
IF flag_found = ‘X’.
WAIT UP TO 20 SECONDS.
LOOP AT it_uinfo INTO wa_uinfo.
IF wa_uinfo–tcode = ‘ ‘/SAPAPO/MSDP_ADMIN’‘.
CALL FUNCTION ‘TH_DELETE_USER’
EXPORTING
user = wa_uinfo–user
client = sy–mandt
only_pooled_user = ‘ ‘
* TID =
EXCEPTIONS
authority_error = 1
OTHERS = 2.
IF sy–subrc = 0.
done = ‘X’.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
Hello Rahul,
Thanks for your sharing,
One question, in the first loop to check if the user using the APO planning tcode,
But why in the second loop to check if the user in the SE01 tcode?
Could you please help to clarify it?
Thanks
Li Dong
Oops , Sorry will edit it. Actually I did the testing with SE01 tcode, missed to edit it
Thanks a Lot!!!
Thanks,
Rahul