‎2009 Dec 16 7:51 AM
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
‎2009 Dec 16 4:34 PM
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.