cancel
Showing results for 
Search instead for 
Did you mean: 

Connection EXcel and SAP problem

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member184675
Active Participant

Hi,

What is the SAP Version that you're working with. FM RFC_CALL_TRANSACTION does not exist since 4.6c (from what i know)

Andrei

Former Member
0 Kudos

Hi Andrei

The version I am using is  (file version) is      7100.1.5.1033  . am I capable of using it with this version. If it does not exit in our SAP what are the other option to run  command in SAP and get its corresponding data?

Thanks

Moh

former_member184675
Active Participant
0 Kudos

Hi,

What you told me is the SAP GUI version. I wanted to know if the SAP system you're trying to connect to is ECC or R/3 4.6 or 4.7

I am not sure but i think the problem is because the FM does not exist in the SAP System.

If you can access the SAP system try to see if FM RFC_CALL_TRANSACTION exists (tcode se37).

If it does not exist use FM RFC_CALL_TRANSACTION_USING.

For RFC_CALL_TRANSACTION_USING you have the following parameters:

IMPORT:

  • TCODE
  • MODE

EXPORT

  • SUBRC

TABLES

  • BT_DATA
  • L_ERRORS

Also i don't see where you set the Hostname parameter. Did you not set it or is it hidden on this forum post?

BR,

Andrei Sosea

Answers (0)