on 08-14-2009 10:39 AM
Hi!
Sorry for my English (it is translated Google).
Faced with a problem: it is necessary to insert a record field with the name of the record (not his name). Posted a little VBA code to get the last names.
Private Sub FM_ExtGetUserDetail()
On Error GoTo errTrap
Dim objBAPIControl As Object
Dim objUserDetail As Object
Dim address As Object
Dim sapConnection As Object
Dim oWS as WorkSheet
Set objBAPIControl = CreateObject("SAP.Functions")
Set sapConnection = objBAPIControl.Connection
sapConnection.client = "100"
sapConnection.User = login
sapConnection.Language = "RU"
sapC :evil: onnection.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 objUserDetail = objBAPIControl.Add("BAPI_USER_GET_DETAIL")
objUserDetail.exports("USERNAME") = sUSER_NAME
returnFunc = objUserDetail.Call
If returnFunc = True Then
Set address = objUserDetail.imports("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")
Else
MsgBox "Error call BAPI_USER_GET_DETAIL ! "
Exit Sub
End If
objBAPIControl.Connection.Logoff
errTrap:
Set address = Nothing
Set objUserDetail = Nothing
Set objBAPIControl = Nothing
Set sapConnection = Nothing
End Sub
But have one problem left:
Now in the code clearly identifies the data to connect to the system. It can be replaced by dialogue to login to the system. But the ideal solution to use the current BEx connection that does not make the user double-enter the registration data.
Q How can this be done?
Try this: Code:
Set sapConnection = Run("BExAnalyzer.xla!sapBEXgetConnection", 0)
but did not succeed (p_connectionObj = Nothing).
Juggling objects p_connectionObj and g_logonObj result failed.
Anybody?
Maybe the message is moved to another branch of the forum?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.