Hi there,
i was wondering if we can the currently logged-in user role for an SAP user, the following examples work, but the role object was not recognized …
> WScript.Echo session.info.systemname
> WScript.Echo session.info.systemnumber
> WScript.Echo session.info.language
> WScript.Echo session.info.user
> WScript.Echo session.info.client
> WScript.Echo session.info.Transaction
> WScript.Echo session.info.user
> WScript.Echo “---------------------------”
> WScript.Echo session.info.UserInfo.UserRoles.CurrentRole.Name ’ ERROR
> WScript.Echo session.ActiveRoles(0).Name ’ ERROR
Thanks
Hara
Hi @Hara_Gopal
You can use different approaches based on your implementation methodology. You can either use Find Children-Get attribute to obtain the use roles from GUI or you can try using the following VB code snippet:
Set SapGuiAuto = GetObject(“SAPGUI”)
Set Application = SapGuiAuto.GetScriptingEngine
Set Connection = Application.Children(0)
Set session = Connection.Children(0)
Set Roles = session.findById(“wnd[0]/usr/cntlUSER_ROLE_MENU_CONTAINER/shellcont/shell/shellcont[0]/shell”)
For i = 0 To Roles.Count - 1
Role = Roles.getitem(i)
WScript.Echo Role.Text
Next
Hope this helps, please let us know if this works.
Best Regards.