Logon from VBA to R3
I have following code to connect from VBA to R3
If I use SilentLogon = True, It will be fail.
If I use SilentLogon = False, logon screen will popup, directly click logon will be fail too.
If I use SilentLogon = False, logon screen will popup and I select the existing system that I have, fill all the same information in this code and logon, the connection run successfully.
In this situation where I'm wrong ?
Can I debug to see which parameter I typed wrong ?
Thank you.
Halomoan
Sub connectR3()
Set LogonControl = CreateObject("SAP.LogonControl.1")
Set R3Connection = LogonControl.NewConnection
R3Connection.Client = "130"
R3Connection.ApplicationServer = "10.10.6.10"
R3Connection.Language = "EN"
R3Connection.User = "user1"
R3Connection.Password = "tiger"
R3Connection.System = "00"
SilentLogon = True
retcd = R3Connection.Logon(0, SilentLogon)
If retcd <> True Then
MsgBox "Logon Failed"
else
Msgbox "Logon Success"
R3Connection.Logoff
End if
End Sub
too much to think about, just use this:
Set FunctionCtrl = CreateObject("SAP.Functions")
Set SapConnection = FunctionCtrl.Connection
SapConnection.client = "<Client>"
SapConnection.user = "<logon user>"
SapConnection.password = "<Logon Password>"
SapConnection.language = "EN"
SapConnection.HostName = "<hostanme>"
SapConnection.SystemNumber = "<SySnr>"
If Not SapConnection.Logon(0, True) Then
msgbox ("not Connected")
else
msgbox ("connected")
End If
SapConnection.logoff
Similar Messages
-
Call BEX-Query from VBA with BEX-automatic login?
Hi,
I'm trying to call a query from VBA. I have two problems/questions:
1. Automatic login?
I want to do an automatic login. I found this peace of code here, but I get an error:
Public Function LogonToYourBW()
' create Logon & RFC-Handle
logonToBW = False clear connect Flag the flag can be used to find out if connected or not
'load SAP functionality by opening BEX file ( use your installation path)
Workbooks.Open (c:\sappc\bw\sapbex.xla)
With Run("sapbex.xla!sapbexGetConnection") call the connection
' Set the params for Auto logon
.client = YOUR CLIENT NO
.user = YOUR BW USER
.Password = YOUR BW PWD I recommend to create a dummy reporting user for this task
.Language = YOUR LANGUAGE YOU LIKE TO USE FOR QUERY DISPLAY ( i.E. EN)
.SystemNumber = YOUR SYSTEM NO
.ApplicationServer = YOUR SERVER Name OR IP-ADDRESS
.UseSAPLOgonIni = FALSE 'important for automatic connection
.logon 0, True This will provide a dialog to appear
If .IsConnected <> 1 Then
.logon 0, False
If .IsConnected <> 1 Then Exit Function
Else
Set g_oFunction = CreateObject("SAP.Functions")
Set g_oFunction.Connection = g_oConnection
End If
End With
Run "sapbex.xla!sapbexinitConnection" this will enable the connection you just created
logonToBW = True
End Function
The error is by this row:
Set g_oFunction.Connection = g_oConnection
Object is needed! How is the g_oConnection-object defined?
2. How can I pass values for the parameters from VBA?
If I open the query usually from SAP-BEX-Toolbar, after selecting the query, I get a parameter mask, where I must put in a value. How can I this automatize from VBA? Has anybody a short samplecode for that?
Thank you for your help
Stefan
[email protected]Peter and others:
What I really want to do is write a stand-alone application that I can run from windows scheduler that queries our BW for sales data for certain items (in a tabular form) and pulls that data into a VB recordset, or a .NET dataset so that I can insert the rows into another database (SQL Server, or Access) I already know how to do all the data movement to/from datasets and databases I just cannot figure out how to programmatically grab this sales data from BW our company has workbooks already set up that aggregate WW sales information by region (IE, there is a separate workbook for each region of the world) I can manually go into the Excel interface, tell it which items to pull the sales info for, and it dumps the data into the worksheet (organized by customer, and then by cat #)
So, what Id like to do is write an app that will pull data every week or so from the BW (from each regions sales invoice detail workbook), and insert it into another database that we use for reporting other, non-sales, data.
Thoughts on this ? Is there another, non-BEx method that is better ?
thanks !! -
Hi all,
I would like to call RFC funtions from VBA, could you please advise on what library should I set reference to?
A piece of sample code would also be highly appreciated.
Thanks in advance.
Tomashere is a small code sample using vbscript
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>RFC Example - THUSRINFO</title>
<script language="VBScript">
sub get_cust_data()
dim fns
set fns = createobject("SAP.Functions")
fns.logfilename = "my_log.txt"
fns.loglevel = 6
dim conn
set conn = fns.connection
conn.ApplicationServer = "application server name or ip address"
conn.System = "DEV"
conn.user = document.myf.t1.value
conn.password = document.myf.t2.value
conn.Client = "025"
conn.Language = "E"
conn.tracelevel = 6
if conn.logon(0, true) <> true then
exit sub
end if
dim myfunct
set myfunc = fns.add("THUSRINFO")
result = myfunc.Call
the_exception = myfunc.exception
dim users
if result = true then
set users = myfunc.tables.item("USR_TABL")
document.write "Table USR_TABL, " & users.rowcount & " rows"
document.write "<table border=1>"
document.write "<tr>"
document.write "<td>BNAME</td>"
document.write "<td>MANDT</td>"
document.write "<td>TCODE</td>"
document.write "<td>TERM</td>"
document.write "<td>ZEIT</td>"
document.write "<td>HOSTADR</td>"
document.write "<td>RFC TYPE</td>"
document.write "</tr>"
for each user in users.Rows
document.write "<tr>"
document.write "<tr>"
document.write "<td>"
document.write trim(user("BNAME"))
document.write "</td>"
document.write "<td>"
document.write trim(user("MANDT"))
document.write "</td>"
document.write "<td> "
document.write trim(user("TCODE"))
document.write "</td>"
document.write "<td> "
document.write trim(user("TERM"))
document.write "</td>"
document.write "<td>"
document.write trim(user("ZEIT"))
document.write "</td>"
document.write "<td>"
document.write trim(user("HOSTADR"))
document.write "</td>"
document.write "<td> "
document.write trim(user("RFC_TYPE"))
document.write "</td>"
next
document.write "</table>"
set users = nothing
end if
fns.connection.logoff
Set fns = nothing
Set conn = nothing
end sub
</script>
</head>
<body>
<form method="POST" name="myf">
User Id <input type="text" name="T1" size="20"></p>
<p>Password<input type="password" name="T2" size="20"></p>
<p> </p>
<p><input type="button" value="Submit" onclick="get_cust_data()" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
Regards
Raja -
Link to SAP R/3 Logon from Portal IView
Hi,
How is the Link to SAP R/3 Logon from Portal IView?
Thanks
RaissaHi Raissa,
Check these links
Configuring EP for connecting to SAP R/3
Creating system object
http://help.sap.com/bp_epv260/EP_EN/documentation/EP/N03_BB_InstallGuide_EN_US.doc
Regards
Arun -
I want to execute a addon of R3 from VBA.
Dear all.
(sorry not good English)
I want to execute a addon of R3 from VBA.
The addon have 'commit' multiple times.
I am using "RFC_CALL_TRANSACTION_USING" from VBA.
but, addon is finished by one commitment processing.
I want to execute a addon continuously after having committed it.
like a "Cont.after commit" of Recoding parameters of SHDB.
Please give me advice other methods or other Function Module.
best regards.Thank you for an answer.
SLIN understands it with a syntax check of the addon.
It is a program practice method from VBA to want to know me.
Would you give me any advice ? -
Acrobat X: improved functions from VBA?
Hello,
I use Acrobat to print create some PDF files from Excel 2010, from Visual Basic for Applications (VBA).
Are there any new and improved functions in VBA for Acrobat X? What is the best/fastest way to print to PDF from VBA in Excel 2010 for Acrobat X?
I currently use something like:
Selection.PrintOut Copies:=1, _
ActivePrinter:="Adobe PDF", _
Collate:=True, _
PrToFileName:=myfileA
Set PDFDistillerApplication = New PdfDistiller
Result = PDFDistillerApplication.FileToPDF(myfileA, myfileB, "")
Is there a better way?
Thanks for any help.Basically I'm just filling a PDF form by getting it's fields and setting their values by the objects/methods below:
Set gApp = CreateObject("AcroExch.app")
Set avDoc = CreateObject("AcroExch.AVDoc")
Set theForm = CreateObject("AcroExch.PDDoc")
theForm.Open (folder & fileDef)
Set jso = theForm.GetJSObject
jso.getField("10").Value
Again, thanks for any advice. -
Connect from VBA 64 bit to Oracle from windows 7 64bit
Hi,
We are trying to connect from Autocad VBA 64 bit to Oracle 10g server from windows 7 64bit OS.
Toad can connect to Oracle without any issue.
I installed 10g 32 bit client and 11g 64 bit client.
Please help me in installing and configuring any 64 bit provider to connect from vba. I tried ODAC but not any success until now.
Regards,
ShijithHi Jenny,
Thanks for replaying in quick time.
I had solved my issue by installing the following.
1) Oracle forms 6i
2) Oracle 11g 32 bit client
3) Oracle 11g 64 bit client
4) ODAC 11g 32 bit
5) ODAC 11g 64 bit
And able to get a sucessful connection with the following connection string.
Provider=OraOLEDB.Oracle;Password=dddd;Persist Security Info=True;User ID=dddd;Data Source=ddddd
Is there is any better way to do it? It is realy pitty that we have to install more than 2GB of client coponents to get a oracle connection from client side.
Please suggest a best practice.
Regards
shijith -
Restrict User Logon from multiple systems
I want to know how can I restrict a user logon from multi systems. That means user 'manager' must be connected to the server only from 1 client system at a time. Is it possible? If yes then how?
@VHNGhi,
I'm afraid this is not possible current versions,In future releases SAP will restrict 1 session for a user id,
For details Check it in SAP Business One 8.8 Central Information
https://websmp201.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000705857&_SCENARIO=01100035870000000183&_ADDINC=011000358700001192682007E&
Jeyakanthan -
What is best option to Create an Annotation in PDF from VBA?
It appears thwere are 2 ways to create an annotation (Like a sticky note) via scritping into a PDF File from VBA
1. In VBA use the Acrobat Interapplication Communication via OLE to use AcroExch.PDAnnot
2. Use AcroJS from a VBA call
My question is:
What are the pros and cons of each - is one better than anohter/
How do I call Acro JS from VBA?
thanksayman hamdan01 wrote:
hi all
i read and learn about (( tablespaces and datafiles)) and all option and types like (local , dictionary , autoextend , reuse,segment manual and auto , autoallocate,logging , storage ..etc) , if you are real dba in software company . what is your plan to create best tablespace and datafile ?
thanks alot
Edited by: ayman hamdan01 on May 17, 2013 7:58 AMwhich metric measures "best"?
Is it fewest characters in SQL statement? -
Hi Guys,
Is it possible to remote logon from client 001 to other systems?
to be moer clear, I have a SCM system client 001 and create a RFC destination to R/3 say client 600. Will it be possible to remote logon from SM59 to R/3?
It is not happening for me. it is neither giving any error nor opening the logon screen. Or even logon. What am I missing?
Points guaranteed.
--RaguHi Ragu,
It is possible to remote login from client 001 to other system clients.
While you configuring make sure that the user must be having S_RFC autorisation object.
In SM59 specify IP Adress insted of host name and check authontication test.
If it is sucess user id password is correct and make sure that you have given Dialog/service user in SM59 logon& security tab.
Thanks,
Suraj -
I want to exit SAP logon from my program.
Hi,
I want to exit SAP logon from my program.
Is there a FM that does this?
(How can I execute '/nex' from my program?)
How can I do so?
Thanks.Hi Kumar,
I am working on 4.7ee version.
I have similar requirement that for one user id we have option to logon multiple times, but now I have to control based on terminal id and SAP session ID, if user logon more than one time from the same terminal, program should read and end the second logon session.
Please let me know if you have any idea on this regard...
Thanks in advance....
Venkat -
Scripting from VBA when scripting is disabled on the server?
Hello All,
I am wondering if it is possible to perform GUI scripting from Excel or MS Access when the scripting functionality has been disabled on the server? I know it is not possible using the Script Recording and Playback, but not sure within VBA?
If possible, can anyone please provide examples? That would be a great help.
Thanks!
Emil JakupovicHI
I have been able to use Visual basic scripting (*.VBS) to automate sapgui to a certain extent . see the code below this allows u to logon to sap and use certain transactions using the "sendkeys" function even if scripting is diabled on the sap server. but the functionality is limited like you cant use it in background mode etc so see if this helps
set objShell = CreateObject("WScript.Shell")
'===Activate SAP logon pad engine
set application = CreateObject("Sapgui.ScriptingCtrl.1")
'===Initiate one of the predefined SAPlogon pad connection
set SapGui = GetObject ("SAPGUI")
set application = SapGui.GetScriptingEngine
set connection = application.OpenConnection("<SERVER DESRIPTION AS IN SAP LOGON PAD>", True)
WScript.Sleep(10000)
objShell.SendKeys "<USERNAME>"
objShell.SendKeys "{TAB}"
objShell.SendKeys "PASSWORD"
objShell.SendKeys "{ENTER}"
WScript.Sleep(10000)
objShell.SendKeys "/nSP01"
objShell.SendKeys "{ENTER}" -
Calling BAPI from VBA - type mismatch error
Hi,
I am trying to retrieve data from SAP R/3 material documents to Access VBA. In the example below, the connections works fine, but when I assign the value to the parameters, fx:
MatDocItems.exports("MATERIAL_RA") = "000000000001032197",
I get an error in vba: Run-time error 13: Type mismatch.
A similar code works fine with USER_GETLIST, and I am thinking that the problem is related to the multiline check box in BAPI_GOODSMVT_GETITEMS.
Hope someone can help,
Simon
Sub MatDocItemsBAPI()
Dim Destination_System As Integer
Dim objBAPIControl As Object
Dim sapConnection As Object
Set objBAPIControl = CreateObject("SAP.Functions")
Set sapConnection = objBAPIControl.Connection
sapConnection.client = "xxx"
sapConnection.User = "xxx"
sapConnection.Language = "xxx"
sapConnection.hostname = "xx.xx.xx.xx"
sapConnection.Password = "xxxxx"
sapConnection.SystemNumber = "xx"
sapConnection.System = "xxx"
sapConnection.Destination = "xx"
If sapConnection.logon(1, True) <> True Then
MsgBox "No connection to R/3!"
Exit Sub
End If
Set MatDocItems = objBAPIControl.Add("BAPI_GOODSMVT_GETITEMS")
MatDocItems.exports("MATERIAL_RA") = "000000000001032197"
MatDocItems.exports("TR_EV_TYPE_RA") = "WL"
MatDocItems.exports("USERNAME_RA") = "PABIT"
returnFunc = MatDocItems.Call
If returnFunc = True Then
Dim objTable As Object
Set objTable = MatDocItems.Tables("GOODSMVTHEADER")
MsgBox ("Row count :" & objTable.ROWCOUNT)
Else
MsgBox "Error when accessing BAPI in R/3 ! "
Exit Sub
End If
objBAPIControl.Connection.logoff
Set sapConnection = Nothing
Set functionCtrl = Nothing
MsgBox "Program done!", 0, "Exit"
End Subwrong forum.
-
Hello all ;
I have an Excel spreadsheet that was created by 'exporting' from an SAP ByDesign form. I want to automatically refresh the spreadsheet. Does anyone know the vba code to logon to SAP ByDesign and 'refresh all'?.there are more different ways to get logo design by[ online printing service|http://www.sireprinting.com/cat/stickers]
-
How can I call a variable from VBA in Diadem report?
Hello,
I have a script in Diadem, script that I can control from a VBA application ( from Excell), and I want to send from Excell some details to the report.
I want in the report, the Local Test Order field to by the LocalTO from the VBA (Excell), the DVM Test Order fiel to be the DVMTO from Excell, and ..... al the fields from the excell to be in the report.
And in the Diadem script the filename of the export .pdf file to be the filename from the Excell.
Attached I put the script from Diadem and the VBA application.
Thank you for your time.
Attachments:
Diadem.zip 28 KBHello Marse!
Sorry that I was not clear enough and add the hwo-to via OLE
For way 1. you have to add this lines to your Excel VBA code:
loadscript = IDIACommand.TextVarSet("T1","Value of T1")
For way 2. it is:
loadscript = IDIACommand.CmdExecuteSync("GlobalDim('MyGlobalVar'")
loadscript = IDIACommand.VariantVarSet("MyGlobalVar","Value of MyGlobalVar")
Inserted before your line
loadscript = IDIACommand.CmdExecuteSync("scriptstart('C:\BForce\LIBR\BForce2.VBS')")
Hope it is clear now! Otherwise feel free to ask
Matthias
Message Edited by Twigeater on 10-10-2008 09:43 AM
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?
Maybe you are looking for
-
I upgraded my iPhone 4S to iPhone 5c... My sister is planing to have my old 4s but we have gone to delete stuff eg contacts but those contact have then automatically deleted of my iPhone 5c ... I'm not sure if this is to do with the same icloud accou
-
Looking for a Good Newer or at least better Graphics Card For M58 ThinkCentre
I'm trying to find a graphics card for my M58 ThinkCentre. I know it needs to be low profile. but i need something that will fit into my Pc. I got one of the low profiles before and found out the fan was to big even with the case off i couldnt fit it
-
Replication of Item Categories from R/3 to CRM
Hi, How can we replicate Item Categories and Item Category Determination from R/3 to CRM. Could you please let me know detail steps as I am new to middleware. Thanks in advance. Sai
-
Siri no longer understands my voice commands.
Since the 6.01 update, Siri is now worthless. It does not understand my voice command. When using Siri to "Call Home" it will pick someone in my address book that has nothing whatsoever to do with my "home". What happened to Siri since the "update"?
-
Rating a RAW thumbnail causes it to rotate and lock.
I use Bridge (CS3) to examine all the RAW files from my shoots and select the best for further processing in ACR. To do this I rate the thumbnails/images using the star system. This works OK for RAW images that are in landscape (horizontal) format, b