|
#1
|
|||
|
|||
Llamada a función RFC
Alguién me podría mandar un ejemplo de una llamada a una RFC desde un excel, desde Visual Basic...???
Muchas gracias. |
#2
|
|||
|
|||
Ejemplo Funcion RFC desde macro de Excel
Aca tienes un ejemplo de llamada a una función RFC desde una macro de Excel.
Saludos Public oR3, oConnection, oMyFunc As Object Public oSTORE, otI_HEADER, otI_ITEMS As Object Public Result As Boolean Public mApplicationServer As String 'Application Server of the R/3 System. Public mSystem As String ' SAP R/3 System name. Public mSystemNumber As Long ' System number of the R/3 System. Public mClient As Long ' Client in the R/3 System. Public mLanguage As String ' Language you use want to use in the R/3 System Public mSAPRouter As String Public mUserId As String Public mPassword As String Sub Logon() '********************************************* 'Logon al sistema SAP R/3 '********************************************* Set oR3 = Nothing Set oR3 = CreateObject("SAP.Functions") ' Cargar los parametros de conexion Set oConnection = oR3.Connection oConnection.ApplicationServer = "xxx.xxx.x.xxx" oConnection.System = "DEV" oConnection.SystemNumber = "00" oConnection.Client = "100" oConnection.Language = "ES" 'oConnection.SAPRouter = "/H/xxx.xxx.xx.xx/H/" oConnection.User = "xxxxxxxx" oConnection.Password = "xxxx" 'Set App = R3.Application If oConnection.Logon(0, True) <> True Then oConnection.SAPRouter = "/H/xxx.xxx.xx.xx/H/" If oConnection.Logon(0, True) <> True Then MsgBox "No se puedo establecer conexión SAP" Exit Sub End If End If End Sub '********************************************* 'Logon al sistema SAP R/3 '********************************************* 'Set App = R3.Application If oConnection.IsConnected = 0 Then MsgBox "No existe conexión SAP establecida, se conectara" Logon End If ' Establecer contacto con la funcion. Set oMyFunc = oR3.Add("ZFUNCION_RFC") Set oSTORE = oMyFunc.Exports("STORE") Set otI_HEADER = oMyFunc.Exports("I_HEADER") Set otI_ITEMS = oMyFunc.Tables("I_ITEMS") oSTORE.Value = "xxxx" Call GenerarI_HEADER Call GenerarTablaI_ITEMS ' Llamar a la funcion de SAP. Result = oMyFunc.Call ' Analizar el resultado de la llamada. If Result = False Then MsgBox "Error en el llamado a la funcion RFC: ZFUNCION_RFC" Else MsgBox "Funcion RFC ejecutada OK." End If '********************************************* 'Clear de Objetos de parametros '********************************************* Set oSTORE = Nothing Set otI_HEADER = Nothing Set otI_ITEMS = Nothing End Sub |
Herramientas | Buscar en Tema |
Desplegado | |
|
|