VBA Script - SAP GUI - check field value and if matches perform transaction and then continue

Trebor200

Board Regular
Joined
Apr 21, 2015
Messages
67
Office Version
  1. 365
Platform
  1. Windows
Hi Experts,

I have been trying to figure out a way to use if statement with a SAP GUI Script but unsure how to tackle this.
I have tried searching but have failed, maybe am not understanding or this is not covered :(.

I want the script to cycle through around 4 - 10 fields and if the contents match defined code then perform a transaction.

This will be using SAP Tcode IW52, i want to search for task "ENGR" or "EXCH" and if matches check see if field is editable and select line and close.

Below is the filed name in SAP when i select and enter a code.

VBA Code:
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB11/ssubSUB_GROUP_10:SAPLIQS0:7120/tblSAPLIQS0MASSNAHMEN_VIEWER/ctxtVIQMSM-MNCOD[2,2]").text = "ENGR"

Code would be executed if matched to close line

VBA Code:
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB11/ssubSUB_GROUP_10:SAPLIQS0:7120/tblSAPLIQS0MASSNAHMEN_VIEWER/txtVIQMSM-QSMNUM[0,2]").setFocus
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB11/ssubSUB_GROUP_10:SAPLIQS0:7120/tblSAPLIQS0MASSNAHMEN_VIEWER/txtVIQMSM-QSMNUM[0,2]").caretPosition = 0
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB11/ssubSUB_GROUP_10:SAPLIQS0:7120/btnFC_ERLEDIGT").press

Below is the screen, notice ENGR apears in one field but its not editable so i would want to move on.
 

Attachments

  • Capture.JPG
    Capture.JPG
    52.4 KB · Views: 109

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top