SAP Get Text Field Dynamic Selector

Hi All,

I’m trying to use the “Get Text” Activity to get a value from a text field in SAP. The selector for the field is as follows :

“wnd[0]/usr/subSUB_MAIN:/COCKPIT/ SAPLDISPLAY46:0389 /subSUB_SALDO:/COCKPIT/SAPLDISPLAY46:0440/txt/COCKPIT/SDUMMY-SALDO”

However, the “SAPLDISPLAY46:xxxx” part of the selector seems to change randomly from time to time and the activity seems to crash when it cannot find the defined selector. there is no pattern to the change and i was wondering if there’s a possibility of using a wildcard there, if so what is the correct syntax to make this selector dynamic?

I.e :

“wnd[0]/usr/subSUB_MAIN:/COCKPIT/ SAPLDISPLAY46:0381 /subSUB_SALDO:/COCKPIT/SAPLDISPLAY46:0440/txt/COCKPIT/SDUMMY-SALDO”
“wnd[0]/usr/subSUB_MAIN:/COCKPIT/ SAPLDISPLAY46:0385 /subSUB_SALDO:/COCKPIT/SAPLDISPLAY46:0440/txt/COCKPIT/SDUMMY-SALDO”

Any suggestions would be greatly appreciated, Thank you in Advance!

Regards,
Johann.

@Johann Did you try this?
“wnd[0]/usr/subSUB_MAIN:/COCKPIT/ SAPLDISPLAY46:* /subSUB_SALDO:/COCKPIT/SAPLDISPLAY46:0440/txt/COCKPIT/SDUMMY-SALDO”

1 Like

Hi Athira,

Yes, i already tried using the wildcard like that and i still can’t get it to work :confused:
Is that the correct syntax for using the wildcard in this context?

Regards,
Johann.

Syntax is correct, but may be that field is unidentifiable without that value.
Can you tell me if you are able to highlight the required field from uiexplorer using above selector.

if not check if any other field also has the same set of selectors.

Hi Athira,

Yes, I believe it is unidentifiable without that value and Yes the field is highlighted in UIExplorer. The first time I run the BOT it will be able to identify and extract the value from the first invoice and it will keep extracting until the selector the “SAPLDISPLAY46:xxxx” changes. All the other fields in the invoice begin with the same “SAPLDISPLAY46:xxxx” so I’m unable to extract any data until this issue is sorted :confused:

In that case get OCR text or screen scrapping method might help

This is a common problem when containers are present on the SAP screen. There are two solutions I’ve used to tackle this problem.

The first is to invoke a script using the “FindByName” method. When you record a macro you’ll notice it records everything using the “FindById” method. By using FindByName you avoid having to know any of the display or screen numbers (which often change). All you need is the name of the object and it’s type. This solution works best when your just writing some Visual Basic script to automate the process; and since I don’t see a clear object name in what you’ve provided, your best bet is to use option two.

The second method to get around this is to use some error handling. First, create an Int32 variable and a string variable. You will concatenate the necessary text around the Int32 to create a your string. Then, insert that value into a dynamic selector.

So, each time the Get Text activity fails you’ll increase your number by one and try again. You may notice that only the last two numbers of the display change so you won’t have to iterate through too many numbers before you get the right value; just start at 80 and work your way up.

You can use the Assign activity to create your string value: yourString = (“wnd[0]/usr/subSUB_MAIN:/COCKPIT/ SAPLDISPLAY46:03" & yourNumber & "/subSUB_SALDO:/COCKPIT/SAPLDISPLAY46:0440/txt/COCKPIT/SDUMMY-SALDO”) Then, insert this into your selector.

There’s some documentation on how to do that here https://docs.uipath.com/studio/docs/dynamic-selectors.

Good luck! Hope this helps.

2 Likes

Hello @Johann,

I wanted to try the TAC /COCKPIT/1 (Automatic Invoice Verification) but it is not available on my system. So I tried different scenarios with wildcards e.g. asterisk and all works as expected. So I tried TAC MIRO and one thing caught my eye: If I changed something the content the title of the SAP session window changed also. Have you checked whether the other identifiers are also correct, especially the title? Or does it change with the other screen number? That would explain why the UI element is not found despite the wildcard.

Best regards
Stefan

@swridings

Hello Scott,

in a normal case are any kind of containers in SAP GUI Scripting not a problem. Please let me know what problems you have noticed with containers?

To iterate the screen number and to check if an exception occurs is not performant. Better and faster is to scan the necessary levels of the tree and to read the entry of interest.

Best regards
Stefan