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 update user group by using BAPI ActiveX Control ?

0 Likes
478

Dear Gurus,

I'm new to ABAP. I'm trying to use BAPI ActiveX Control to update all users' group information. So I write a simple VBScript to test. Below is the code. After running below code I found the user's group was not changed, but in the return structure it showed "User MyUserID is changed".

Could you help to see how to correct below code ?

Sub ChangeUser()

Dim oBAPICtrl

Dim oConnection

Dim Logon

Dim oUser

Dim oReturn As Object

Dim oGroups As Object

Set oBAPICtrl = CreateObject("SAP.BAPI.1")

Set oConnection = oBAPICtrl.Connection

If oConnection.Logon(0, False) <> True Then 'Logon With Dialog

Set oConnection = Nothing

Logon = False

MsgBox "No access to R/3 System", vbOKOnly, APPID

Else

Logon = True

End If

Set oUser = oBAPICtrl.GetSAPObject("user", "MyUserID")

Set oGroups = oBAPICtrl.DimAs(oUser, "Change", "Groups")

oGroups.Rows.Add

oGroups.Value(1, 1) = "MyGroup"

oUser.Change Groups = oGroups, return:=oReturn

oConnection.logoff

Set oUser = Nothing

Set oReturn = Nothing

Set oGroup = Nothing

Set oConnection = Nothing

Set oBAPICtrl = Nothing

End Sub

Thanks

Baoyan

1 REPLY 1
Read only

0 Likes
355

Solved problem by checking the BAPI user.change, and found that one parameter was missed: Groupsx. This parameter indicates whether to update the corresponding data.

By adding this parameter, data update is ok now.