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

Sub user creation

Former Member
0 Likes
870

Dear SAP Friends,

Can any one tell me that how to create sub-users under Main user?

Please Inform.

Regards,

Chandra.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
817

I haven't done this so far, but have a look at BAPI 'BAPI_USER_CREATE1'...

8 REPLIES 8
Read only

Former Member
0 Likes
818

I haven't done this so far, but have a look at BAPI 'BAPI_USER_CREATE1'...

Read only

0 Likes
817

Hi Dear,

Thanks for reply.

I am not find the link.

How to find that link.

Plz reply.

chandra

Read only

0 Likes
817

Which link do you mean? From user to sub-user?

Or how to have a look at the BAPI? If so, go to SE37 or transaction BAPI and search for 'user' (via CTRL + g).

Read only

0 Likes
817

Dear Friend,

I get it.

Thanks.

But can any one tell the procedure for creation of sub user

Please reply.

Chandra.

Read only

0 Likes
817

Hm, can't find anything abaout sub-users...

Are you sure that you don't mean SAP users?

Read only

0 Likes
817

Hi Sir,

YES.

Read only

0 Likes
817

Ok, please check this code for creating a user...


  CONSTANTS:
    lc_timezone_cet         TYPE tznzone       VALUE 'CET',

  DATA:
    ls_return             TYPE bapiret2,
    lt_return             TYPE TABLE of BAPIRET2,
*   BAPI structures
    ls_logondata          TYPE bapilogond,
    ls_password           TYPE bapipwd,
    ls_address            TYPE bapiaddr3,
    lt_bapi_return        TYPE TABLE OF bapiret2,
    lv_uname              LIKE BAPIBNAME-BAPIBNAME.

  FIELD-SYMBOLS:
    <fs_return>           TYPE bapiret2.

  ls_logondata-gltgv  = sy-datum.
  ls_logondata-gltgb  = '99991231.
  ls_logondata-tzone  = lc_timezone_cet .

* Generate password
  CALL FUNCTION 'RSEC_GENERATE_PASSWORD'
    EXPORTING
      output_length = 8
    IMPORTING
      output        = ls_password-bapipwd
    EXCEPTIONS
      some_error    = 1
      OTHERS        = 2.

  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* Set address data
  ls_address-lastname  = 'LAST_NAME'.
  ls_address-firstname = 'FIRST_NAME'.
  ls_address-e_mail    = 'TEST'.

***********************************************************
* Create user in SAP ERP
***********************************************************
  lv_uname = 'TEST_USER'.

  CALL FUNCTION 'BAPI_USER_CREATE1'
    EXPORTING
      username  = lv_uname
      logondata = ls_logondata
      password  = ls_password
      address   = ls_address
    TABLES
      return    = lt_bapi_return.

  LOOP AT lt_bapi_return[] ASSIGNING <fs_return>
    WHERE type = 'E'.
    APPEND <fs_return> TO lt_return.
  ENDLOOP.
  IF sy-subrc IS NOT INITIAL.
*   No Error occurred => Print out success message
    CLEAR ls_return.
    ls_return-type       = 'I'.
    ls_return-id         = gc_message_id.
    ls_return-number     = '010'.
    ls_return-message_v1 = lv_uname.
    APPEND ls_return TO et_return.
  ENDIF.

Read only

0 Likes
817

Dear Sir,

Thanks for solving query.

Chandra.