Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Close a transaction through ABAP program without user log off.

Former Member
0 Likes
2,990

Hi,

I have to write an ABAP program that will check if a particular transaction (for example tcode VA01) is running than it must close the transaction.

Please give me your inputs or sample code if possible.

Thanks for your suggestions.

--Sanjay

15 REPLIES 15
Read only

Former Member
0 Likes
2,082

for the same user or different users?

Read only

Former Member
0 Likes
2,082

Thanks for your reply.

in both cases it can be applicable. I will try to make it for the same user as well as different user.

Read only

Former Member
0 Likes
2,082

Hi Sanjay,

Please write the below code:

DATA: lt_user TYPE STANDARD TABLE OF uinfo,

lt_user_wa LIKE LINE OF lt_user.

*---- Get the list of logged users

CALL FUNCTION 'CNV_GET_USERS_LOGGED_IN'

EXPORTING

mode = '1'

TABLES

i_usr = lt_user.

IF NOT lt_user[] IS INITIAL.

LOOP AT lt_user INTO lt_user_wa.

IF lt_user_wa-tcode = 'VA01'.

LEAVE TO TRANSACTION ' '.

ENDIF.

ENDLOOP.

ENDIF.

Regards,

-Syed

Read only

Former Member
0 Likes
2,082

I guess you need to close that session, the way done in Std transaction SM04

Read only

0 Likes
2,082

Hi Vivek,

Sorry, CNV_GET_USERS_LOGGED_IN FM will get the list of users logged in currently.

And we need to explicitly close this using LEAVE TO TRANSACTION ' '.

Regards,

-Syed.

Edited by: wahid hussain syed on May 12, 2009 1:23 PM

Read only

Former Member
0 Likes
2,082

Thanks Sayed and Vivek for your valuable inputs.

Sayed, the function CNV_GET_USERS_LOGGED_IN does not exist but PRGN_GET_USERS_LOGGED_IN with different parameters.

Yes Vivek, I want to implement the SM04 end session functionality in my ABAP program.

Please keep posting your inputs. Thanks.

Read only

Former Member
0 Likes
2,082

Hello Team,

There are no new updates on my query. Should I close the query without answered?

Please let me know if you have some information to share. Thanks.

--Sanjay

Read only

0 Likes
2,082

Look [here|https://www.sdn.sap.com/irj/scn/advancedsearch?query=th_delete_user&cat=sdn_all].

Read only

0 Likes
2,082

Use this fm.

TH_DELETE_USER

Read only

0 Likes
2,082

Sanjay,

Check with this how much it is going to help you out..

PARAMETERS: p_user LIKE sy-uname.

DATA: gt_user_info TYPE TABLE OF /sdf/user_context,

wa_uinfo LIKE /sdf/user_context.

START-OF-SELECTION.

CALL FUNCTION '/SDF/MON_USER_MEMORY'

TABLES

modes = gt_user_info.

CHECK NOT gt_user_info IS INITIAL.

LOOP AT gt_user_info INTO wa_uinfo WHERE uname EQ p_user.

IF wa_uinfo-tcode = 'VA01'.

CALL FUNCTION 'TRANSACTION_ABORT'

EXPORTING

transaction_id = transaction_id

EXCEPTIONS

OTHERS = 1.

EXIT.

ENDIF.

ENDLOOP.

Regards,

CK

Read only

Former Member
0 Likes
2,082

Hi Chandan,

thanks for your reply.

I did not find /sdf/user_context. I am getting error on the same line.

Please tell me what the structure/table it is.

-Sanjay

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
2,082

Hi,

Just do BDC for SM04 so that in menu Edit->Set filter is chosed. Then select transaction and then set the value as VA01.Then execute and select all button and then delete.

If you did recording for it, you can delete the list of users accessing the tcode .

Read only

Former Member
0 Likes
2,082

Left more try on the requirement.

Read only

0 Likes
2,082

Hi Sanjay,

I also have the same requirement.

Can you please let me know how did you solve it.

Thanks in advance.

Thanks,

Sudheer

Read only

Former Member
0 Likes
2,082

Hi,

You can use ecatt recording for the same and call using se38