Standard service - a fixed amount of work that is performed at a fixed price.  Post Service

  

Thursday, 30 May 2019 22:40

ABAP – Power To Kill

Written by  https://sapyard.com/abap-power-to-kill-2/
Rate this item
(0 votes)

OK. The title might look like click bait, but ABAP developers do have the Power to Kill the SAP Session. ?

This document has provided me the opportunity

to flaunt the power of an ABAP team members. You have always undermined the service of an ABAPer. You have used them for SAP house cleaning tasks. But ABAP team members are the backbone of any SAP Project. So never underestimate the powerful ABAPer. ?

Remember my last article A to Z of AL11? A basis colleague of mine helped me know about the server details/creation of directory etc. Now it was payback time. I was a little tensed, what I might need to offer for the help but my colleague is a simple guy. He just wanted a help with an annoying daily job nothing else. Fewww!! ?

Nowwas the time to thank him with my ABAP skill.

Over a tea break, he casually told me that the Basis team has one job scheduled to update some master data. They schedule the job during the lean window time frame after business hours but somehow very often they find some users locking the transaction the basis team needs to update. And if any user is sitting in that material master, the basis job failed and the basis team had to re-run again.

OurBasis Team members were frustrated as they had to monitor the job every day andreschedule it again if it failed.

Afterhearing his pain, I could empathize with his plight. After all ABAPers are alsovictim of similar agony. Anyway, I had to return the favor and this was theright time.

Here is the summary of the issue:

There is a batch job which updates the material master (for simplicity assume the data in table MARA) on daily basis. But if some user has logged into that material in MM02 then the job fails to update the material master and logs the lock object error. Basis team has to re-run the job again.

How many times have you opened the SM30 t-code or MM02 or VA02 sessions in the evening and left for home without signing off your system? Now anyone working late night or in another time zone cannot use SM30 to maintain the table you have opened. Next time you are done for the day, log off your SAP system and shut down your machine. It will help global warming and keep the earth green. (from Gyan Bhandar) ?

MyBasis friend wanted a solution on priority basis.

High level Solution Architecture

  • Check how many users are locking the Material Master transaction.
  • Provide Pop Up warning message to those users to save their session and come out of transaction within 5 minutes.
  • After 5 minutes (time should be configurable and not hard coded), check again for those are still locking the transaction. Provide the 2nd and final warning to save their work within 5 minutes.
  • After further 5 minutes, the material master transaction which the user is locking would be released/closed. All other transactions and sessions which are not interfering with the job is left untouched.

Also Read:Simple SAP Security Breach

Soundsinteresting? Now, action time.

Steps:

Identify Users:

Functionmodule ENQUEUE_READ provides thedetails of locks.

Here,I am going to provide sy-uname = my name as I am going to test this object anddon’t want to close other’s sessions.

Afterfull testing, will remove my name with ‘*’ to get all the users.

*** FM to get all lock details of MARA table (like SM12)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<code>CALL FUNCTION'ENQUEUE_READ'
EXPORTING
gname='MARA'
guname='$SBHANDARE'
TABLES
enq=gt_lock_details
EXCEPTIONS
communication_failure=1
system_failure=2
OTHERS=3.
IFsy-subrc&lt;>0.
EXIT.
ENDIF.</code>

Get active sessions:

Oncewe know which users are locking our transaction, we need to find out how manysessions are open in the users’ system.

Thereis a standard ABAP class SERVER_INFO which will give us all active sessioninfo.

1
2
3
4
<code>***Getallusersessions
CREATE OBJECTserver_info.
gt_session_list=server_info->get_session_list(with_application_info=1).</code>

Nowwe need to filter out the sessions which belong to our users with clientdetails.

1
2
3
4
5
6
7
<code>***Filterusersessionsonthebasisofusernameandclient.
gt_session_list_user=VALUE#(FORls_lock_detailsINgt_lock_details
FORls_session_listINgt_session_list
WHERE(user_name=ls_lock_details-guname
ANDtenant=sy-mandt)
(ls_session_list)).</code>

