cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Script in VBA Logic Help

former_member658317
Discoverer
0 Kudos

I have been working on a Macro in Excel that connects to SAP and so far I've been able to manage (NOT super familiar with coding at all). My goal and strategy so far has been the following:

I am trying to automate a fairly standard task that we carry out very often in SAP by pulling some info from Excel. In order to get the SAP script, I recorded a basic example of this task in SAP and have been using that script to try and complete what I need to do.

My latest roadblock is the following: I need to be able to fill in the short text for certain tasks (in "Item Tasks" of QM02 transaction) that are entered in by other people. So, I tried using the following code from my recording:

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB03").Select
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB03/ssubSUB_GROUP_20:SAPLIQS0:7125/tblSAPLIQS0MASSNAH_VIEWER2/txtVIQMSM-MATXT[4,8]").Text = "See tab"
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB03/ssubSUB_GROUP_20:SAPLIQS0:7125/tblSAPLIQS0MASSNAH_VIEWER2/txtVIQMSM-MATXT[4,9]").Text = "See tab"
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB03/ssubSUB_GROUP_20:SAPLIQS0:7125/tblSAPLIQS0MASSNAH_VIEWER2/txtVIQMSM-MATXT[4,10]").Text = "See tab"
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB03/ssubSUB_GROUP_20:SAPLIQS0:7125/tblSAPLIQS0MASSNAH_VIEWER2/txtVIQMSM-MATXT[4,11]").SetFocus
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB03/ssubSUB_GROUP_20:SAPLIQS0:7125/tblSAPLIQS0MASSNAH_VIEWER2/txtVIQMSM-MATXT[4,11]").caretPosition = 0
session.findById("wnd[0]").sendVKey 0

Of course, I realized when I tried to run this that it will input the "See tab" text into the specific rows in the short text column from my recording, but the tasks that I need this short text for will not always be in the same row, and may not be entered in at all. So I am hoping there is a way to possibly have the code recognize whether the task is there or not, and then fill in the short text in the appropriate place, I'm guessing with some if-then statement, but again I am NOT confident in coding at all, let alone SAP coding, so I would not even know where to begin.

Any guidance would be really appreciated!!!

Thank you

HarshalVakil
Active Contributor
0 Kudos

Hello Brandon,

Which SAP Product you are trying to connect with Excel? Is it SAP Business Bydesign? I think you have tagged the wrong product ( SAP Business Bydesign), since you also mentioned the QM02 transaction code. In ByDesign there are no transaction codes.

If this is for SAP Business ByDesign, Can you please provide the screenshot where you would like to fill the text?

Thanks.

Harshal

Accepted Solutions (0)

Answers (0)