web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Issue with Dynamic Tex...
Power Automate
Answered

Issue with Dynamic Text Input Positioning in SAP Automation

(1) ShareShare
ReportReport
Posted on by 12

Hi,

I'm new to SAP Automation, and I'm using the pro code way (record the script > run it as a PAD VB Script from Power Automate Desktop), but here.
I'm having trouble with the dynamic positioning of text input fields throughout the SAP automation process using VBScript. Specifically, the coordinates of the text input fields change across occurrences (for example, the length value was [1,0] the first time, but [1,3] the second time), causing the automation script to fail when attempting to enter data. For your convenience, I've attached an attachment.

Can anyone help me with a solution or guidance on how to handle dynamic text input positions effectively, ensuring that the automation script can adapt to these changes and maintain consistent functionality?

Your assistance in resolving this issue would be greatly appreciated.

PAD3_0-1718030251982.png

I have the same question (0)
  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    If you have  session.findById("wnd[0]/usr/TableRowElement/[1,0]").text = "600"
    That would be second Column 1 and Row 0 (so second column and first row since the indexing starts at 0)
    First number inside square brackets = columns index
    Second number inside square brackets = row index

    eetuRobo_0-1718034737594.png

    So what you want to do is create a variable that increases each loop if you want to populate more than just the first row in SAP. Like so:

    session.findById("wnd[0]/usr/TableRowElement/[1,%RowIndex%]").text = "600"

    eetuRobo_1-1718035110980.png

     

  • Akash14 Profile Picture
    12 on at

    hi @eetuRobo 

    I have an understanding of the Column Index and Row Index, but the difficulty here is that I need to get the Row Index dynamically based on the Name, which is the first column in the table.

    PAD3_0-1718093856705.png
    From the above image, I need to enter the Char.value, and when I use the GUI programming to record the video, I get the following code as a result.


    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,0]").text = "600"
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,1]").text = "400"
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,2]").text = "6"
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,5]").text = "PRIME GRADE"
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,8]").text = "WM"
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,8]").setFocus
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,8]").caretPosition = 2

    But the problem here is that if I say length as [1,0] in the next iteration, length will move to [1,3].

    How to overcome this difficulty.

    Thank you for your help in advance.

  • Verified answer
    eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    Okay that clears it up a bit. So I assume that the actual interface in the SAP does not change? But for some reason the elements index rows does. Do you need to scroll down at all in that table interface?

    What I have noticed is that SAPs row index is dynamic to what you see. So if you scroll down so that "Core ID" row is at the top (first showing row) then that will be the row 0 element. 

     

    So in some SAP automations I had to make logic that if the table gets filled and I need to add more rows my automation will press Page Down and then it scrolls down so automatically so that it only shows the last filled line. So then my automation starts to fill from the second row onward.
    Hard to explain but hopefully you understood 🙂

  • Akash14 Profile Picture
    12 on at

    Yeah @eetuRobo 

    This option will work. Thank you so much for your help!

    Also, I discovered another option where we have an option to search once we search with the specific char, automatically the texinput connected to that char description is set to the [1,0] and the following code will be in this format written below.

    Code:- 

    session.findById("wnd[0]").maximize
    session.findById("wnd[0]/usr/btnPOS").press
    session.findById("wnd[1]/usr/txtRCTMS-EMERK").text = "Length"
    session.findById("wnd[1]/usr/txtRCTMS-EMERK").caretPosition = 6
    session.findById("wnd[1]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,0]").text = "15000"
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,0]").caretPosition = 5
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES").verticalScrollbar.position = 2
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES").verticalScrollbar.position = 4
    session.findById("wnd[0]/usr/btnPOS").press
    session.findById("wnd[1]/usr/txtRCTMS-EMERK").text = "Width"
    session.findById("wnd[1]/usr/txtRCTMS-EMERK").caretPosition = 5
    session.findById("wnd[1]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,0]").text = "500"
    session.findById("wnd[0]/usr/ssubCHARACTERISTICS:SAPLCEI0:1400/tblSAPLCEI0CHARACTER_VALUES/ctxtRCTMS-MWERT[1,0]").caretPosition = 3
    session.findById("wnd[0]/usr/btnPOS").press
    session.findById("wnd[1]/usr/txtRCTMS-EMERK").text = "Core ID"
    session.findById("wnd[1]/usr/txtRCTMS-EMERK").caretPosition = 7
    session.findById("wnd[1]/tbar[0]/btn[0]").press
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]").sendVKey 3

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard