‎2010 May 19 3:25 PM
Option Compare Database
Option Explicit
Dim attachpath1, headers, attachpath2 As String
Dim sFileName As String
Dim R3, MyFunc, App, objFileSystemObject, filOutput, objmessage As Object
Dim nTotalRecords As Long
Dim QUERY_TABLE As Object
Dim DELIMITER As Object
Dim NO_DATA As Object
Dim ROWSKIPS As Object
Dim ROWCOUNT As Object
Dim OPTIONS As Object
Dim FIELDS As Object
Dim tDATA As Object
Dim ROW As Object
Dim Result As Boolean
Dim iRow, iColumn, iStart, iStartRow, iField, iLength As Integer
Dim var_return As String
Public Function RFC_READ_TABLE_MLEA()
'**********************************************
'Create Server object and Setup the connection
'**********************************************
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
attachpath1 = "C:\MLEA.rtf"
Set R3 = CreateObject("SAP.Functions")
R3.Connection.system = "***"
R3.Connection.client = "***"
R3.Connection.User = "my username"
R3.Connection.Password = "my password"
R3.Connection.language = "EN"
R3.Connection.applicationserver = "******"
If R3.Connection.logon(0, True) <> True Then
MsgBox "No connection to R3!"
var_return = " has Failed"
sendmessage (var_return)
Exit Function
End If
**Can anyone please advise why this would not work ?
I recieve the error dialog box "No connection to R3". Anyone know what I am missing ?
‎2010 May 19 7:08 PM
Hi,
I use:
R3.Connection.SystemNumber = 0
R3.Connection.ApplicationServer = '172.16.7.1'If don´t work, try:
R3.Connection.LogOn(0,false)... only to see if you can connect.
Also make a test with: http://www.mengue.com.br/files/QuerySap.zip
Best regards,
Leandro Mengue
‎2010 May 20 2:56 PM
'R3.Connection.SystemNumber = "0"
That didnt work
and I'm using R3.Connection.Logon ! that's how I know that it's connecting to SAP, because the argument returns false, and I get my dialog box.
‎2010 May 20 3:37 PM
Aren't you missing the not equal operator in the following line?
If R3.Connection.logon(0, True) True Then
Edited by: Ana-Luisa Sixtos on May 20, 2010 4:41 PM
‎2010 May 20 7:02 PM
Good catch, but that was just a typo in this message. My actual code has it:
If R3.Connection.LogOn(0, True) not equal True Then
MsgBox "No connection to R3!"
var_return = " has Failed"
sendmessage (var_return)
I keep getting the "dialog box", which means my connection is not successful. not sure where im going.
i've tried this at another company and it worked..
‎2010 May 20 7:08 PM
Hi,
Try:
1) Analyse the file "dev_rfc.trc" that is created in the current directory where you are running the executable.
2) Check if the username is a "RFC" user (if has rights to connect via RFC).
Best regards,
Leandro Mengue
‎2010 May 20 7:22 PM
Thanks guys, but no i dont have that dev file.
It got created when I ran your exe program, so I deleted the file, and then re ran my VB, but no dev file now.
Couple of times it failed at hte other company was when I used the wrong connection server.
Is there a sure shot way of finding which is the correct r3.connection server ?
R3.Connection.applicationserver = "*****"
Currently I found the above through Status (then i take the value in host Data, and add .mycompanyname.com to it
thank you !
‎2010 May 20 7:31 PM
and if it helps, i did run your querysap.exe, AND was able to download the MLEA TABLE.
so then i took the server used above, and pasted that in my vb program, but no luck yet
‎2010 May 20 7:49 PM
Hi,
You try to connect with servername with IP address? (like 192.168.0.0 , ...)
Follow my code. Is not VB. Is Delphi.
Connection:=SAPLogonControl1.NewConnection;
Connection.User:=Ini.ReadString('Conexao','Usuario','');
Connection.Password:=Ini.ReadString('Conexao','Senha','');
Connection.Language:='PT';
Connection.Client:=Ini.ReadString('Conexao','Cliente','');
Connection.System:=Ini.ReadString('Conexao','Sistema','');
Connection.SystemNumber:=0;
Connection.ApplicationServer:=Ini.ReadString('Conexao','IP','');
if Connection.LogOn(0,True) then begin
SAPFunctions1.Connection:=Connection;
SAPFunctions1.RemoveAll;
Funct:=SAPFunctions1.Add('ZANDON');
opt4:=Funct.Tables.Item('PI_ZEVTANDON');
opt1:=Funct.Tables.Item('PI_ZINTFCEAND1');
opt2:=Funct.Tables.Item('PI_ZINTFCEAND2C');
opt3:=Funct.Tables.Item('PI_ZINTFCEAND3C');
opt1.FreeTable;
opt2.FreeTable;
opt3.FreeTable;
opt4.FreeTable;
endif.Best regards,
Leandro Mengue
‎2010 May 20 8:23 PM
right, i understand that, but what i'm really asking is how can i verify i'm using the correct APPLICATION SERVER ?
is there a way to find out wht my applicationserver should be ?
‎2010 May 20 9:01 PM
I checked the dev_rfc.trc file, and this is what's in it:
ERROR file opened at 20100520 155843 Eastern Daylig, SAP-REL 640,0,117 RFC-VER 3 815402 MT-SL
T:4544 Error in program 'MSACCESS': ======> Connect to SAP gateway failed
Connect_PM GWHOST=*********, GWSERV=sapgw11, ASHOST=********, SYSNR=11
LOCATION CPIC (TCP/IP) on local host
ERROR partner not reached (host *****, service
3311)
TIME Thu May 20 15:58:43 2010
RELEASE 640
COMPONENT NI (network interface)
VERSION 37
RC -10
MODULE nixxi_r.cpp
LINE 8688
DETAIL NiPConnect2
SYSTEM CALL SiPeekPendConn
ERRNO 10061
ERRNO TEXT WSAECONNREFUSED: Connection refused
COUNTER 1
so i know that the connection failed...any idea how I can resolve this now ?
thanks !!
‎2010 May 20 9:02 PM
Hi,
In SAP , go to menu "System" / "Status" , on the status screen click on the button "Other kernel info" and look to IP address.
Best regards,
Leandro Mengue
‎2010 May 20 9:22 PM
IT WORKED !!!!!!
THANK YOU...I CHANGED THE IP ADDRESS EARLIER TOO, BUT THIS TIME I ENTERED En instead of EN for language (by mistake)
anyhooo.it worked...thank you everyone !
‎2010 May 20 9:22 PM
> 'R3.Connection.SystemNumber = "0"
> That didnt work
Did you use the system number which corresponds to your SAP system? Otherwise it won't work. You'll find it in the SAP logon properties.