Quantcast
Channel: SCN : Discussion List - Scripting Languages
Viewing all articles
Browse latest Browse all 325

SAP Scripting Issue: Control could not be found by ID. -

$
0
0

Hi

We were trying to change the baseline date for approx 50000 document lines.

 

Recorded a script. It work fine for some of the part but at times it throws error and getting error "Control could not be found by ID. -" for the same thing. I could not understand the reason.

 

Can someone help me please...? I need to make sure that it run smoothly. I was thinking of if there is any syncing issue between ECC response and script spped, but not sure. If it is response issue then can we apply some wait time or something else. Currently not sure what to do.

 

Below is the code I have:

**********************************************************************

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

 

 

 

 

REM Set up connection to the Excel data to be keyed into SAP:

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

Set objSheet = objExcel.ActiveWorkbook.ActiveSheet

 

 

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

session.findById("wnd[0]/tbar[0]/okcd").text = "/nfb02"

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

 

 

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

 

 

session.findById("wnd[0]/usr/txtRF05L-BELNR").text = Trim(Cstr(objSheet.Cells(i, 1).Value2))

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").text = "Test"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").text = "2016"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").setFocus

session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4

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

session.findById("wnd[0]/usr/cntlCTRL_CONTAINERBSEG/shellcont/shell").setCurrentCell -1,"BUZEI"

session.findById("wnd[0]/usr/cntlCTRL_CONTAINERBSEG/shellcont/shell").selectColumn "BUZEI"

session.findById("wnd[0]/usr/cntlCTRL_CONTAINERBSEG/shellcont/shell").selectedRows = ""

session.findById("wnd[0]/usr/cntlCTRL_CONTAINERBSEG/shellcont/shell").pressToolbarButton "&SORT_ASC"

 

 

session.findById("wnd[0]/mbar/menu[1]/menu[1]").select

session.findById("wnd[1]/usr/txtRF05L-BUZEI").text = Trim(Cstr(objSheet.Cells(i, 2).Value2))

session.findById("wnd[1]/usr/txtRF05L-BUZEI").caretPosition = 2

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

session.findById("wnd[0]/mbar/menu[1]/menu[0]").select

session.findById("wnd[0]/usr/ctxtBSEG-ZFBDT").text = Trim(Cstr(objSheet.Cells(i, 3).Value2))

session.findById("wnd[0]/usr/ctxtBSEG-ZFBDT").setFocus

session.findById("wnd[0]/usr/ctxtBSEG-ZFBDT").caretPosition = 10

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

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

 

 

Next

 

*************************************************************


Viewing all articles
Browse latest Browse all 325

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>