Sign in to follow this  
Followers 0
yhrtan

Automate sap

4 posts in this topic

Hi,

I have some problem automating the SAP.

Share this post


Link to post
Share on other sites



This a the script that i wrote and it will just hang there after 1st file is saved.

$printer = "simodlsr01"

$plantNo = "sg05"

; Open BOM File

Local $bomExcel = _ExcelBookOpen( @WorkingDir & "\550-500369.xls", 1, False, "", "")

; Open new book, make it visible

Local $oExcel = _ExcelBookNew(1)

; Find the last row

$iCellRow = 400

$iStart = 2

Do

$iCellRow = $iCellRow - 1

$sReadCell = _ExcelReadCell($bomExcel, "B" & $iCellRow)

Until $sReadCell <> ""

; Start formatting the data, remove the retired BOM

$ioRow = 1

For $iCount = $iStart To $iCellRow

$sReadCell = _ExcelReadCell($bomExcel, "B" & $iCount)

If $sReadCell <> "RETIRED" Then

;WinSetState("BOM Explosion Report", "", @SW_SHOW)

_ExcelWriteCell($oExcel, $sReadCell, $ioRow, 2)

$bomID = _ExcelReadCell($bomExcel, "A" & $iCount)

_ExcelWriteCell($oExcel, $bomID, $ioRow, 1)

WinSetState("BOM Explosion Report", "", @SW_MINIMIZE)

;Sleep(3000)

WinSetState("BOM Explosion Report", "",@SW_MAXIMIZE)

;WinActivate("BOM Explosion Report", "")

Send("{F3}")

Sleep(800)

WinWaitActive("BOM Explosion Report","")

;MouseClick("left", 245, 146)

Send($bomID)

Sleep(1500)

Send("{TAB}")

Send($plantNo)

Sleep(1500)

Send("{F8}")

Sleep(2000)

;save

WinWaitActive("BOM Explosion Report","")

Send("{F9}")

WinWaitActive("Save list in file...","")

Send("{DOWN}")

sleep(500)

Send("{ENTER}")

Sleep(2000)

WinWaitActive("BOM Explosion Report","")

;Highlight the default path and delete.

MouseClickDrag("left", 452, 307, 156, 307)

Send("{DELETE}")

;Enter a new path to save the BOM data.

Send("C:\new\bom_list")

Send("{TAB}")

Sleep(1000)

Send($bomID & ".xls")

Send("{ENTER}")

Sleep(1000)

Send("^{F4}")

$ioRow = $ioRow + 1

EndIf

Next

_ExcelBookSaveAs($oExcel, @WorkingDir & "\temp02.xls", "xls", 0, 1)

; And finally we close out

;_ExcelBookClose($oExcel)

_ExcelBookClose($bomExcel,0)

Share this post


Link to post
Share on other sites

I am about to submit a SAP UDF yhrtan.

It uses SAP's COM object which makes automating SAP much easier than with window and keyboard functions alone.

I'll let you know once I've posted it. It should allow you to automate SAP much easier than you have done here.


Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia

Share this post


Link to post
Share on other sites

I have submitted my SAP UDF:

SAP UDF, Automating SAP using SAP's GUI Scripting COM object

Hope this helps all you SAP scripters out there :)


Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0