Hello Stefan,
Thank you very much for your quick response!
Regards,
Wes
Hello Stefan,
Thank you very much for your quick response!
Regards,
Wes
Thanks Holger. Your code is working fine. But it gives the available tabs in the View. My requirement is, I want know which Tab I am currently in. The use case is,
If the Material is being modified first time,
In this case, user will see "Basic Data 1" always in the screen and then the available tabs will be selected sequentially.
If the Material is being modified more than one time:
In this case, Basic Data 1 will be displayed. If the Tax values are not there, then it will go to "Tax Data" tab and then it will return to Basic Data 1 tab, and then the available tabs will be selected sequentially.
If the Material is not extended to the plant, while extending it will be in Specific tab:
In this case, Plant Storage 1 tab is displayed by default. User have to enter a data and save the view.
To address the above cases, I want to ensure the the current tab where users is accessing the details.
Is it possible to get that tab name using your code?
Regards,
Vijay.
Hello.
Sure. This is much easier as you just Need to get Text from selected tab:
This can be achieved with below code or one single line in your existing Code
Session.findByID("wnd[0]/usr/tabsTABSPR1").SelectedTab.Text
'-Start of Code-------------------------------------------------------
Sub Test()
Dim SapGuiAuto As Object
Dim Application_SAP As SAPFEWSELib.GuiApplication
Dim Connection As SAPFEWSELib.GuiConnection
Dim Session As SAPFEWSELib.GuiSession
Dim TabStrip As SAPFEWSELib.GuiTabStrip
Dim SelectedTab As SAPFEWSELib.GuiTab
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
Exit Sub
End If
Set Application_SAP = SapGuiAuto.GetScriptingEngine()
If Not IsObject(Application_SAP) Then
Exit Sub
End If
Set Connection = Application_SAP.Connections(0)
If Not IsObject(Connection) Then
Exit Sub
End If
Set Session = Connection.Sessions(0)
If Not IsObject(Session) Then
Exit Sub
End If
Set TabStrip = Session.findByID("wnd[0]/usr/tabsTABSPR1")
Set SelectedTab = TabStrip.SelectedTab
MsgBox SelectedTab.Text
Set SelectedTab = Nothing
Set TabStrip = Nothing
End Sub
'-End of Code-------------------------------------------------------------------
Thanks a lot Holger. It works Perfect.
You made my work too easy
Regards,
Vijay.
Hi Michael,
like Holger wrote to use variables you should change your code:
sub TEST()
Dim a As Integer
Dim b As Integer
a = 0 'Column
b = 0 'Row
Do
session.findById("wnd[0]/usr/tblSAPLZZVWPM79_CANCWO2TCTRL_ZZVWPM79_CANCWO2/txtZZVWPM79_CANCWO2-IWERK[a," & b &"]").Text = "TEST1"
'a = a + 1
b = b + 1
Loop Until b = 4
end sub
This code will fill in the first 4 rows in column 0 (the first column) with the same value TEST1.
Hi All,
I am looking for the solution to download the documents listed in the Excel from DMS in to the specific folder. The use case is, user will enter the list of required DMS numbers in the excel. Upon pressing the button, the mentioned in the list of Documents needs to be downloaded from DMS in to the specific folder.
Let me know, if you need any more information.
Regards,
Vijay.
Hello Vijay,
interesting use case.
I assume you want to download the files from an archive, correct? So you need the document ID from one of the TOA tables. And with this information you can download the file with the FM ARCHIVOBJECT_GET_DT_VIA_TABLE.
Cheers
Stefan
Hellocommunity!
Errorwhile trying to attachan Excel spreadsheetby_Excel_BookAttach() functionAutoItthe sheetwas opened byan SAPtransaction,so I'm usingonlythe_Excel_Open() functionbut thisreturningan intermittent errorin myscript, does anyone canmehelp out?
Global$aWins=WinList($sSAP_Excel_Temp)
_ArrayDisplay($aWins)
$oWorkBook=_Excel_BookAttach($aWins[1] [0], "Title")
Error ="1 - Anerror occurredor$sStringcannot be foundinanyof theopenworkbooks@extendedisSet totheCOMerror code."
@Error=1@extended=-2147352570
I believeI'musingthe same resourcementionedin thislink:
http://help.sap.com/saphelp_afs64/helpdata/ja/e3/41a138c4397a42e10000009b38f842/content.htm
Thank you so much!
Márcio.
Hello Marcio,
try this to attach to an open Excel workbook:
;-Begin-----------------------------------------------------------------
;-Includes------------------------------------------------------------
#include "Array.au3"
#include "Excel.au3"
;-Main----------------------------------------------------------------
$aWorkBooks = _Excel_BookList()
;_ArrayDisplay($aWorkBooks)
For $i = 0 To UBound($aWorkBooks) - 1
If StringInStr(String($aWorkBooks[$i][1]), "Mappe1") Then
$oWorkBook = _Excel_BookAttach($aWorkBooks[$i][2] + "\" + _
$aWorkBooks[$i][1])
EndIf
Next
;-End-------------------------------------------------------------------
With _Excel_BookList you get all open workbooks. Loop over all open workbooks and find the right workbook based on a substring of the title. Attach to this workbook via path and name of the workbook.
Let us know your results.
Cheers
Stefan
What did I not define using the coding above as reference? I get an error that says 'Object variable or With block variable not set on this line:
Dim WSHShell As Object
Dim SID As String
Dim InstanceNo As String
Dim WinTitle As String
Dim SapGuiPath As String
Dim WScript As Object
Set WSHShell = WScript.CreateObject("WScript.Shell")
Hello Stefan,
The _Excel_BookList () function did not find any open workbook.
... Until we solve this issue, it would be possible to copy the data to clipboard through AutoIt?
Thank you.
Márcio.
HelloStefan,
I foundan article that explainsexactlywhere I'mstuck!
http://help.sap.com/saphelp_afs64/helpdata/ja/b7/989d37d373243de10000009b38f8cf/content.htm
Afterclicking the "Export ListObjecttoXXL" I choosethe option: Table, automaticallyopensaexcelwindow with theSAP data, butI can notaccesswith_Excel_BookAttach() not evenget the nameusing the function_excel_BookList()
* My main goal is to copy the data from the Excel window and paste it into MS Word and then format and print.
Youhaveany other alternative? I believenot bepossibleto attachthe spreadsheet with_Excel_BookAttach() function.
Once againthank you for yourattentionever.
Márcio.
If you have an ALV List als Source just Reader Data from there into an Excel Worksheet.
Hello Holger Kohn,
It is exactlywhat I'mtrying to dothrough theAutoIt, butnot yetsucceeded.
Youwould havetohelp me.
Thank you very much!
Marcio.
How to read ALV and cremte an CSV file is good explaniert by Stefan Schnell in this document:
Tip: Write each table with SAP GUI Scripting to a CSV file
YOu just need to use this technic and convert into AutoIT Syntax.
Hello Marcio,
please have a closer look to the _Excel_BookList function of AutoIt. It scans the class ID {00020819-0000-0000-C000-000000000046} = Microsoft.Office.Interop.Excel.WorkbookClass. If you open an Excel instance you should find an open workbook. It is weired that you can't find any open workbook.
Let us know your results.
Cheers
Stefan
My company is moving from SAP ECC 6.0 to SAP HANA.
Is SAP GUI SCRIPTING available on SAP HANA ?
Any modification is required ?
Thanks
Hello André,
we discuss this question recently here.
Hope this answers your question, otherwise let us know.
Cheers
Stefan
Hi,
I've been attempting insert this code into an if statement and keep getting the same error:
'Object Required: 'WScript' -
Reading through the various forums, I've placed this code:
set WScript = CreateObject("WScript.Shell") in anumber of areas and it does not work
Does anyone know how to fix this and/or any other alternative for a user
to have the choice to Exit/Stop/Terminate a script,
Thanks