Reply from mrg1968 on Aug 19 at 3:18 PM Hi, Louis. As I said in the opening of the problem, I get 'Error 0' BEFORE the RFC call ("However, when I try to instantiate the RETURN parameter (the result), I get an 'Error 0' in it. "). Initially I was trying with this piece of code:
'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") 'HERE I GET 'ERROR 0' Rem *** BAPI CALL *** If objRfcFunc.Call = False Then ErrorMsg = objRfcFunc.Exception 'Message collection MsgBox ErrorMsg, 16, "Error" sapConn.Connection.logoff Exit Sub End If Then I changed with this piece of code:
'BAPI RFC Call Set objRfcFunc = sapConn.Add("BAPI_GL_ACC_EXISTENCECHECK" ) objRfcFunc.exports("COMPANYCODE") = "C100" objRfcFunc.exports("GLACCT") = "0000000001" Rem *** BAPI CALL ***If objRfcFunc.Call = False Then ErrorMsg = objRfcFunc.Exception 'Message collection MsgBox ErrorMsg, 16, "Error" sapConn.Connection.logoff Exit Sub else Dim objReturn As Object Set objReturn = objRfcFunc.imports("RETURN") 'HERE I GET 'ERROR 0'End If So it's not the return from the RFC that gives 'Error 0'. Changing the order (instantiate the Return object after the RFC call) doesn't change the problem, and I get always 'Error 0' both if I try with an existing account or not existing account. For this I thought it was a communication bug between SAP and the local PC from which I make the call. So I changed the PC from which doing the call, but the problem remained the same (on the first PC I had SAP GUI 6.20 now I'm working with SAP GUI 7.20). Just my two cents, I can't find a solution in the result but I'm bypassing it. I think it's good to keep this thread live/open so if someone else is encountering this kind of problem can give his opinion/answer/solution on this ... Thanks you all however again for all your patience ... 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. __.____._ | _.____.__ |