Announcement:
wanna exchange links? contact me at sapchatroom@gmail.com.
Posted by
Admin at
Reply from mrg1968 on Aug 18 at 2:10 PM @Wes, @Horacio: I tried just now the use of RFC_READ_TABLE and in this way I found what I needed (I replicated the functionality of BAPI_GL_ACC_EXISTENCECHECK) : Set objRfcFunc = sapConn.Add("RFC_READ_TABLE") objRfcFunc.Exports("QUERY_TABLE") = "SKB1" objRfcFunc.Exports("DELIMITER") = "|" Dim optsObj As Object Set optsObj = objRfcFunc.Tables("OPTIONS") Call optsObj.appendrow optsObj(1, "TEXT") = "BUKRS EQ 'C100' AND SAKNR EQ '0000000001'" Dim fldObj As Object Set fldObj = objRfcFunc.Tables("FIELDS") Call fldObj.appendrow fldObj(1, "FIELDNAME") = "SAKNR" Rem *** BAPI Call *** If objRfcFunc.Call = False Then ErrorMsg = objRfcFunc.Exception 'Message collection MsgBox ErrorMsg, 16, "Errore" InsertCash = False sapConn.Connection.Logoff Exit Sub End If Dim tabReturn As Variant Set tabReturn = objRfcFunc.Tables("DATA") returnedRows = tabReturn.RowCount if returnedRows=0 then MsgBox "Don't exist" else MsgBox "Exist" end if sapConn.Connection.Logoff However I simply don't understand why I'm getting the 'Error 0' problem with the BAPI itself calling it directly. I found a way to bypass the problem (and that's good!) but I consider it not solved at the moment. I want - If all of you are ok with me - leave this thread open to see if something else is coming out to solve the 'Error 0' problem. At the moment, please accept my sincere thanks to all of you *gurus*! Mauro
| | | ---------------Original Message--------------- From: Mauro Re Garbagnati Sent: Thursday, August 16, 2012 6:29 AM Subject: SAP RFC Call Returns Error in Return Parameter from Vb Before the RFC Call Hi everybody. I'm trying to call a SAP BAPI using RFC from vb but I'm having some problem to get the result of the call. The BAPI "BAPI_GL_ACC_EXISTENCECHECK" (from General Ledger Account module) has two parameters, COMPANYCODE and GLACCT, and a RETURN parameter. I wrote the attached piece of code to make the call and I had no problem to establish the SAP Connection (I use the SAP Logon Control OLE/COM object to do the job). I then instantiate the input Parameters COMPANYCODE and GLACCT and again no problem. However, when I try to instantiate the RETURN parameter (the result), I get an 'Error 0' in it. The strange thing is that when I make the call it gives no error because the RFC call returns true and no exception. However, looking through the objReturn object/parameter, it has a value "Error 0" in it. I was expecting a complex structure like the BAPIRETURN object in SAP or something similar if the account doesn't exist. BTW, Final Notes: the user that makes the call has SAP_ALL / SAP_NEW authorization 'BAPI RFC Call Set objRfcFunc = sapConn.Add("BAPI_GL_ACC_EXISTENCECHECK" ) objRfcFunc.exports("COMPANYCODE") = "C100" objRfcFunc.exports("GLACCT") = "0000000001" Dim objReturn As Object Set objReturn = objRfcFunc.imports("RETURN") Rem *** BAPI CALL *** If objRfcFunc.Call = False Then ErrorMsg = objRfcFunc.Exception 'Message collection MsgBox ErrorMsg, 16, "Error" sapConn.Connection.logoff Exit Sub End If Thanks in advance for your precious answers or suggestions ... | | Reply to this email to post your response. __.____._ | In the Spotlight Become a blogger at Toolbox.com and share your expertise with the community. Start today. _.____.__ |