Bynow, we have all open sessions of our target users only.

Time to send warnings and notifications to these stubborn users. May be hard working users. ?

We use FM ‘POPUP_TO_CONFIRM’ for pop up messages. But there is a catch. POPUP_TO_CONFRIM will give message to the person who is running the report or program. The user who has opened the screen in change mode will not get notification if we use this FM. So, what is the alternative?

Also Read:Can you really restrict developers from executing any t-code?

Chat in SAP. Yes, you read it right. You can send anonymous pop up messages to anyone in your office SAP network. The good thing is they will not be able to find the sender name easily. I hope you are not thinking what I am thinking. Ready for teenage prank? ?

FM ‘TH_POPUP’ helps us to send pop up messages to any user in the network system. Worksperfectly in our scenario.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<code>DATA(gv_msg)=|YouarelockingTransaction{gv_tcode}.Pleasesaveandleavethetransactionwithin5Secs!!!|.
DATAgv_messageTYPEsm04dic-popupmsg.
gv_message=gv_msg.
LOOP ATgt_lock_detailsINTOgs_lock_details.
CALL FUNCTION'TH_POPUP'
EXPORTING
client=sy-mandt
user=gs_lock_details-guname
message=gv_message
EXCEPTIONS
user_not_found=1
OTHERS=2.
ENDLOOP.</code>

Loopingthrough the users table, we can send notification to all the users who are lockingour transaction.

Let’swait from 5 minutes so that users can save the data and close the session.

1
2
<code>WAIT UP TO300SECONDS.</code>

ABAP Wait statement in SAP Workflow nearly brought my SAP Production system to halt. That is an interesting story which I will tell some other day. I even have the title of the article in mind – “Wait Wait.. do NOT use me”. ?

After5 minutes, check again for the list of users who are sitting on ourtransaction. In between if any new user locks the transaction; this poor guywould only get 5 minutes. They would not get the 2nd warning as thefirst list of users are getting.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<code>gv_msg=|grrr..YouarestilllockingTransaction{gv_tcode}.Yoursessionwillbekilledsoon!!!|.
gv_message=gv_msg.
LOOP ATgt_lock_detailsASSIGNING&lt;fs_lock_details>.
CALL FUNCTION'TH_POPUP'
EXPORTING
client=sy-mandt
user=&lt;fs_lock_details>-guname
message=gv_message
EXCEPTIONS
user_not_found=1
OTHERS=2.
ENDLOOP.</code>

Waitfrom final 5 minutes to give the users one more chance to save the data andclose the session.

1
2
<code>WAIT UP TO300SECONDS.</code>

After the 10th minute, take the list of users who are still locking the transaction. They are the guys who have already left for the day or are talking on phone for more than 10 minutes. By the way, with whom would they talk at these late hours? ?

Action Time.

We will use system kernel call to get all active session details same as t-code SM04.

1
2
3
4
5
6
<code>"get technical info for the user
CALL'ThUsrInfo'ID'OPCODE'FIELDopcode_usr_info
ID'TID'FIELD&lt;fs_session_list>-logon_hdl
ID'WITH_APPL_INFO'FIELDwith_appl_info
ID'TABLE'FIELDgt_usr_info[].</code>

Here we will get a huge list of multiple rows for each session number (0-6) that the user has opened. Each login by a user is assigned a unique login ID which is generated based on parameters you log in with viz: the client number, system, and language. This session ID has the form of TXX_UXXXXX, where X can be any number 0-9.

Eachsession then has a session ID which is comprised of first the login ID asdescribed above, with an appended _MX, where X in this case is the sessionnumber, 0-6 (session 1-7). So, we are interested in the .session value of thistechnical list:

modelinfo[0] is for session 1. Similarly [1] and [2] would be for session 2 and 3 respectively.

modeinfo[1].session = T51_U11407_M1

