Application Development 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: 

TH_DELETE_USER not working in background mode

former_member219850
Participant
0 Kudos
829

Hi folks,

I am uploading exchange rates in tcurr table by using bapi bapi_create_multiple.

but if end-user in logged in , then bapi throws an error 'Object requested is currently locked by user '.

to avoid this  i am killing session with the help of fm TH_DELETE_USER.

But this fm is not responding in background.

CALL FUNCTION 'ENQUEUE_READ'

         EXPORTING

           gclient               = sy-mandt

           gname                 = gc_rstable

           guname                = ''

         TABLES

           enq                   = gt_enq

         EXCEPTIONS

           communication_failure = 1

           system_failure        = 2

           OTHERS                = 3.

       IF sy-subrc EQ 0.

* Implement suitable error handling here

       ENDIF.

       SORT gt_enq STABLE BY gname.

       READ TABLE gt_enq INTO gw_enq WITH KEY gname = gc_rstable

                                      garg+0(5= 'TCURR' BINARY SEARCH.

       IF sy-subrc EQ 0.

         gv_user = gw_enq-guname.

       ENDIF.


CALL FUNCTION 'TH_DELETE_USER'

       EXPORTING

         user                   = gv_user

         client                 = sy-mandt

         tid                    = -1

*      LOGON_ID               = -1

       EXCEPTIONS

         authority_error        = 1

         OTHERS                 = 2

                .

      IF sy-subrc EQ 0.

*** Implement suitable error handling here

      ENDIF.

please suggest what should i do??

Thanks,

Darshan



11 REPLIES 11

raymond_giuseppi
Active Contributor
0 Kudos
355

Could you elaborate on "But this fm is not responding in background." (this FM performs perfectly in background)

Also

  • Explain your READ TABLE (seems strange to me somehow unnecessarily complicated)
  • Use GW_ENQ-GCL and not SY-MANDT and use a LOOP on the internal table.
  • Manage return codes (usually NE 0 and not EQ 0)
  • Check your authorisations ( S_ADMI_FCD , SU53 or trace)

Regards,

Raymond

0 Kudos
355

Hi raymond,

Thank you reply.

i have written this code in an abap proxy.. which gets triggered from PI system..

so when it gets triggered user session is not getting killed.

because of which bapi is throwing an error.

FM enqeue_read gives the username who has locked the entry.

to read the username, i am comparing the first five letters of garg field.

After that i am passing the same in th_delete_user.

Thanks,

Darshan

0 Kudos
355

Hi Raymond,

Below are all critical authorizations i found in su53.

SAP_ABAA

SAP_ABJA

SAP_ABNA

SAP_ABNN

SAP_ADMM

SAP_ALOG

SAP_ARZM

SAP_ASPA

SAP_ASPD

SAP_ASPT

SAP_AUAM

SAP_AUAS

SAP_AUPM

SAP_AUPS

SAP_AUUM

SAP_AUUS

SAP_CTBA

SAP_CTBC

SAP_CTBS

SAP_DEVD

SAP_DEVT.

** S_ADMI_FCD  is not in the list.. can be this the reason??

Thanks,

Darshan

0 Kudos
355

If you think it is an authorisation problem, then run your transaction with an authorisation trace on ST01, and check the results for a non-zero return code.

0 Kudos
355

Or look at FM source, in most (all?) versions, the first statement is an authorization-check.

Former Member
0 Kudos
355

Hi,

Did you tested the same in foreground, i mean by creating any sample program for the same. If so its working properly in foreground then you need to check what values are passing when you are executing the in background by doing external debugging.

Regards,

Venu

0 Kudos
355

Hi venu,

Thank you for replying.

Yes it is working fine in foreground. when i test it manually in sproxy tcode.

But when i trigger it from pi server it does not work.

Thanks,

Darshan

0 Kudos
355

hi venu & raymond,

please suggest .

thanks

0 Kudos
355

Hi,

I suggest you to put external breakpoint and debug, then what return code you getting from FM's.

If your return code (SY-SUBRC) is not "0", then look for the exception matching with your code to find what's the actual error.

Regards,

Venu

0 Kudos
355

HI Venu,

For triggering data into system, basis team has created different user named as RFC_PIT130.

Type of this user B i.e. System. because of which external debugger is not hitting.

Thanks.

franzstrohmeier
Explorer
0 Kudos
355

The question is quite old, but nevertheless the following hint might be helpful in similar cases:

You have to logout the user from all servers of a system: Call TH_SERVER_LIST and make a call of TH_DELETE_USER with the option DESTINATION <servername> for each of the servers. This also works in a background job. The standard uses this way in form KILL_LOCKING_USERS of report HFIUCPL0.

Kind regards,

Franz