cancel
Showing results for 
Search instead for 
Did you mean: 

Question : Will not the following snippet of code work?

Former Member
0 Kudos

strName =session.findById("wnd[0]/usr/tabsTABSTRIP_2000/tabpKOSL/ssubSUBSCR_2000:SAPLCOVG:2054/tblSAPLCOVGTCTRL_2054/ctxtAFVGD-VORNR[0,0]").text

will not this assign the value from row and column to string value called Name?

Accepted Solutions (0)

Answers (1)

Answers (1)

holger_khn
Contributor
0 Kudos

Have you tried it?

What you want to achieve?

For me it seems like you want to Transfer a cell value from a dynamic Sub table to an string variable. So it should work

Former Member
0 Kudos

I have tried it an I get an error

The control could not be found by id.-

looks like it can not find the first value in col and row 0.

holger_khn
Contributor
0 Kudos

Have you tried to check your Screen with Scripting Tracker if field is available?

Former Member
0 Kudos

You are correct in your assumptions. I do want transfer a cell value from sub table then manipulate  a specific cell value of the transferred to a new value in the table.

Former Member
0 Kudos

yes I have the field with the Scripting tracker and the field is available and can see what the value is. I think it is something to do with the assignment to the variable that is the problem but I have no idea why it does not like the way I declare the variable that is to hold the value returned from the script.

holger_khn
Contributor
0 Kudos

May your complete code will bring some more light into. If field is available during script execution it will work. So I doubt there is something wrong.

Did you adopt your code to an existing session or did you open an session by SAPGUI.ScriptingCTRL.1 ?

Former Member
0 Kudos

here is the code that I am working on

If Not IsObject(application) Then

   Set SapGuiAuto  = GetObject("SAPGUI")

   Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(connection) Then

   Set connection = application.Children(0)

End If

If Not IsObject(session) Then

   Set session    = connection.Children(0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session,     "on"

   WScript.ConnectObject application, "on"

End If

strNetwork = InputBox("Please enter a network number", _     "Network #")        rem This will get the network you want to move

strActivity = InputBox("Please enter the activity you want to Move")   Rem this will give you the activity you want to move in this case DCRV

strWorkCentre = InputBox("Please enter the new work centre to move the activity to") rem in this case the work centre to move to is DSOPENN

rem the next block of statements takes the network number and goes to internal activity Screen

session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").text =strNetwork rem using input box for network but will eventually use spreadsheet of network numbers as input

session.findById("wnd[0]").resizeWorkingPane 173,32,false

session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").caretPosition = 7

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/tbar[1]/btn[7]").press

'find  activity, select row, go into it

  strName = session.findById("[/wnd[0]/usr/tabsTABSTRIP_2000/tabpARBL/ssubSUBSCR_2000:SAPLCOVG:2030/tblSAPLCOVGTCTRL_2030/txtAFVGD-VORNR[0,0]").text

    

Everything works great except the last line of code

holger_khn
Contributor
0 Kudos

As your code is not calling any Transaction I guess you call first correct Transaction and Screen Manual. If you have more than one session open it might be that your code is adopt to wrong session. Or you have not correct Sub tab open in Transaction.

Is your code defintely stopping when correct session got used and field is visible?