Session 3 would have: modeinfo[2].session = T51_U11407_M2

Now we need to use the ‘/UPD’ value in the technical info to get the exact session used by the user. You guessed it right. UPD must be for Update Mode.

1
2
3
4
5
6
7
8
9
10
11
<code>CONCATENATE&lt;fs_lock_details>-gusrvb'/UPD'INTODATA(gv_value).
READ TABLEgt_usr_infoASSIGNINGFIELD-SYMBOL(&lt;fs_usr_info>)
WITHKEYvalue=gv_value.
IFsy-subrcISINITIAL.
"The key for the value is 'modeinfo[X].enq_info'.... we need just the X
gv_modus_index=&lt;fs_usr_info>-field+9(1).
ELSE.
CONTINUE.
ENDIF.</code>

Nowwe will do above process and make the list of the users with required sessionswhich we need to close/kill.

After preparing the final user list, I tried to figure out the right way to kill the session of user but failed if initial attempt.

I tried to do the BDC recording of SM12 with delete functionality but that didn’t work. Not sure, may be I did not have the right authorization. I did not dig deep though.

Also Read:How to Delete Foreign Lock Entries in Debug

Then I researched t-code SM04. I did the BDC recording of it and sent user session number to kill that session.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<code>" call transaction SM04, sync (S), no screens
CALL TRANSACTION'SM04'
USINGbdcdata
MODE'N'
UPDATE'S'.
" Now use bdc to end the session with that session id
CLEARbdcdata[].
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/03',
' ''BDC_OKCODE''=&amp;OL0'.
PERFORMbdcdatenUSING:
'X''SAPLSKBH''0800',
' ''BDC_CURSOR''GT_FIELD_LIST-SELTEXT(01)',
' ''BDC_OKCODE''=WLSE',
' ''GT_FIELD_LIST-MARK(01)''X',
' ''BDC_SUBSCR''SAPLSKBH 0810SUB810'.
PERFORMbdcdatenUSING:
'X''SAPLSKBH''0800',
' ''BDC_CURSOR''GT_FIELD_LIST-SELTEXT(01)',
' ''BDC_OKCODE''=CONT',
' ''BDC_SUBSCR''SAPLSKBH 0810SUB810'.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/03',
' ''BDC_OKCODE''=PS 63'.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''02/76',
' ''BDC_OKCODE''=&amp;IC1'.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''02/76',
' ''BDC_OKCODE''=&amp;ILT'.
PERFORMbdcdatenUSING:
'X''SAPLSSEL''1104',
' ''BDC_OKCODE''=CRET',
' ''BDC_SUBSCR''SAPLSSEL 1105%_SUBSCREEN_FREESEL',
' ''BDC_CURSOR''%%DYN001-LOW',
' ''%%DYN001-LOW'gv_ssi_session_id.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/15',
' ''BDC_OKCODE''=&amp;IC1'.
PERFORMbdcdatenUSING:
'X''RSM04000_ALV_NEW''2000',
' ''BDC_CURSOR'gv_modus_string,
' ''BDC_OKCODE''=DEL'.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/15',
' ''BDC_OKCODE''=&amp;F15'.
" call transaction SM04, sync (S), no screens
CALL TRANSACTION'SM04'
USINGbdcdata
MODE'P'
UPDATE'N'.</code>

Finally let’s go in for the kill and shut down that session(s). Once we do that, we log which session/user/transaction combo we deleted to the spool so that no one can cry foul play later. We gave enough time people!

Don’t feel sorry for closing the sessions. We warned the users twice, gave them 10 minutes to save the thing but if they are still blocking our transaction. We were forced for the attack.

Sometimes, we need to be difficult. Kicking the users out of the system ensures that the overall system is synced with up to date master data.

This is my favorite line from Spiderman “With great power comes great responsibility”. Always use your super power for the good reason. ?

Check this video for the output in action:

