cancel
Showing results for 
Search instead for 
Did you mean: 

How to make script recorded work with other Windows

Former Member
0 Kudos

Hi,

Im quite new with SAP and i tried to record a script to download some reports, the script is working well in my laptop, but doesnt in the other, the problem as i know is about the SAP Window session size, its not the same with the one i have recorded in my Laptop.

And yes, the report does not have any T-Code to access to.

Is there any way to fix it?

I Tried both maximize, resizeWorkingPane false or true. And as i know its clicking to the node


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

session.findById("wnd[0]").resizeWorkingPaneEx 1131,1092,false

Session.FindById("wnd[0]/tbar[0]/okcd").Text = "/nSRET"

Session.FindById("wnd[0]").SendVKey 0

Session.FindById("wnd[0]/usr/lbl[5,11]").SetFocus 'First Node

Session.FindById("wnd[0]").SendVKey 2

Session.FindById("wnd[0]/usr/lbl[9,20]").SetFocus 'Second Node'

Session.FindById("wnd[0]").SendVKey 2

Session.FindById("wnd[0]/usr/lbl[13,34]").SetFocus 'Third Node

Session.FindById("wnd[0]").SendVKey 2

Session.FindById("wnd[0]/usr/lbl[20,37]").SetFocus 'This node has failed coz wrong node i need

Session.FindById("wnd[0]").SendVKey 2

Accepted Solutions (0)

Answers (1)

Answers (1)

holger_khn
Contributor
0 Kudos

Hello.

replace this Code line

session.findById("wnd[0]").resizeWorkingPaneEx 1131,1092,false

with

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


This should work.


best regards


Holger

Former Member
0 Kudos

Hi Holger,

Thanks for your reply, and sorry coz my question is unclear, i want to work with other Computer, not only in my Laptop.

The issue here seem come from the windows's resolution, my Laptop is in 1920*1080 but other computer is 1366*768.

Is there any way to fix it work in other resolution? I want to share the scrip for my Operators also

holger_khn
Contributor
0 Kudos

Hello.

I Have understand your requirements and my hint should do as expected on Otter computers als well.

IF the Label you want is not Visible scroll until Label is visible.

Thanks.

Best regards

Former Member
0 Kudos

Hello,

I Tried as you Suggested but still getting error.


As i understand, the script is runing by clicking to node by positions, it does not search the label, if scroll till the label visible then how to get the node's position (in this line i need to replace the bold number i have makred),


Session.FindById("wnd[0]/usr/lbl[20,37]").SetFocus 'This node has failed coz wrong node i need

Session.FindById("wnd[0]").SendVKey 2

Former Member
0 Kudos

Hi Holger, I'm with other problem. Can you help me? The error is on the line "Set Session = Connection.Children(1)"

Former Member
0 Kudos

Hi Binh,

If the nodes are moving, you can loop through them and search the ones you want based on string.

Eg.


for i = 0 to 100

     if Session.findById("wnd[0]/usr/lbl[" & i & ",3]").Text = "This or That" then

          Session.findById("wnd[0]/usr/lbl[" & i & ",3]").setfocus

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

     end if

next i

thomas_brutigam2
Active Participant
0 Kudos

João Paulo da Rosa wrote:

Hi Holger, I'm with other problem. Can you help me? The error is on the line "Set Session = Connection.Children(1)"

Simple and Easy -
The Enumeration always begins in 0 ....
unless you have no second Window in SAP opened this error occurs
Set it to 0 and everything will work - or open up a second Window


Greetings -.-..-