<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Instantiating a RFC BAPI using VBA (Excel) in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632251#M4738538</link>
    <description>&lt;P&gt;Thanks Sandra, very new to this board and still feeling my way around it. &lt;/P&gt;&lt;P&gt;Basically I'm stuck on figuring out these 64-bit VBA libraries (see list below). All the research I've done have come up with either 32-bit solutions or are answers that I've having difficulty deciphering/reproducing. &lt;/P&gt;&lt;P&gt;In the code above, I can instantiate the "sapConn" connection object - but how exactly do I pass that over to an RFC call? I have four VBA libraries referenced in a test macro-enabled spreadsheet (SAP Function Call Control, SAP Table Factory, SAP BAPI Control, SAP Logon Control). My goal here is to pass a parameter to the RFC Function "Z_BAPI_ALM_ORDER_MAINTAIN_01" and I'm not sure of the procedure (or which libraries) to do that.&lt;/P&gt;</description>
    <pubDate>Sat, 17 Sep 2022 18:39:50 GMT</pubDate>
    <dc:creator>former_member817179</dc:creator>
    <dc:date>2022-09-17T18:39:50Z</dc:date>
    <item>
      <title>Instantiating a RFC BAPI using VBA (Excel)</title>
      <link>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaq-p/12632249</link>
      <description>&lt;P&gt;I have been able to successfully log onto SAP from inside excel and have a BAPI I'm trying to call. This BAPI takes a single parameter. But I'm trying to figure out how to instantiate the BAPI (using 64-bit controls). Honestly, just looking for the next step after logging on (which I've been able to do using SAPLogonCtrl. &lt;/P&gt;
  &lt;P&gt;Current Code that is working and the three attempts I've made all failing (commented out all the failed code) &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;Dim sapLogon As SAPLogonCtrl.SAPLogonControl&lt;BR /&gt;Dim sapConn As SAPLogonCtrl.Connection&lt;BR /&gt;Set sapLogon = New SAPLogonControl&lt;BR /&gt;Set sapConn = sapLogon.NewConnection&lt;BR /&gt;With sapConn&lt;BR /&gt; .System = "ED1"&lt;BR /&gt; .ApplicationServer = "{serverName}"&lt;BR /&gt; .SystemNumber = "{serverNumber}" '&lt;BR /&gt; .Client = "{clientNumber}"&lt;BR /&gt; .User = "user"&lt;BR /&gt; .Password = "userPasword"&lt;BR /&gt; .Language = "EN"&lt;BR /&gt;End With&lt;BR /&gt;Call sapConn.Logon(0, True)&lt;BR /&gt;If sapConn.IsConnected &amp;lt;&amp;gt; tloRfcConnected Then&lt;BR /&gt; MsgBox "connection failed. " &amp;amp; sapConn.IsConnected&lt;BR /&gt; Exit Sub&lt;BR /&gt;Else&lt;BR /&gt; MsgBox "Connection Successful!!! - Code " &amp;amp; sapConn.IsConnected '&amp;lt;- this line runs!!!!&lt;BR /&gt;End If&lt;BR /&gt;'NOTE: I CAN GET TO HERE JUST FINE WITH THE LOGON &lt;BR /&gt;'FIRST ATTEMPT (FAIL)&lt;BR /&gt;'Dim RFCFunc As New SAPFunctionsOCX.Function&lt;BR /&gt;'Dim SAPFunCtl As New SAPFunctions&lt;BR /&gt;'&lt;BR /&gt;'Set RFCFunc = SAPFunCtl.Add("Z_BAPI_ALM_ORDER_MAINTAIN_01")&lt;BR /&gt;'SECOND ATTEMPT (FAIL)&lt;BR /&gt;'Dim functions As Object&lt;BR /&gt;'Dim obSapBapi As Object&lt;BR /&gt;'&lt;BR /&gt;'Set functions = sap.functions(sapConn)&lt;BR /&gt;'Set obSapBapi = functions.Add("Z_BAPI_ALM_ORDER_MAINTAIN_01")&lt;BR /&gt;'THIRD ATTEMPT (FAIL)&lt;BR /&gt;'Dim oSAP As Object&lt;BR /&gt;'Dim objGetList As Object&lt;BR /&gt;'Set oSAP = sapConn.RfcCOMInstance&lt;BR /&gt;'Set objGetList = oSAP.Add("Z_BAPI_ALM_ORDER_MAINTAIN_01")&lt;BR /&gt;End Sub&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Sep 2022 19:42:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaq-p/12632249</guid>
      <dc:creator>former_member817179</dc:creator>
      <dc:date>2022-09-16T19:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating a RFC BAPI using VBA (Excel)</title>
      <link>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632250#M4738537</link>
      <description>&lt;P&gt;Please explain the symptoms of "attempt (fail)".&lt;/P&gt;</description>
      <pubDate>Sat, 17 Sep 2022 07:38:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632250#M4738537</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-09-17T07:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating a RFC BAPI using VBA (Excel)</title>
      <link>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632251#M4738538</link>
      <description>&lt;P&gt;Thanks Sandra, very new to this board and still feeling my way around it. &lt;/P&gt;&lt;P&gt;Basically I'm stuck on figuring out these 64-bit VBA libraries (see list below). All the research I've done have come up with either 32-bit solutions or are answers that I've having difficulty deciphering/reproducing. &lt;/P&gt;&lt;P&gt;In the code above, I can instantiate the "sapConn" connection object - but how exactly do I pass that over to an RFC call? I have four VBA libraries referenced in a test macro-enabled spreadsheet (SAP Function Call Control, SAP Table Factory, SAP BAPI Control, SAP Logon Control). My goal here is to pass a parameter to the RFC Function "Z_BAPI_ALM_ORDER_MAINTAIN_01" and I'm not sure of the procedure (or which libraries) to do that.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Sep 2022 18:39:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632251#M4738538</guid>
      <dc:creator>former_member817179</dc:creator>
      <dc:date>2022-09-17T18:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating a RFC BAPI using VBA (Excel)</title>
      <link>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632252#M4738539</link>
      <description>&lt;P&gt;I thought you were asking about how to solve an error, but you are looking for documentation or examples.&lt;/P&gt;&lt;P&gt;Whatever it's 32 or 64 bits, it's the same VBA code. Just try what you have found for 32 bits, it will work.&lt;/P&gt;&lt;P&gt;Just to confirm, with simple parameters, and Early Binding (set the references in VBA editor):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Dim RFCFunc As SAPFunctionsOCX.Function
Dim SAPFunCtl As SAPFunctions

Set SAPFunCtl = New SAPFunctions

Set RFCFunc = SAPFunCtl.Add("Z_BAPI_ALM_ORDER_MAINTAIN_01")

RFCFunc.Exports("PARAM") = "value"

returnFunc = RFCFunc.Call

die_exception = RFCFunc.Exception

If returnFunc = False Then
    MsgBox "Exception " + die_exception + " when accessing function in SAP ! "
Else
    return = RFCFunc.Imports("RETURN").Value
End If&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;NB: alas I don't know any official documentation.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 06:48:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632252#M4738539</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-09-18T06:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating a RFC BAPI using VBA (Excel)</title>
      <link>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632253#M4738540</link>
      <description>&lt;P&gt;Good day Sandra, &lt;/P&gt;&lt;P&gt;Thanks again for your reply.  I have done additional testing and am throwing an 'SAP Remote Function Call' error at the location noted in the code.  If you have any thoughts on why this might be happening, I'm all ears but I imagine it could be many things?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Public Sub LogonAndRunRFCTest()

Dim sapLogon As SAPLogonCtrl.SAPLogonControl
Dim sapConn As SAPLogonCtrl.Connection

Set sapLogon = New SAPLogonControl
Set sapConn = sapLogon.NewConnection

'Actual arguments provided in testing
With sapConn
    .System = "{System}"&lt;BR /&gt;    .ApplicationServer = "{ApplicationServer}"&lt;BR /&gt;    .SystemNumber = "{SystemNumber}"             '&lt;BR /&gt;    .Client = "{Client}"&lt;BR /&gt;    .User = "{User}"&lt;BR /&gt;    .Password = "{Password}"&lt;BR /&gt;    .Language = "EN"
End With

Call sapConn.Logon(0, True)

'Check if the connection is successful
If sapConn.IsConnected &amp;lt;&amp;gt; tloRfcConnected Then
    MsgBox "connection failed. " &amp;amp; sapConn.IsConnected
    Exit Sub
Else
    MsgBox "Connection Successful!!! - Code " &amp;amp; sapConn.IsConnected '&amp;lt;--- I get this message!
End If

'After successful connection
Dim SAPFunCtl As New SAPFunctionsOCX.SAPFunctions
Dim RFCFunc As New SAPFunctionsOCX.Function
Dim returnFunc As New SAPFunctionsOCX.Function
Dim die_exception As New SAPFunctionsOCX.Function
Dim returnMsg As New SAPFunctionsOCX.Function

SAPFunCtl.Connection = sapConn
MsgBox "Got to this message without issue"  '&amp;lt;---- I get this message!

RFCFunc = SAPFunCtl.Add("Z_BAPI_ALM_ORDER_MAINTAIN_01")  '&amp;lt;--- Exception Thrown {Run-Time Error '1001' SAP Remote Function Call}

'Send Parameter (this is untested as I am throwing an exception in the preceeding line)
RFCFunc.Exports("NUMBER") = "4134440"
returnFunc = RFCFunc.Call

die_exception = RFCFunc.Exception

If returnFunc = False Then
    MsgBox "Exception " + die_exception + " when accessing function in SAP ! "
Else
    returnMsg = RFCFunc.Imports("RETURN").Value
End If

End Sub&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Sep 2022 13:00:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632253#M4738540</guid>
      <dc:creator>former_member817179</dc:creator>
      <dc:date>2022-09-18T13:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating a RFC BAPI using VBA (Excel)</title>
      <link>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632254#M4738541</link>
      <description>&lt;P&gt;Update: 2022-09-419 2:18 PM (EST)&lt;/P&gt;&lt;P&gt;Good day Sandra, so a bit of an update. The exception {Run-Time Error '1001' SAP Remote Function Call} was occurring because I did not have proper RFC authorizations on the SAP back-end. When that was changed and the code rerun, an exception was thrown on the same line but now reads {Class not registered}. I do not think I have the code correct below (perhaps?) particularly around the later half of the code?&lt;/P&gt; 
&lt;PRE&gt;&lt;CODE&gt;Dim sapLogon As SAPLogonCtrl.SAPLogonControl
Dim sapConn As SAPLogonCtrl.Connection

Set sapLogon = New SAPLogonControl
Set sapConn = sapLogon.NewConnection

'Actual arguments provided in testing
With sapConn
    .System = "{SYSTEM}"
    .ApplicationServer = "{ApplicationServer}"
    .SystemNumber = "{SystemNumber}"             '
    .Client = "{Client}"
    .User = "{User}"
    .Password = "{password}"
    .Language = "EN"
End With

Call sapConn.Logon(0, True)

'Check if the connection is successful
If sapConn.IsConnected &amp;lt;&amp;gt; tloRfcConnected Then
    MsgBox "connection failed. " &amp;amp; sapConn.IsConnected
    Exit Sub
Else
    MsgBox "Connection Successful!!! - Code " &amp;amp; sapConn.IsConnected '&amp;lt;--- I get this message!
End If

'After successful connection
Dim SAPFunCtl As New SAPFunctionsOCX.SAPFunctions
Dim RFCFunc As New SAPFunctionsOCX.Function
Dim returnFunc As New SAPFunctionsOCX.Function
Dim die_exception As New SAPFunctionsOCX.Function
Dim returnMsg As New SAPFunctionsOCX.Function

SAPFunCtl.Connection = sapConn
MsgBox "Got to this message without issue"  '&amp;lt;---- I get this message!

'The original exception - {Run-Time Error '1001' SAP Remote Function Call} - is not thrown
RFCFunc = SAPFunCtl.Add("Z_BAPI_ALM_ORDER_MAINTAIN_01")  '&amp;lt;--- New Exception Thrown {Run-Time Error '-2147221164' Class not registered}

'Send Parameter (this is untested as I am throwing an exception in the preceeding line)
RFCFunc.Exports("NUMBER") = "4134440"
returnFunc = RFCFunc.Call

die_exception = RFCFunc.Exception

If returnFunc = False Then
    MsgBox "Exception " + die_exception + " when accessing function in SAP ! "
Else
    returnMsg = RFCFunc.Imports("RETURN").Value
End If

End Sub&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Sep 2022 18:32:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632254#M4738541</guid>
      <dc:creator>former_member817179</dc:creator>
      <dc:date>2022-09-19T18:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating a RFC BAPI using VBA (Excel)</title>
      <link>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632255#M4738542</link>
      <description>&lt;P&gt;Hello John,&lt;/P&gt;&lt;P&gt;"Class not registered" sounds like a problem on Windows COM level. I am not familiar with the RFC controls/OCX used here, but I think I remember there are three or four ocx libraries. Perhaps one of them has not yet been registered as COM library?&lt;/P&gt;&lt;P&gt;In any case, let me also recommend a different solution: instead of the old OCX controls, have you also thought about using the .NET Connector (NCo)? It can also be used for making RFC calls from Excel or VB scripts and it has two advantages: it's up-to-date technology, and there is lots of documentation and samples. (Samples are mainly in C#, but there is also a short tutorial in VB.NET)&lt;/P&gt;&lt;P&gt;See &lt;A href="https://support.sap.com/nco" target="test_blank"&gt;https://support.sap.com/nco&lt;/A&gt; &lt;BR /&gt;Current version 3.0 is supported until Dec. 2023, but a new version 3.1 is going to be released in a couple of weeks.&lt;/P&gt;&lt;P&gt;Best Regards, Ulrich&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 08:54:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/instantiating-a-rfc-bapi-using-vba-excel/qaa-p/12632255#M4738542</guid>
      <dc:creator>Ulrich_Schmidt1</dc:creator>
      <dc:date>2022-10-18T08:54:39Z</dc:date>
    </item>
  </channel>
</rss>

