on 08-02-2013 4:38 PM
Hi all,
I'm new to SAP and SAP GUI Scripting.
I've 2 questions that need your expertise to enlighten me.
1. session.RecordFile = "myfile" <- this will created under SapWorkDir
Q: Is there a way to know exact directory based on the variable SapWorkDir without hardcode it?
I need to use program to read this "myfile". Main reason no hardcode, I may have different SAP Gui Clients on different environments (XP, Win7 etc)
2. If above solution does not work
I know another alternative, using "_Change" event to record it myself. Is there any good sample?
Hope i can get some hints from you guys.
Cheers
Sato
Hello Eric,
at first welcome.
You can get the SAP work directory inside SAP GUI Scripting with the following code:
'-Begin-----------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Variables-----------------------------------------------------------
Dim SAPInfo, strResult
Set SAPInfo = CreateObject("Sapgui.InfoCtrl.1")
If IsObject(SAPInfo) Then
strResult = SAPInfo.GetSapWorkDir()
MsgBox strResult, vbOkOnly, "SAP Work Directory"
Set SAPInfo = Nothing
End If
'-End-------------------------------------------------------------------
Look also here: How to use SAPInfo Control module inside SAP GUI Scripting
You find an example for the change event here: https://service.sap.com/sap/support/notes/1441550, it is in VB classic.
Let us know your results.
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Stefan,
You are right. But the documentation says otherwise.
My environment.
Window 7 and window server 8
SAP GUI : 720 Final Release
Family : 64 bits
The result of "strResult" is C:\Users\<login name>\Documents\SAP
I assume this is SapWorkDir
I used the SAP GUI Script (using AutoIt scripting)
$file = $application.Utils().OpenFile("TEST_1")
$application.Utils().Write($file, "hello world")$application.Utils().CloseFile($file)
$application.Utils().CloseFile($file)
; Yes the file created C:\Users\<login name>\Documents\SAP
But (recording)
$session.TestToolMode = 1
$session.SaveAsUnicode = True
$session.Recordfile = "Test_IE07"
$session.Record=True
; It will create the file in this directory C:\Users\<login name>\AppData\Roaming\SAP\SAP GUI\Scripts\
;According the doc - (chm file) - under "RecordFile"
;A simple way to record a script it to set the recordFile property to a valid filename and then enable the record property. A Visual Basic Script file of the given name will be created in the SapWorkDir on the client PC
Why the RecordFile (stated in SapWorkDir) but checked, created in C:\Users\<login name>\AppData\Roaming\SAP\SAP GUI\Scripts\
and not C:\Users\<login name>\Documents\SAP
Hope you can further assists.
Best Regards,
Sato
I think i found the answer in SAP's doc
From the pdf doc on page 9.
It stated
SAP GUI Scripts
Windows XP:
C:\Documents and Settings\<username>\Application Data\SAP\SAP GUI\Scripts
Windows Vista/7:
C:\Users\<username>\AppData\Roaming\SAP\SAP GUI\Scripts
Started from SAP GUI Window - 7.20 onward.The local working directory SAPWORKDIR is obsolete and a new Windows-compliant structure is used.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.