Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle a variable SAP id name in VBA scripting

0 Kudos

Hi,

I am working on a script that will schedule work order operations via IW32. I am running into an issue related to the SAP id. When I recorded the script and attempted to run it, it faulted on the line below. So I then re-recorded and found that the id name was different. This line of code is below, this selects an operation by row number:

seccion.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1101/tabsTS_1100/tabpVGUE/ssubSUB_AUFTRAG:SAPLCOVG:3010/tblSAPLCOVGTCTRL_3010").getAbsoluteRow(1).selected = True

The portion that changed was "…/ssubSUB_LEVEL:SAPLCOIH:1101/…". It was working for a time, then I went back to improve the code and the same issue occurred again. For this specific portion of the code I have seen it as:

(1) ssubSUB_LEVEL:SAPLCOIH:1100

(2) ssubSUB_LEVEL:SAPLCOIH:1101

(3) ssubSUB_LEVEL:SAPLCOIH:1107

Does anyone know why this occurs or know how to handle it? This is just one specific example, this has happened in another case as well, so a general approach to handling is preferred.

The code below is a second example, this one clicks the work order status info button.

ObjSess.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1101/subSUB_KOPF:SAPLCOIH:1102/btnBUTTON_STATUS").press

Thanks!
3 REPLIES 3

Sandra_Rossi
Active Contributor

Why this occurs: screens 1100, 1101, 1107 are almost identical, but not exactly identical, they are chosen depending on empty contents or not, so that the contents are better displayed, and there are a few more criteria (function module CO_IH_TABSTRIP_ABLAUF).

What to do: detect whether the screen currently displayed is 1100, 1101 or 1107, and change accordingly the field ID.

0 Kudos

Can you tell me help with how to detect the screen currently being displayed?

I'm having the same issue as the original question.

If Not ObjSess.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100") Is Nothing Then
  ' screen 1100 is displayed
Else If Not ObjSess.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1101") Is Nothing Then
  ' screen 1101 is displayed
Else If Not ObjSess.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107") Is Nothing Then
  ' screen 1107 is displayed
End If