I want to automate a transaction on SAP using the playback script.
I record a transaction and then export it under excellent all while remaining on SAP, it works perfectly. (this is the Microsoft Excel icon, Ctrl+Shift+F7), this is an icon with an Excel sheet and a green cross on it.
When I open my script and execute it, the script itself works, the export works but there is no data when it existed when I did the transaction by hand.
I don't see why.
This happens in SAP GUI.
If Not IsObject(App) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set App = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = App.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject App, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "S_ALR_87012284"
.......
session.findById("wnd[0]/usr/cntlGRID1/shellcont/
shell/shellcont[1]/shell[1]").setDocument 1, ""
When I look at the excel sheet on SAP, I see that "/" and the sheet is called "~SAP{7BD014FE-F4CF-49DA-AAD5-FD"
Yet when I do it by hand, I see all my data.
Please deactivate the last command and it should work again.
...
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "S_ALR_87012284"
...
'session.findById("wnd[0]/usr/cntlGRID1/shellcont/
shell/shellcont[1]/shell[1]").setDocument 1, ""
Regards, ScriptMan
Related
I have a table that stores instruction book pages.
while working on the app and finished adding an instuction book, I found that that the table was over 200MB, however the PDF containing the pages was only 70MB 438 Pages.
The problem is that it saves the images as max quality. now i want to make a script that goes over every record opens the images and saves it again as medium compression.
I've made a record set and a loop to go through each record to change the compression, but but the app crashes half way the process.
No matter how i Change the code, it always crashes.
So i took an other approach and make a for loop of 200 records.
This wend well, but it didn't change the file size of the database???
The runtime error is an UnsupportedOperationException, as shown here:
This is the code:
dim rs as RecordSet
rs=lego.LegoData.SQLSelect("SELECT * FROM Books")
dim resize as Picture
while not rs.EOF
resize = picture.FromData(rs.Field("intructions").StringValue)
rs.Edit
rs.Field("intructions").StringValue = resize.GetData(Picture.FormatJPEG, Picture.QualityMedium)
rs.Update
rs.MoveNext
wend
Somehow it reads NIL after 200 records, but it's not NIL.
The error is not happening every time at the same record, it has its own will?
Any suggestions? I want to build-in a book image compression function as well so people can make the exported manual smaller.
The database file does not automatically get smaller if you remove or compact data inside it. You have to issue the VACCUM command (e.g. with SQLExecute("VACUUM")). You can issue that command only after committing, so first do a SQLExecute("COMMIT"). Or use a SQLite tool such as SQLVue to do that by hand.
If resize.GetData returns nil, it means that it can't read the data as JPEG. Maybe it's not in JPEG data but a GIF or something else. Try loading the data into a string first and look at it in the debugger, using the Binary (hex bytes) view to see what's up with it.
If you get an exception, wrap the code in an try block to keep the app from stopping, like this:
try
resize = picture.FromData(rs.Field("intructions").StringValue)
catch exc as RuntimeException
// The image could not be loaded - let's skip it
rs.MoveNext
continue
end try
I've found a solution to make the code faster, still having the crash
OutofMemorry exception
dim rs as RecordSet
dim pic as RecordSet
rs=lego.LegoData.SQLSelect("SELECT ID, SETID, Page FROM Books")
dim resize as Picture
dim count as Integer = 0
while not rs.EOF
pic = LegoData.SQLSelect("Select ID, Intructions FROM Books WHERE ID = " + Str(rs.Field("ID").IntegerValue))
if pic <> nil then
if len(pic.Field("intructions").StringValue) > 0 then
resize = picture.FromData(pic.Field("intructions").StringValue)
pic.Edit
pic.Field("intructions").StringValue = resize.GetData(Picture.FormatJPEG, Picture.QualityMedium)
pic.Update
if count = 100 then
LegoData.SQLExecute("COMMIT")
LegoData.SQLExecute("VACUUM")
count = 0
else
count = count + 1
end if
end if
end if
rs.MoveNext
wend
LegoData.SQLExecute("COMMIT")
LegoData.SQLExecute("VACUUM")
Before the crash its start updating my images with Nil
like 15 images before it crash
I am using QtQuick/QML/Qt5.2.1 on Android. I also tested this issue on the Desktop rather than Android and I see the same problem.
I use LocalStorage to persist application data after the application closes.
I open a database using openDatabaseSync:
var db = LocalStorage.openDatabaseSync(
"TestDB",
"1.0", <-- version
"Test Database",
1000000,
function(db) {
createSchema(db);
populateData(db);
}
);
If the database does not exist and was created, the callback function gets executed and in that case I create the database schema and populate the initial dataset.
The next time the application starts, obviously I want to keep the database as-is and not recreate it.
The problem is when I restart the application I get this error:
Error: SQL: database version mismatch
If I inspect the .ini file that was created when the database was created the first time the application was run, I see this:
[General]
Description=Test Database
Driver=QSQLITE
EstimatedSize=1000000
Name=TestDB
Version=
You can clearly see a problem here is that the "Version" attribute is empty.
When the application starts up, it compares the requested version "1.0" against this empty string "" and fails.
I can fake it to get it to work of course by specifying the version as "", or by fixing the ini file - that at least tells me the code is otherwise correct - but clearly that's not a solution.
So, did I miss something or is this a Qt bug?
You can set the database version after creating it:
var db = LocalStorage.openDatabaseSync(
"TestDB",
"1.0",
"Test Database",
1000000,
function(db) {
createSchema(db);
populateData(db);
db.changeVersion("", "1.0");
}
);
Since the callback function will only be called it the database doesn't exists, and the changeVersion function will only work if current version is "" (otherwise, exception is thrown), I believe it's safe to use it.
EDIT: Maybe this is the intended behaviour... from LocalStorage source code, line 700:
if (dbcreationCallback)
version = QString();
So, maybe you really need to set db version after you create your tables... before you do that on the callback, it's just an empty database, and shouldn't really have a version.
set the attributes like this in your above code
// db = LocalStorage.openDatabaseSync(identifier, version, description, estimated_size, callback(db))
LocalStorage.openDatabaseSync("kMusicplay", "0.1", "kMusicPlay app Ubuntu", 10000);
where
'kMusicplay' is appname ,
'0.1' is version ,
'kMusicPlay app Ubuntu' is app discription
and '10000' is size of database
I am New to Sqlite and LiveCode.I need to do some tasks with liveCode and SqlLite.Can anyone let me know what is suitable version of Sqlite for the LiveCode and from where i can download it as i am not finding anything sufficient information on the web regarding it.Thanks
There is a sqlite driver included in LiveCode. Just read up on the revDB functions and commands. This tutorial will probably help you out:
http://lessons.runrev.com/s/lessons/m/4071/l/30516-how-to-create-and-use-an-sqlite-database
The current version distributed with LiveCode is 3.7.4
In LiveCode 6 do the following
go to menu Help
choose Example Stacks and Resources
open the Examples folder
double click on SQLite Sampler.rev . The stack SQLite Sampler.rev contains explanations and code snippets.
Adapt the example code snippets to your needs.
For example the following snippet taken from that stack connects to a database AppReg3.db. The database is created if it does not exist yet.
gConID holds the connection identifier to refer to the database in later scripts.
# Connect button script
on mouseUp
global gConID
put revOpenDatabase("sqlite","AppReg3.db",,,,,,) into tConID
if tConID is "" then
answer warning "Problem creating or accessing database!"
else
answer information "AppReg Connected! Your connection ID is: " & tConID
put tConID into gConID
end if
end mouseUp
The following creates a table Users
on mouseUp
global gConID
if gConID is "" then
answer information "No Database is Connected to, please go back 1 step and connect to the Database!"
exit mouseUp
end if
put "CREATE TABLE users(userID integer primary key, name text,email text,emailList boolean)" into tSQL
put revExecuteSQL(gConID,tSQL) into tTmp
handleRevDBerror tTmp
if the result is not empty then
answer warning the result
exit mouseUp
end if
answer information "Number of Tables Added: " & tTmp
end mouseUp
I hava a Pass-Through sql-query in access which queries my mysql-db.
My current ODBC connection for the query is defined as follows:
ODBC;UID=access_frontend; PWD=hello#world; DSN=my_db_test;
If I change my ODBC connection from my test to my normal DB
ODBC;UID=access_frontend; PWD=hello#world; DSN=my_db;
If I save my changes and restart again, Access has changed it back to my_db_test.
Is there any place where I can globally change my ODBC connection?`
I do not get this problem changing in code or manually. You can change the connection through VBA:
Dim qdf As QueryDef
''dbQSQLPassThrough = 112
For Each qdf In CurrentDb.QueryDefs
If qdf.Type = dbQSQLPassThrough Then
Debug.Print qdf.connect
qdf.connect = "ODBC;filedsn=z:\docs\test.dsn;"
Debug.Print qdf.connect
End If
Next
You will notice that the passthrough query illustrated refers to:
filedsn=z:\docs\test.dsn;
This is another easy way of changing the connection, just change the DSN, in the above case, you could just edit the file test.dsn.
I have a requirement when a user clicks a specific arrangement of radio buttons to run a series of vbscripts (and soon Perl scripts).
I have all of the vbscripts stored server side, they do not need to be on the remote system to run. Oh yes, the scripts are gathering information on remote system in our intranet.
What would be the best way. Currently I have this to run just one script, not multiple...should I keep this or dispose of this idea.
Protected Sub windowsScript(ByVal COMPUTERNAME As String)
' Create an array to store VBScript results
Dim winVariables(1) As String
Dim filePath As String = COMPUTERNAME & "\C$\Windows\somefile.txt"
'Execute PsExec on script
runPsExec(COMPUTERNAME, "systemInfo.vbs", 1)
'Import data from text file into variables
textRead(filePath, winVariables)
System.Threading.Thread.Sleep(1000)
'Delete the file on server - we don't need it anymore
runPsExec(COMPUTERNAME, "systemInfo.vbs", 2)
MsgBox("Windows OS: " & winVariables(0).ToString())
MsgBox("Service Pack: " & winVariables(1).ToString())
End Sub
Also, it is hard to see here because I do have another function "textRead" but what is going on is this particular script is stored client side and the vbscript it outputting to a text file. textRead will read the variable and send a text file back to the server to read it.
This is definitely not what I want to do.
I want to be a little more dynamic, plus with my new scripts...they don't need to be on the client at all.
Any help would be appreciated :)
I'm thinking of making some type of While loop, not sure if that would work.
It's kind of strange to do this through the browser. In my company we collect systeminfo at logontime with a vbscript logonscript and add the result to a logfile which we can access through a webapp to do research. Occasionally when the need rises we run a specific script to gather more data or change some system setting through windows SCCM.
If the goal is to provide the user with info about his system there are some good utilities around which can be run locally (but from a location on a server share).
EDIT
a simple way to start multiple processes
dim scripts_to_run, script
const COMPUTERNAME = 0, SCRIPTNAME = 1, EXTRA_PARAMS = 2
scripts_to_run = Array(_
Array("computer1","script1.vbs",1),_
Array("computer2","script1.vbs",0),_
Array("computer3","script3.vbs",3)_
)
for each script in scripts_to_run
runPsExec script(COMPUTERNAME), script(SCRIPTNAME), script(EXTRA_PARAMS)
runPsExec join(script,",")
next
sub runPsExec(p1, p2, p3)
'here coms your code shat runs the script
wscript.echo p1 & p2 & p3
end sub
or a shorter version
dim scripts_to_run, aArgs
scripts_to_run = Array(_
Array("computer1","script1.vbs",1),_
Array("computer2","script1.vbs",0),_
Array("computer3","script3.vbs",3)_
)
for each aArgs in scripts_to_run
runPsExec aArgs
next
sub runPsExec(aArgs)
'here coms your code shat runs the script
wscript.echo aArgs(0) & aArgs(1) & aArgs(2)
end sub