cancel
Showing results for 
Search instead for 
Did you mean: 

What do you need (to activate in SAP) in order to execute scripts from VBA?

Former Member
0 Kudos

Hello helpers,

I'm having trouble with the code I've developed on VBA pasting code from SAP script recorder. I launch it on my computer and it works fine, for example enter a transaction -> do something -> save changes, but when I share it other users they receive VBA errors messages.

Here's the code with problem:

Private Sub TheScript()

'setting the connection with sap:

Dim App, Connection, session As Object

Set SapGuiAuto = GetObject("SAPGUI")

Set App = SapGuiAuto.GetScriptingEngine

Set Connection = App.Children(0)

Set session = Connection.Children(0)

'Data to use from the worksheet

fechaDoc = Range("b1").Value

fechaContab = Range("b2").Value

periodo = Range("b3").Value

claseDoc = Range("b4").Value

textoReferencia = Range("b5").Value

textoCabecera = Range("b6").Value

posiciones = Range("j1").Value

'Enter FB01 trx

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

session.findById("wnd[0]/tbar[0]/okcd").Text = "/nfb01"

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

'Enter date value

session.findById("wnd[0]/usr/ctxtBKPF-BLDAT").Text = fechaDoc

session.findById("wnd[0]/usr/ctxtBKPF-BUDAT").Text = fechaContab

session.findById("wnd[0]/usr/txtBKPF-MONAT").Text = periodo

Here's the problem, the code doesn't find those elements. I've used the script recorder on this mate's computer and found that it recorded this fields with diferent names.

Thanks in advance,

Richard

Accepted Solutions (1)

Accepted Solutions (1)

holger_khn
Contributor
0 Kudos

Hello.

Can you post the lines with different names (from your mates recording)?

Best regards,

Holger

Former Member
0 Kudos

Hello Holger,

Thanks for your reply.

I can't found him now, but it was something like:


session.findById("wnd[0]/usr/txt[0]).Text =



Thanks again,

Richard

holger_khn
Contributor
0 Kudos

Hello.we Need to know exactly. May you can perform an script recording on his Device. Is he using SAPGUI or via aother application?

Former Member
0 Kudos

We've completed two date fields while recording:

  1. session.findById("wnd[0]").maximize
  2. session.findById("wnd[0]/usr/ctxt[0]").text = "21082014"
  3. session.findById("wnd[0]/usr/ctxt[3]").text = "21082014"
  4. session.findById("wnd[0]/usr/txt[0]").setFocus
  5. session.findById("wnd[0]/usr/txt[0]").caretPosition = 0
holger_khn
Contributor
0 Kudos

Did they have the same Transaction + views as you?

Former Member
0 Kudos

I've tried with his Sap user, both on my computer and on his... works on mine, doesn't on his..

Even worse, I've tried on his computer within a Qa environment and worked but doesn't on Production.

holger_khn
Contributor
0 Kudos

There is something different. Looks like he have an different Screen when calling Transaction. So in this case you should use recording from him and adopt to a template.

Former Member
0 Kudos

Hello Holger,

I did that, but I still need to know where to look...

There must be something that controls this kind of "field naming".

Thanks again!

holger_khn
Contributor
0 Kudos

Hello. Check Conection Properties in SAP GUI from this user. If they have Network Settings on Low Speed Connection Screen can get an reduced view.

As well user-dependent Settings in System can cause that an different Screen layout is used for them.

Former Member
0 Kudos

Thanks a looooooooooooot !!

That was the problem, Network Settings.

Hope some day I can help you,

Regards,

Richard

Answers (0)