GoodsMovement BAPI from VBA

Advertisement
Hi,
I am trying to retrive material document data through the BAPI_GOODSMVT_GETITEMS. In the following code, the connection works fine, but when I get to the line:
Set matdocitems = MatDoc.GetItems(mat)
I get an error:
"Run-time error '8793'. An exception was raised in the RFC system. The connection was automatically closed by the system.
Exception: RFCTYPE_UNKNOWN_HANDLE.
Error-key: rfc system error raised
Description: for more information: see tracefile_rfc
cpic-status: ???
Internal state: ???
Please help
Sub Button1_Click()
    Dim objBAPIControl As Object
    Set objBAPIControl = CreateObject("SAP.BAPI.1")
    Call ConnectToSAP(objBAPIControl, True)
    Dim mat As Object
    Set mat = objBAPIControl.GetSAPObject("BUS1001", "000000000001032197")
    Dim MatDoc As Object
    Set MatDoc = objBAPIControl.GetSAPObject("BUS2017")
    MsgBox ("Starting GetItems")
    Dim matdocitems As Object
    Set matdocitems = MatDoc.GetItems(mat)
    Call ConnectToSAP(objBAPIControl, False)
    MsgBox "Program done!", 0, "Exit"
End Sub
Advertisement

Replay

Hi, how are you?
Look, it's easy to do a rfc call to SAP.
But, if you look in the Netweaver Developer Studio 7.1, the SAP CONNECTOR is deprecated. So, my recomendation is to convert your RFC's to Web Services, and consume them like that, you won't have any problem with SOAP.
Regards,
Sebastiá