SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

ФИО пользователя через логин



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
NotTemp
Участник
Участник



Joined: 05 Jun 2009
Posts: 1

PostPosted: Fri Jun 05, 2009 9:30 am    Post subject: ФИО пользователя через логин Reply with quote

Доброе время суток!

Возникла такая задача: необходимо через имя пользователя в системе получить его ФИО и отдел (то что видно по SU01).
По советам родственного форума, использовал BAPI.
Далее VBA код. Я не сказал, что мне нужно отформатировать отчет в Bex Analyser (это BW), а он построен на MS Excell.

Code:

Private Sub ExtGetUserDetail_BAPI()
On Error GoTo errTrap
Dim objBAPIControl As Object
Dim sapConnection As Object
Dim oUser As Object
Dim oAddress As Object

Set objBAPIControl = CreateObject("sap.bapi.1")
Set sapConnection = objBAPIControl.Connection

sapConnection.client = "100"
sapConnection.User = login
sapConnection.Language = "RU"
sapConnection.ApplicationServer = AS
sapConnection.Password = pass
sapConnection.systemnumber = "0"
sapConnection.System = "00"

If sapConnection.Logon(1, True) <> True Then
    MsgBox "No connection to R/3!"
    Exit Sub
End If

Set oUser = objBAPIControl.GetSAPObject("USER", sUSER_NAME)
Set oAddress = objBAPIControl.DimAs(oUser, "GetDetail", "Address")

    Set oWS = ActiveSheet
    oWS.Cells(1, 1) = address.Value("DEPARTMENT")
    oWS.Cells(1, 2) = address.Value("TEL1_EXT")
    oWS.Cells(1, 3) = address.Value("LASTNAME")
    oWS.Cells(1, 4) = address.Value("FIRSTNAME")

objBAPIControl.Connection.Logoff

errTrap:
Set oUser = Nothing
Set oAddress = Nothing
Set objBAPIControl = Nothing
Set sapConnection = Nothing

End Sub


Но почему-то при таком способе, хоть код отрабатываться без ошибок, тем не менее все возвращаемые значения пустые.

В чем может быть причина?
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 200
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Fri Jun 05, 2009 1:05 pm    Post subject: Reply with quote

Возможно с правами на клиенте.
У себя под дебагером (включается sapConnection.ABAPDebug = True)
глянул, SAP информацию отдает.
Проверю на другом клиенте, где есть права админа и отпишу.
Back to top
View user's profile Send private message Blog Visit poster's website
vga
Мастер
Мастер


Age: 200
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Mon Jun 08, 2009 1:52 pm    Post subject: Reply with quote

Попробовал, от прав не зависит.

Иследования показали, что если у параметра не стоит признак 'Table', то через objBAPIControl.DimAs ничего не возвращается.
Может баг, может фича.

А так к вашему коду претензий нет, замена 'Address' на другой параметр, например 'Groups', значения возвращает.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.