You can use the below code in your system and execute it. Do not forget to remove the hard code 300 seconds and my sy-uname. If your system is below 7.4, you need to change the new syntax to old and also you might not have some data elements.

Working Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<code>*&amp;---------------------------------------------------------------------*
*&amp; Report ZUSER_SESSION_KILL
*&amp;---------------------------------------------------------------------*
*&amp;
*&amp;---------------------------------------------------------------------*
REPORTzuser_session_kill.
*** Types declarations.
DATA:BEGIN OFgt_usr_infoOCCURS10,
field(40),
value(80),
END OFgt_usr_info.
*** Variable declarations.
DATA:gv_timeTYPEstring,
gv_tcodeTYPEeqetcode,
gv_ssi_session_idTYPEssi_session_id,
gv_modus_num_foundTYPEssi_session_hdl,
gv_modus_index_charTYPEnumc1,
gv_messageTYPEsm04dic-popupmsg,
gv_modus_stringTYPEstring,
gv_modus_indexTYPEstring,
gv_stopTYPEc,
th_opcode(1)TYPEx.
*** Internal table declarations.
DATA:gt_lock_detailsTYPETABLEOFseqg3,
gt_session_listTYPETABLEOFssi_session_info,
gt_session_list_userTYPETABLEOFssi_session_info,
gt_sessions_userTYPETABLEOFssi_session_info.
*** Workareas declarations.
DATA:server_infoTYPEREF TOcl_server_info,
bdcdataLIKEbdcdataOCCURS0WITHHEADERLINE.
*** Constants declarations.
CONSTANTS:opcode_usr_infoLIKEth_opcodeVALUE52,
with_appl_infoTYPEssi_boolVALUE1." this is the internal SAP number
CLEARgv_time.
"To stop the loop processing.
WHILEgv_stopNEabap_true.
"send notification to users, those who are locking our table, do it till 10 seconds.
IFgv_timeISINITIAL." First warning message after 5 minutes
*** fm to GET all lock details of mara table (like sm12)
CALL FUNCTION'ENQUEUE_READ'
EXPORTING
gname='MARA'
guname='$SBHANDARE'
TABLES
enq=gt_lock_details
EXCEPTIONS
communication_failure=1
system_failure=2
OTHERS=3.
IFsy-subrc&lt;>0.
EXIT.
ENDIF.
DATA(gv_msg)=|YouarelockingTransaction{gv_tcode}.Pleasesaveandleavethetransactionwithin5Secs!!!|.
gv_message=gv_msg.
LOOP ATgt_lock_detailsASSIGNINGFIELD-SYMBOL(&lt;fs_lock_details>).
CALL FUNCTION'TH_POPUP'
EXPORTING
client=sy-mandt
user=&lt;fs_lock_details>-guname
message=gv_message
EXCEPTIONS
user_not_found=1
OTHERS=2.
ENDLOOP.
WAIT UP TO300SECONDS.
gv_time='01'.
FREE:gt_lock_details[],gv_message,gv_msg.
"send notification to users, those who are locking our table after first notification too, do it from 5 seconds to 45 seconds.
ELSEIFgv_time='01'." Second warning message
*** FM to get all lock details of MARA table (like SM12)
CALL FUNCTION'ENQUEUE_READ'
EXPORTING
gname='MARA'
guname='$SBHANDARE'
TABLES
enq=gt_lock_details
EXCEPTIONS
communication_failure=1
system_failure=2
OTHERS=3.
IFsy-subrc&lt;>0.
EXIT.
ENDIF.
gv_msg=|Uff...YouarestilllockingTransaction{gv_tcode}.Yoursessionwillbekilledsoon!!!|.
gv_message=gv_msg.
LOOP ATgt_lock_detailsASSIGNING&lt;fs_lock_details>.
CALL FUNCTION'TH_POPUP'
EXPORTING
client=sy-mandt
user=&lt;fs_lock_details>-guname
message=gv_message
EXCEPTIONS
user_not_found=1
OTHERS=2.
ENDLOOP.
WAIT UP TO300SECONDS.
gv_time='03'.
FREE:gt_lock_details[],gv_message,gv_msg.
"kill the user sessions after 50 seconds.
ELSEIFgv_time='03'.
gv_stop=abap_true.
*** FM to get all lock details of MARA table (like SM12)
CALL FUNCTION'ENQUEUE_READ'
EXPORTING
gname='MARA'
guname='$SBHANDARE'
TABLES
enq=gt_lock_details
EXCEPTIONS
communication_failure=1
system_failure=2
OTHERS=3.
IFsy-subrc&lt;>0.
EXIT.
ENDIF.
*** Get all user sessions
CREATE OBJECTserver_info.
gt_session_list=server_info->get_session_list(with_application_info=1).
*** Filter user sessions on the basis of username and client.
gt_session_list_user=VALUE#(FORls_lock_detailsINgt_lock_details
FORls_session_listINgt_session_list
WHERE(user_name=ls_lock_details-guname
ANDtenant=sy-mandt)
(ls_session_list)).
FREE:gt_session_list[].
LOOP ATgt_lock_detailsASSIGNING&lt;fs_lock_details>.
gv_tcode=&lt;fs_lock_details>-gtcode.
CLEARgt_sessions_user.
LOOP ATgt_session_list_userASSIGNINGFIELD-SYMBOL(&lt;fs_session_list>)." loop at all open sessions to build a list of just the user sessions
CLEARgv_modus_index.
CLEARgt_usr_info[].
"get technical info for the user
CALL'ThUsrInfo'ID'OPCODE'FIELDopcode_usr_info
ID'TID'FIELD&lt;fs_session_list>-logon_hdl
ID'WITH_APPL_INFO'FIELDwith_appl_info
ID'TABLE'FIELDgt_usr_info[].
"Need to use the '/UPD' value in the technical info to get the exact session used by user
CONCATENATE&lt;fs_lock_details>-gusrvb'/UPD'INTODATA(gv_value).
READ TABLEgt_usr_infoASSIGNINGFIELD-SYMBOL(&lt;fs_usr_info>)
WITHKEYvalue=gv_value.
IFsy-subrcISINITIAL.
"The key for the value is 'modeinfo[X].enq_info'.... we need just the X
gv_modus_index=&lt;fs_usr_info>-field+9(1).
ELSE.
CONTINUE.
ENDIF.
" If we found a session with that number, we know we had the correct logon... we can add this to the user list
IFgv_modus_indexISNOTINITIAL.
" convert to type ssi_session_handle for later lookup
gv_modus_num_found=gv_modus_index.
" get the session id for this specific session.
CONCATENATE'modeinfo['gv_modus_index'].session'INTODATA(gv_field)." this time we need to find the value from the field
READ TABLEgt_usr_infoASSIGNING&lt;fs_usr_info>WITHKEYfield=gv_field.
IFsy-subrcISINITIAL.
gv_ssi_session_id=&lt;fs_usr_info>-value.
ENDIF.
APPEND&lt;fs_session_list>TOgt_sessions_user.
ENDIF.
ENDLOOP.
IFgt_sessions_user[]ISNOTINITIAL.
SORTgt_sessions_userBYsession_hdlASCENDING.
READ TABLEgt_sessions_userTRANSPORTINGNOFIELDS
WITHKEYsession_hdl=gv_modus_num_found.
IFsy-subrcISINITIAL.
" Kill only the session from the table that matches the index of the modus found
gv_modus_index_char=sy-tabix.
CLEARgv_modus_string.
CONCATENATE'MODUS-MTCODE(0'gv_modus_index_char')'INTOgv_modus_string.
ENDIF.
IFgv_modus_index_charEQ'0'.
CONTINUE.
ENDIF.
" First ensure that sm04 is called and set to the sessions view
CLEARbdcdata[].
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/03',
' ''BDC_OKCODE''=SESSIONS'.
" call transaction SM04, sync (S), no screens
CALL TRANSACTION'SM04'
USINGbdcdata
MODE'N'
UPDATE'S'.
" Now use bdc to end the session with that session id
CLEARbdcdata[].
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/03',
' ''BDC_OKCODE''=&amp;OL0'.
PERFORMbdcdatenUSING:
'X''SAPLSKBH''0800',
' ''BDC_CURSOR''GT_FIELD_LIST-SELTEXT(01)',
' ''BDC_OKCODE''=WLSE',
' ''GT_FIELD_LIST-MARK(01)''X',
' ''BDC_SUBSCR''SAPLSKBH 0810SUB810'.
PERFORMbdcdatenUSING:
'X''SAPLSKBH''0800',
' ''BDC_CURSOR''GT_FIELD_LIST-SELTEXT(01)',
' ''BDC_OKCODE''=CONT',
' ''BDC_SUBSCR''SAPLSKBH 0810SUB810'.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/03',
' ''BDC_OKCODE''=PS 63'.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''02/76',
' ''BDC_OKCODE''=&amp;IC1'.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''02/76',
' ''BDC_OKCODE''=&amp;ILT'.
PERFORMbdcdatenUSING:
'X''SAPLSSEL''1104',
' ''BDC_OKCODE''=CRET',
' ''BDC_SUBSCR''SAPLSSEL 1105%_SUBSCREEN_FREESEL',
' ''BDC_CURSOR''%%DYN001-LOW',
' ''%%DYN001-LOW'gv_ssi_session_id.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/15',
' ''BDC_OKCODE''=&amp;IC1'.
PERFORMbdcdatenUSING:
'X''RSM04000_ALV_NEW''2000',
' ''BDC_CURSOR'gv_modus_string,
' ''BDC_OKCODE''=DEL'.
PERFORMbdcdatenUSING:
'X''SAPMSSY0''0120',
' ''BDC_CURSOR''04/15',
' ''BDC_OKCODE''=&amp;F15'.
" call transaction SM04, sync (S), no screens
CALL TRANSACTION'SM04'
USINGbdcdata
MODE'P'
UPDATE'N'.
" proper logging. times, order number, and transaction added as well as
WRITE:/'User session from user ',&lt;fs_lock_details>-guname,'with session number',gv_modus_index_char,'was deleted.'.
WRITE:/'Object Lock Time Length:',&lt;fs_lock_details>-gttime.
ENDIF.
ENDLOOP.
ENDIF.
ENDWHILE.
*&amp;---------------------------------------------------------------------*
*&amp; Form BDCDATEN
*&amp;---------------------------------------------------------------------*
FORMbdcdatenUSINGstartfnamfval.
CLEARbdcdata.
IFstart=abap_true.
bdcdata-dynbegin=start.
bdcdata-program=fnam.
bdcdata-dynpro=fval.
ELSE.
bdcdata-fnam=fnam.
bdcdata-fval=fval.
ENDIF.
APPENDbdcdata.
ENDFORM." BDCDATEN</code>

Beloware the output snapshots of the code:

First Warning message to user (done for 5 secs time as doing testing):

SecondWarning message after 10 minutes to user:

SM12entry of lock:

After 10 minutes, the sessions which are locking the material master will be closed.

Hope you found this interesting. Try it internally in your team and remember its impact. Also take note of the forbidden system kernel calls.

Your comments make me smile. Please comment!

We have a very active Telegram (App) SAP Technical Group with more than 4930+ SAP Technical Practitioners from 6 Continents of the SAP World. Please join it using below link.
Telegram SAP Technical Discuss Group. You need to install the Telegram App first on your mobile device. Once you have it on your mobile, you can join the group and also access it from the Web on your computer and laptop.

Please SUBSCRIBE to SAPYard’s Youtube Channel for Free End to End SAP Video Course and Training.

Check HANA-ABAP Tutorials

Read 169 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.