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: 

New User Session via ABAP

Former Member

Hi,

I am trying to create a program in which i want to login as a different user.

I will run this program as user X and than want to create a new GUI session for another user Y.

I should have options for password.

I am aware of 2 types of user session :

GUI

RFC.

Currently i am using SYSTEM_REMOTE_LOGIN for creating a RFC session but want to change this to GUI logon.

I wasn't able to find any FM or code for GUI logon.

Thanks in advance for your help!

Regards,
Deepak Duhan

7 REPLIES 7

satyabrata_sahoo3
Contributor
0 Kudos

SAP Login Inside a login !! I dont think such standard feature available. However you can achieve this by using custom screens and validating User~password from custom table.

0 Kudos

Hi Satya,

As i mentioned we can use SYSTEM_REMOTE_LOGIN to login. But my issue with this is that all the stats recoded with this type of logon shows RFC in report column of the stat table. I want to check what all reports were executed via the second login.

Regards,

Deepak

Former Member
0 Kudos

Hi Deepak,

Try using the Function Module TH_CREATE_FOREIGN_MODE or TH_CREATE_MODE..

Regards,

AyyamPerumal

0 Kudos

Another option is to write a wrapper around this standard SYSTEM_REMOTE_LOGIN function and use submit statement with user as parameter.

regards,

Bartek

0 Kudos

Bartek, a bit confused about using Submit. Please provide some code example how can i submit a FM using the SUBMIT statement.

Just  for info: i am using a TRUSTED RFC created for the specific user(second  user) i am trying to login with. This was to skip any password check.

0 Kudos

Ayyam, i can use TH_CREATE_FOREIGN_MODE only for creating a new session for my user. If i specify any other user id, it raises no NO_AUTHORITY exception. With TH_CREATE_MODE i don't have the option of providing user id.

0 Kudos

This is some solution hope you will find it usefull:

  CALL FUNCTION 'JOB_OPEN'

    EXPORTING

      jobname          = 'ZMYJOB'

    IMPORTING

      jobcount         = l_jobcount

    EXCEPTIONS

      cant_create_job  = 1

      invalid_job_data = 2

      jobname_missing  = 3

      OTHERS           = 4.

  IF sy-subrc = 0.

    SUBMIT zsomereport [WITH parameter = x]

          USER username VIA JOB 'ZMYJOB' NUMBER l_jobcount AND RETURN.

    IF sy-subrc = 0.

      CALL FUNCTION 'JOB_CLOSE'

        EXPORTING

          jobcount             = l_jobcount

          jobname              = 'ZMYJOB'

          strtimmed            = 'X'

        EXCEPTIONS

          cant_start_immediate = 1

          invalid_startdate    = 2

          jobname_missing      = 3

          job_close_failed     = 4

          job_nosteps          = 5

          job_notex            = 6

          lock_failed          = 7

          invalid_target       = 8

          OTHERS               = 9.

      IF sy-subrc <> 0.

* Implement suitable error handling here

      ENDIF.

    ENDIF.

  ENDIF.