Skip to Content
0
Former Member
Apr 16, 2012 at 01:51 PM

Connection EXcel and SAP problem

939 Views

Hello Everybody,

I am new to this community and have started to make a connection between Excel and SAP. I want to run ME2M command in Excel from SAP but I get an error in vba which says:

Run time Error '1001'

SAP remote function call when I clikc on help bottun in VBA it gives me this message:

Cannot find the wdtfuncs.hlp file. Do you want to try to find it yourself?

I do not nnow how to get rid of this error. Can s.omeone help me? Thanks

This is the code I use :

Public Sub rfc_call_transaction()
Dim Functions As Object
Dim RfcCallTransaction As Object
Dim Messages As Object
Dim BdcTable As Object
'On error resume next
' Create the Function control (that is, the high-level Functions collection):
Set Functions = CreateObject("SAP.Functions")

' Set the rest of Connection object values:
Functions.Connection.System = "00"
Functions.Connection.client = "20"
Functions.Connection.user = "123456"
Functions.Connection.Password = "123"
Functions.Connection.Language = "EN"


'sapConnection.ApplicationServer = "7100.1.5.1033" 'TSP
'sapConnection.SystemNumber = "00"

'sapConnection.codepage = "1100"
If Functions.Connection.Logon(0, False) <> True Then
Exit Sub
End If

' Retrieve the Function object (the Connection object must be set up before Function objects can be created):
Set RfcCallTransaction = Functions.Add("RFC_CALL_TRANSACTION")
' Set the export parameters (here, get all customers whose names start with J):

RfcCallTransaction.exports("TRANCODE") = "ME2M"
RfcCallTransaction.exports("UPDMODE") = "S"
Set BdcTable = RfcCallTransaction.Tables("BDCTABLE")

' Set the tables parameter and add the data for the call transaction
add_bdcdata BdcTable, "SAPLSETB", "230", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "DATABROWSE-TABLENAME"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=ANZE"
add_bdcdata BdcTable, "", "", "", "DATABROWSE-TABLENAME", "KNA1"
add_bdcdata BdcTable, "/1BCDWB/DBKNA1", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "MAX_SEL"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=ONLI"
add_bdcdata BdcTable, "", "", "", "LIST_BRE", "250"
add_bdcdata BdcTable, "", "", "", "MAX_SEL", "5"
add_bdcdata BdcTable, "SAPMSSY0", "120", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "01/02/1962"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=%EX"
add_bdcdata BdcTable, "/1BCDWB/DBKNA1", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/EE"
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "I1-LOW"
add_bdcdata BdcTable, "SAPLSETB", "230", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/EBACK"
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "DATABROWSE-TABLENAME"

' Call the function (if the result is false, then display a message):
If RfcCallTransaction.Call = True Then
Set Messages = RfcCallTransaction.imports("MESSG")
MsgBox Messages.Value("MSGTX")
Else
MsgBox " Call Failed! error: " ' + GetCustomers.Exception
End If

Functions.Connection.Logoff
End Sub