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

How to use BAPI_USER_CHANGE

Former Member
0 Likes
16,175

Hi Experts,

Can some one please tell me, how i can make changes to user id, mobile number, office number, fax number using  BAPI_USER_CHANGE,

Thanks in advance.

Regards,
Snigdha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
8,613

Hi,

       Use below sample code .

   DATA : T_USERNAME LIKE BAPIBNAME-BAPIBNAME ,
               BAPIMSG    LIKE BAPIRET2  OCCURS 0 WITH HEADER LINE,
               T_ADDTEL LIKE  BAPIADTEL    OCCURS 0 WITH HEADER LINE.
.



T_USERNAME-BAPIBNAME = 'XXXXXXXXX' .   " User Name in User Master Record

LOOP AT  T_ADDTEL .
  T_ADDTEL-TELEPHONE = 'xxxxxxx' " pass ur TELEPHONE numner
  APPEND:  T_ADDTEL  .
  CLEAR :  T_ADDTEL  .
ENDLOOP.



CALL FUNCTION 'BAPI_USER_CHANGE'
  EXPORTING
    USERNAME                =  T_USERNAME
  TABLES
*   PARAMETER               =
    RETURN                  =  BAPIMSG
   ADDTEL                  =   T_ADDTEL
          .


READ TABLE BAPIMSG WITH KEY TYPE = 'E'.

IF SY-SUBRC EQ '0'.
  CONCATENATE BAPIMSG-MESSAGE  BAPIMSG-ID BAPIMSG-NUMBER INTO E_ERROR SEPARATED BY SPACE.

ELSE .

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
* IMPORTING
*   RETURN        =
      .
ENDIF.

Regard's

Smruti Ranjan

13 REPLIES 13
Read only

Former Member
0 Likes
8,613

Use ADDTEL(For Mobile number and standard number) and ADDFAX ( For Fax number ). See the SE37 documentation for FM.

Read only

0 Likes
8,613

Hi Rudra,

How can i use addtel for both mobile number and standard number?
Will that help me?
I am actually fetching bname(user id ) from an external source outside sap, and i am using an rfc to check whether the the bname exists in sap or not,
If yes, i am trying to fill the above mentioned fields.
So will my exporting parameter, wen i call bapi_user_change in my rfc will be bname.
Please do kindly show me, how i can make use of it,
Do tell me, how to make use of bapiret2, if the bname doesnt exist in sap
Thanks in advacne.

Read only

0 Likes
8,613

Incase you User name is invalid ( BNAME ) bapi_user_change will throw an error message automatically in the RETURN table which has got structure BAPIRET2, You do not need to call a separate BAPI to validate the user name. Still you want to do it it is up to you.

To answer your second question, yes you pass the User Name to FM importing parameter USERNAME field and pass the telephone number and fax numbers in those internal table. If you are using JCO to call the RFC you have methods available to populate the internal table. To know how the BAPI works, check for the documentation and run the BAPI in SE37 in SAP system.

Read only

0 Likes
8,613

Thanks Rudra Roy,

That was really helpfull.
Thanks for your time.

Read only

former_member585060
Active Contributor
0 Likes
8,613

Hi,

     Provide the following exporting parameters.

Pass the below parameters for the BAPI.

USERNAME

ADDRESS        ADDRESS-PERS_NO

                         ADDRESS-ADDR_NO

                         ADDRESS-TEL1_NUMBR

                         ADDRESS-FAX_NUMBER  

ADDRESSX     ADDRESSX-PERS_NO = 'X'

                         ADDRESSX-ADDR_NO = 'X'

                         ADDRESSX-TEL1_NUMBR = 'X'

                         ADDRESSX-FAX_NUMBER = 'X'.

Then Call the BAPI_TRANSACTION_COMMIT 

Thanks & Regards

Bala Krishna

Read only

Former Member
0 Likes
8,614

Hi,

       Use below sample code .

   DATA : T_USERNAME LIKE BAPIBNAME-BAPIBNAME ,
               BAPIMSG    LIKE BAPIRET2  OCCURS 0 WITH HEADER LINE,
               T_ADDTEL LIKE  BAPIADTEL    OCCURS 0 WITH HEADER LINE.
.



T_USERNAME-BAPIBNAME = 'XXXXXXXXX' .   " User Name in User Master Record

LOOP AT  T_ADDTEL .
  T_ADDTEL-TELEPHONE = 'xxxxxxx' " pass ur TELEPHONE numner
  APPEND:  T_ADDTEL  .
  CLEAR :  T_ADDTEL  .
ENDLOOP.



CALL FUNCTION 'BAPI_USER_CHANGE'
  EXPORTING
    USERNAME                =  T_USERNAME
  TABLES
*   PARAMETER               =
    RETURN                  =  BAPIMSG
   ADDTEL                  =   T_ADDTEL
          .


READ TABLE BAPIMSG WITH KEY TYPE = 'E'.

IF SY-SUBRC EQ '0'.
  CONCATENATE BAPIMSG-MESSAGE  BAPIMSG-ID BAPIMSG-NUMBER INTO E_ERROR SEPARATED BY SPACE.

ELSE .

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
* IMPORTING
*   RETURN        =
      .
ENDIF.

Regard's

Smruti Ranjan

Read only

0 Likes
8,613

Thanks Smruti Ranjan,
Thanks all for ur time.

Read only

Venkat_Sesha
Product and Topic Expert
Product and Topic Expert
0 Likes
8,613

If you question is solved. Please close the Thread.

Read only

0 Likes
8,613

Hi venkat,
how do i close the tread?
can u please tell me, how i can do this,
Thanks!!

Read only

Venkat_Sesha
Product and Topic Expert
Product and Topic Expert
0 Likes
8,613

You can say it as Self Answered or Can give points to others who answered.

Read only

0 Likes
8,613

Hello,

I am having an issue with BAPI_USER_CHANGE. The client has the users centralized system in 250 and the program i am creating has to change any system password. So, for example, when i try to change system 700 password if i execute the FM it will throw me an error because the password change has to be done in 250, and if I do the password change in 250 it will change the password for 250, not for 700.

Do you know any other BAPI i can use or if i can set the parameters correctly in a different way to use

BAPI_USER_CHANGE. Currently if i execute bia RFC from 700 to 250 it changes 250 password and not 700.

Thanks for any inputs, regards,

Gustavo

Read only

0 Likes
8,613

Hi Gustavo

This thread is answered already.

First search the SDN forum for a similar issue to yours. If you cannot find the answer you seek, then open a new discussion thread.

Regards

Arden

Read only

RaymondGiuseppi
Active Contributor
0 Likes
8,613