cancel
Showing results for 
Search instead for 
Did you mean: 

IK01 Script

former_member860352
Discoverer
0 Kudos
274

Can anyone help with looping issue on below.

Script run through first line on excel sheet and then stop.

If Not IsObject(application) Then

Set SapGuiAuto = GetObject("SAPGUI")

Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(connection) Then

Set connection = application.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 application, "on"

End If

session.findById("wnd[0]").maximize

REM ADDED BY EXCEL *************************************

Dim objExcel

Dim objSheet, intRow, i

Set objExcel = GetObject(,"Excel.Application")

Set objSheet = objExcel.ActiveWorkbook.ActiveSheet

For i = 2 to objSheet.UsedRange.Rows.Count

COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1

COL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2

COL3 = Trim(CStr(objSheet.Cells(i, 3).Value)) 'Column3

COL4 = Trim(CStr(objSheet.Cells(i, 4).Value)) 'Column4

COL5 = Trim(CStr(objSheet.Cells(i, 5).Value)) 'Column5

REM ADDED BY EXCEL *************************************

session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").expandNode "F00011"

session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00062"

session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").topNode = "F00011"

session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00062"

session.findById("wnd[0]/usr/ctxtRIMR0-MPOTY").setFocus

session.findById("wnd[0]/usr/ctxtRIMR0-MPOTY").caretPosition = 3

session.findById("wnd[0]").sendVKey 4

session.findById("wnd[1]/usr/sub/1[0,0]/sub/1/2[0,0]/sub/1/2/5[0,5]/lbl[1,5]").setFocus

session.findById("wnd[1]/usr/sub/1[0,0]/sub/1/2[0,0]/sub/1/2/5[0,5]/lbl[1,5]").caretPosition = 1

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/subMPOBJ:SAPLIMR4:7501/ctxtIFLOT-TPLNR").text = COL1

session.findById("wnd[0]/usr/ctxtIMPT-MPTYP").setFocus

session.findById("wnd[0]/usr/ctxtIMPT-MPTYP").caretPosition = 1

session.findById("wnd[0]").sendVKey 4

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[0]/usr/chkIMPT-INDCT").selected = true

session.findById("wnd[0]/usr/chkIMPT-INDCT").setFocus

session.findById("wnd[0]/tbar[0]/btn[0]").press

session.findById("wnd[0]/usr/chkIMPT-INDTR").selected = true

session.findById("wnd[0]/usr/txtIMPT-PSORT").text = "SMU"

session.findById("wnd[0]/usr/txtIMPT-PTTXT").text = COL2

session.findById("wnd[0]/usr/ctxtIMPT-ATNAM").text = "YPM_RUN_HRS"

session.findById("wnd[0]/usr/txtIMPT-DECIM").text = "2"

session.findById("wnd[0]/usr/ctxtIMPT-BEGRU").text = "4595"

session.findById("wnd[0]/usr/txtRIMR0-PYEAC").text = COL3

session.findById("wnd[0]/usr/txtRIMR0-ATEXT").text = COL4

session.findById("wnd[0]/usr/txtRIMR0-ATEXT").setFocus

session.findById("wnd[0]/usr/txtRIMR0-ATEXT").caretPosition = 5

session.findById("wnd[0]/usr/btnDETAIL").press

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[1]/usr/btnCREATE").press

session.findById("wnd[2]/usr/ctxtIMPH-TRANS").text = COL5

session.findById("wnd[2]/usr/ctxtIMPH-DATLO").text = "01.01.2018"

session.findById("wnd[2]/usr/ctxtIMPH-TIMLO").text = "07:00:00"

session.findById("wnd[2]/usr/ctxtIMPH-TIMLO").setFocus

session.findById("wnd[2]/usr/ctxtIMPH-TIMLO").caretPosition = 8

session.findById("wnd[2]/tbar[0]/btn[0]").press

session.findById("wnd[2]/tbar[0]/btn[0]").press

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[0]/tbar[0]/btn[11]").press

session.findById("wnd[0]/tbar[0]/btn[3]").press

REM FINALIZATION CONTROL CHECK ************************

aux=col1 & " " & col2 & " " & col3 & " " & col4 & " " & col5

CreateObject("WScript.Shell").run("cmd /c @echo %date% %time% " & aux & " >> C:\SCRIPT\PlOrCreationLog.txt")

Next

msgbox "Process Completed"

REM FINALIZATION CONTROL CHECK ************************

anne-petteroe
Community Manager
Community Manager
0 Kudos

Hello Frans,

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.

Feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will also help you when preparing questions for the community.

Should you wish, you can revise your question by selecting Actions, then Edit.

Kind regards,
Anne


View Entire Topic
former_member860352
Discoverer
0 Kudos

Thanks Script Man, tried your script but still comes up wit an error "control could not be found by id".