2023 Feb 02 11:02 PM
Hi i got some project using SAP Gui Recording and Playback function and i already got some input and code for a single sheet. now i need to to get the data from multiple sheet example. Sheet1BAL , Sheet2CUB and etc.
this is my running code for sheet1BAL:
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]").resizeWorkingPane 138,41,false
Dim objExcel, objWorkbook, objSheet, i
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Users\itdatacenter\Desktop\3rd shift process\BATCH SCRIPT\OSBDL1.xlsx")
Set objSheet = objWorkbook.Sheets("BAL")
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
COL6 = Trim(CStr(objSheet.Cells(i, 6).Value)) 'Column6
session.findById("wnd[0]/tbar[0]/okcd").text = "zdown_osb_v14"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtP_MRDATE").text = COL1
session.findById("wnd[0]/usr/ctxtSO_MRU-LOW").text = COL2
session.findById("wnd[0]/usr/radPA_RD2").setFocus
session.findById("wnd[0]/usr/radPA_RD2").select
session.findById("wnd[0]/usr/ctxtPA_PAT2").text = COL3
session.findById("wnd[0]/usr/txtP_INFILE").text = COL4
session.findById("wnd[0]/usr/txtP_INFILE").setFocus
session.findById("wnd[0]/usr/txtP_INFILE").caretPosition = 12
session.findById("wnd[0]").sendVKey 9
session.findById("wnd[1]/tbar[0]/btn[13]").press
session.findById("wnd[1]/usr/btnDATE_PUSH").press
session.findById("wnd[1]/usr/ctxtBTCH1010-SDLSTRTDT").text = COL5
session.findById("wnd[1]/usr/ctxtBTCH1010-SDLSTRTTM").text = COL6
session.findById("wnd[1]/usr/ctxtBTCH1010-SDLSTRTTM").setFocus
session.findById("wnd[1]/usr/ctxtBTCH1010-SDLSTRTTM").caretPosition = 8
session.findById("wnd[1]/tbar[0]/btn[11]").press
Next
MsgBox " END"
2023 Feb 02 11:02 PM
Thank you for visiting SAP Community to get answers to your questions.
As you're looking to get most out of your community membership, please consider include a profile picture to increase user engagement & additional resources to your reference that can really benefit you:
I hope you find this advice useful, and we're happy to have you as part of SAP Community!
All the best,
Alex