We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE:[sap-dev] SAP RFC Call Returns Error in Return Parameter from Vb Before the RFC Call

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from sapwes on Aug 17 at 1:51 PM
Here is a sample from something I had around. You will need to adapt it to your own needs.
The input table "options" contains the where clause.
The input table "fields" contains the field list of values to return from the query
You can add to input tables using Appendrow


Dim codes2 = bapi.Add("RFC_READ_TABLE")
codes2.exports("QUERY_TABLE") = "MSEG"
codes2.exports("DELIMITER") = "|"

Dim Opts As Object = codes2.Tables("OPTIONS")
Opts.Appendrow()
Opts(1, "TEXT") = "MJAHR EQ 2011 AND AUFNR EQ '001000375125'"

Dim fld As Object = codes2.tables("FIELDS")
fld.appendrow()
fld(1, "FIELDNAME") = "MBLNR"
fld.appendrow()
fld(2, "FIELDNAME") = "RSNUM"
codes2.call()
Dim tab As Table
tab = codes2.Tables("DATA")
returnedRows = tab.RowCount
aValue = tab.cell(x,y)

Be careful if you loop on this as the input tables stay populated between calls
use .freetable() to remove the rows
Horacio - Yeah he can look online but if you've never done it before the syntax is obtuse.
Wes

---------------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.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2012 Toolbox.com and message author.
Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251
sapwes  
Jack
achievements
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Earn Recognition for Your Contributions at Toolbox for IT. Gain Points for Community Achievements

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language