Quantcast
Channel: SCN: Message List - Scripting Languages
Viewing all 1708 articles
Browse latest View live

"Controlling" the SAPGUI through Excel VBA

$
0
0

Dear,

I'm startinga series ofknowledge sharing. UsingVBAExcelandSAPGUI.

This"control"ismade byOLEAutomation,which is a mechanismfor communication betweenprocessesbased onComponent ObjectModel (COM).


All commentsare welcome.

Regards,

Jerônimo.


--- = ----


' BootingtheSAPGUIScriptingAPIthrough ExcelVBA.


' Through asubroutine.



Sub Test()

 

    Sheets("Plan1").Select

 

    On Error Resume Next

 

    'Setasmy nameobjectbecause theApplicationis a property ofVBAand not giveconflict in thecode syntax.

 

    Dim Jeronimo, SapGuiAuto, Connection, session, WScript As Object

 

    Set SapGuiAuto = GetObject("SAPGUI")

    Set Jeronimo = SapGuiAuto.GetScriptingEngine

    Set Connection = Jeronimo.Children(0)

    Set session = Connection.Children(0)

    WScript.ConnectObject session, "on"

    WScript.ConnectObject Jeronimo, "on"

 

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

 

       'Herethe restof your code,such asloops, conditions, tests,shotsetc.


End Sub


Ruby and SAPNWSDK: `load_rbconfig': uninitialized constant Config (NameError)

$
0
0

Dear all,

 

I try to use the SAPNWSDK by Piers Harding. I've downloaded the SAP RFC SDK from Support portal and extracted. Then I've downloaded the Zip from github and extracted also. Then I added the rfcsdk (from sap) to my PATH variable and created LD_LIBRARY_PATH and assigned the sapnwsdk/lib to it.

 

If I now try to execute setup I get the error:

D:\Programme\ruby-sapnwrfc-master>ruby setup.rb config  --with-nwrfcsdk-dir=D:\P
rogramme\rfcsdk\lib
setup.rb:283: warning: duplicated key at line 284 ignored: "bin-dir"
setup.rb:791:in `load_rbconfig': uninitialized constant Config (NameError)        from setup.rb:771:in `invoke'        from setup.rb:1619:in `<main>'

Can anybody tell me what to do to get the ruby sdk running?

 

Thanks

SAPScript in RFC possible?

$
0
0

Hello!

 

I have made loads and loads of SAPScripting (SAP GUI scripting) using Excel and VBA. That is really useful and allows for a great deal of efficiency. Lately i experimented with some RFC calls and that is really cool because its faster and allows the program to execute in the background i.e not using the GUI.

 

However, I don't have too much experience with using Function Modules and ABAP code. And so far I have only been able to fetch data from tables.

 

So I'm wondering if the regular SAPScript (session.findById.. etc) can be used in RFC calls. To carry out different updates as if they were done in the GUI?

 

And if so, does anyone possibly have a bit starter code to get me started?

 

BR Mattias

Re: SAPScript in RFC possible?

$
0
0

Hello Mattias,

 

welcome in the Scripting Language forum.

 

As I understand you correct, you want to use SAP GUI Scripting inside an RFC module. This means, you want to control the frontend server via SAP GUI Scripting in an executed RFC backend module.

 

Mhm, in my opinion tt is not really possible and not really recommended to use SAP GUI Scripting in RFC calls.

 

RFC (Remorte Function Call) is designed as a machine to machine (M2M) interface. So it is possible to use it without any UI. So you must check at first in the RFC the using of an UI,  otherwise the module could have problems.

 

The using of the SAP GUI Scripting control in the backend server is generally forbidden in the SAP GUI for Windows security options. so you must disable the standard SAP Logon security options, if you want to use it directly.

 

001.JPG

 

In my opinion is it from the architecture perspective with the separation from the front- and backend components better to renounce this scenario. You can use RFCs in SAP GUI Scripting on different ways easily, via SAP ActiveX control or via CCo (COM Connector), and you can use the results of the RFCs in your SAP GUI Script processing. It is not really necessary to mix these different components and their approaches, based on thereasons set out here.

 

If you really want to use SAP GUI Scripting from the ABAP backend I developed Background Light. This is a server application which allows to use COM libraries with ABAP background processes and without the SAP GUI for Windows. You can find more Information here.

 

You see it is interesting topic with many facets. Let us know more about your ideas, your requirements and your results.

 

Cheers

Stefan

Re: VBA Code to export data from SAP and save to Desktop

$
0
0

Hello Michael,

 

welcome in the Scripting Language forum.

 

I tried the printing of a source code in the SE80 transaction successfully with the following script.

 

Set Wshell = CreateObject("Wscript.Shell")

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

Do

  bWindowFound = Wshell.AppActivate("Print Screen List")

  WScript.Sleep 1000

Loop Until bWindowFound

session.findById("wnd[1]/usr/ctxtPRI_PARAMS-PDEST").text = "LP01"

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

Do

  bWindowFound = Wshell.AppActivate("Information")

  WScript.Sleep 1000

Loop Until bWindowFound

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

 

This is exact the same way as yours, but with other controls. In my opinion your script should work. Here your script, which I optimized a little bit, unfortunately without being able to prove it..

 

WScript.Sleep 10000

Set Wshell = CreateObject("Wscript.Shell")

Do

  bWindowFound = Wshell.AppActivate("Pdf995 Save As")

  WScript.Sleep 1000

Loop Until bWindowFound

Wshell.SendKeys ("Parked and Blocked Report" & " " & Format(Date, "mmddyyyy") & ".pdf")

WScript.Sleep 100

Wshell.SendKeys ("{ENTER}")

WScript.Sleep 100

 

Let us know your results.

 

Cheers

Stefan

Re: SAP.Functions and VBA connectivity fail

$
0
0

Hello Ekaterina,

 

you are right. The behavior of the SAP Logon Control or Classic RFC library between SAP GUI version 7.30 and 7.40 is different. I monitored the complete activities of the script, and I can't find any file access to SAPlogon.ini. All SAPlogon accesses are only in the registry.

 

Anyway, if you open the OSS note and you get a result, please let us know. It is very a interesting topic.

 

Thanks and cheers

Stefan

 

 

 

P.S. Here my test script:

 

'-Begin-------------------------------------------------


  Set oFunc = CreateObject("SAP.Functions")

  Set oCon = oFunc.Connection

 

  oCon.ApplicationServer = "localhost"

  oCon.SystemNumber = "00"

  oCon.Client = "001"

  oCon.Language = "EN"

  oCon.User = "BCUSER"

  oCon.Password = "minisap"

 

  If oCon.Logon(0, True) = False Then

    MsgBox "R/3 connection failed"

  Else

    MsgBox "R/3 connection successful"

    oCon.LogOff

  End If

 

  Set oCon = Nothing

  Set oFunc = Nothing

 

'-End---------------------------------------------------


Re: Extract data from SAP using VBScript

$
0
0

Hi Sheetal,

 

Good evening. I am not sure if you have succeeded in extracting the data or gave up.

 

The key thing is on the code above:

 

If you have a VBscript with the code - that is standalone - then you cannot define the variables

as follows:

 

Dim R3Logon         As object

Dim MyFunc As object

 

which should be just:

 

Dim R3

Dim MyFunc

 

then when you actually want to instantiate them as objects then:

 

Set MyFunc = CreateObject("SAP.Functions")

Set R3Logon = CreateObject("SAP.LogonControl.1")

 

etc.

 

Check out my video - where i have extracted the SAP table headers and SAP table data

and also bypassed the limit of 512 byte, which exist in the RFC function.

 

https://youtu.be/BYgx3SogEjE

 

Let me know if you need any help?

 

Thanks

Ram.S

Re: VBA Code to export data from SAP and save to Desktop

$
0
0

Thanks for that Stefan.

 

Your script is working but not everytime. Sometimes it is working, sometimes no . I am not sure where is the problem, if it has to do with the sleep function.

 

After doing below step, SAP is waiting for 5-10 seconds before the "Pdf995 Save As" appear. It depends on the volume of the report.

 

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

 

The script is not consistent. Sometimes it proceed with the saving of PDF, sometimes it stops when the dialog box appear. Do i have to declare anything?

 

Thanks in advance.

Mike


Re: VBA Code to export data from SAP and save to Desktop

$
0
0

Hello Mike,

 

thanks for your reply.

 

Please look here for different reasons why AppActivate returns false. Observe your dialog and compare the status of the dialog with the described conditions.

 

Do you interact with your computer if the script is running - keyboard input, mouse pointer move?

 

Let us know your results.

 

Cheers

Stefan

Re: SAP.Functions and VBA connectivity fail

$
0
0

...Created. Waiting for the answer.

Re: VBA Code to export data from SAP and save to Desktop

$
0
0

Hi Stefan,

 

I am not playing with the mouse when i start running the report. I just noticed that after i press the last print button (session.findById("wnd[1]/tbar[0]/btn[13]").press), a window appear. Its the "SAPLPD.LOG - SAPLPD" window. Could it be the reason why sometimes the script is not working?

Re: VBA Code to export data from SAP and save to Desktop

$
0
0

Hello Mike,

 

this could be a reason.

 

Please, can you try this:

 

WScript.Sleep 10000

Set Wshell = CreateObject("Wscript.Shell")

Do

  WScript.Sleep 100

  bWindowFound = Wshell.AppActivate("Pdf995 Save As")

Loop Until bWindowFound

Wshell.SendKeys ("Parked and Blocked Report" & " " & Format(Date, "mmddyyyy") & ".pdf")

WScript.Sleep 100

Wshell.SendKeys ("{ENTER}")

WScript.Sleep 100


I changed in the loop the duration from 1 second to 0.1 second and the sequence of the commands - Sleep before AppActivate. On this way you reduce your time difference between the activation of the dialog and the sending of the key presses. So has the SAPLPD Print Daemon not much occasion to spark between this activities. Hope it works better now.


Another way would be, if you wait until SAPLPD Print Daemon window is open, via an additional loop, and then you activate your dialog and send the key presses, e.g. like this:


WScript.Sleep 10000

Set Wshell = CreateObject("Wscript.Shell")

Do

  WScript.Sleep 100

  bWindowFound = Wshell.AppActivate("SAPLPD.LOG - SAPLPD")

Loop Until bWindowFound

Do

  WScript.Sleep 100

  bWindowFound = Wshell.AppActivate("Pdf995 Save As")

Loop Until bWindowFound

Wshell.SendKeys ("Parked and Blocked Report" & " " & Format(Date, "mmddyyyy") & ".pdf")

WScript.Sleep 100

Wshell.SendKeys ("{ENTER}")

WScript.Sleep 100


So you are really sure that no other process you know can push in between.


Let us know your results.


Cheers

Stefan


Re: Copy from SAP ECC into Excel Cell

$
0
0

Thank you stefan! This helped me get the first node into excel successfully!

I need to get the 5 nodes below it as well and I'm not sure how to get it to work?

 

Here's what I used to get first node:

 

Set Tree = session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell")

 

 

 

 

 

  'Column 2 is Profit Center, but the index starts with 0

 

 

  'To get the correct columnt 2 minus 1

 

 

  colName = Tree.GetColumnNames.Item("1")

 

 

  Set col = Tree.GetColumnCol(colName)

 

 

 

 

 

  'Get top node

 

 

  topNode = CStr(Tree.topNode)

 

 

 

 

 

  'Counts all sub nodes of the top node

 

 

  cntSubNodes = Tree.GetNodeChildrenCountByPath(topNode)

 

 

 

 

 

  'Scan all sub nodes

 

 

  For I = 1 To cntSubNodes

 

 

 

 

 

    'The path of the subnodes is 1/1, 1/2 etc.

 

 

    NodeName = Tree.GetNodeTextByPath(topNode & "/" & CStr(I))

 

 

 

 

 

    'Search for the correct node name

 

 

    If NodeName = "Communications, Medi" Then

 

 

 

 

 

      'Get the key of the node

 

 

      Key = CLng(Tree.GetNodeKeyByPath(topNode & "/" & CStr(I))) - 1

 

 

 

 

 

      'Get the description

 

 

      ProfitCenter = col.Item(Key)

 

 

      Cells(I, "F").Value = ProfitCenter

 

 

    End If

 

 

 

 

Next

 

 

 

The remaining nodes would be:

If NodeName = "Financial Services" Then

If NodeName = "Health & Public Serv" Then

If NodeName = "Products" Then

If NodeName = "Resources" Then

If NodeName = "Other" Then


I tried making NodeName an array, but that didn't work and I tried reusing the code above but the Next is tripping me up?


Can anyone assist?


Thank you!


Danielle


Capture.JPG

 

Re: VBA Code to export data from SAP and save to Desktop

$
0
0

Thanks Stefan. I tried but im not getting any luck.

i pasted below my whole code. can you check if i missed any declaration or variant etc?

Im feeling hopeless now.

Thanks

 

Sub Sap_DownPDF()

 

 

Dim application

 

 

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

 

 

'Start the transaction to view a table

    session.findById("wnd[0]/tbar[0]/okcd").Text = "/N/DS1/MM_C_BLK_PARK23"

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

 

 

'Update the Company Code

    session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").Text = Sheets("Home").Range("K4").Value

    session.findById("wnd[0]/usr/txtS_GJAHR-LOW").Text = Sheets("Home").Range("K5").Value

    session.findById("wnd[0]/usr/txtS_GJAHR-HIGH").Text = Sheets("Home").Range("M5").Value

    session.findById("wnd[0]/usr/ctxtS_BLART-LOW").SetFocus

    session.findById("wnd[0]/usr/ctxtS_BLART-LOW").caretPosition = 0

    session.findById("wnd[0]/usr/btn%_S_BLART_%_APP_%-VALU_PUSH").press

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

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

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

 

 

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

    session.findById("wnd[1]/usr/ctxtPRI_PARAMS-PDEST").Text = "LOCL"

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

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

    session.findById("wnd[2]/tbar[0]/btn[13]").press

    session.findById("wnd[1]/usr/cmbPRIPAR_EXT-OSPRINTER").Key = "PDF995"

   

    Set Wshell = CreateObject("WScript.Shell")

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

 

 

WScript.Sleep 10000

Set Wshell = CreateObject("Wscript.Shell")

Do

WScript.Sleep 100

bWindowFound = Wshell.AppActivate("Pdf995 Save As")

Loop Until bWindowFound

Wshell.SendKeys ("Parked and Blocked Report" & " " & Format(Date, "mmddyyyy") & ".pdf")

WScript.Sleep 100

Wshell.SendKeys ("{ENTER}")

WScript.Sleep 100

 

 

 

 

End Sub

Re: Copy from SAP ECC into Excel Cell

$
0
0

Hello Danielle,

 

my suggested solution seems to be a little bit special for the transaction SE80 and I mixed the key of the node with the item position of the entry in the column. They are different, but in my example case they are coincidentally the same.

 

Here another approach, to read the column Kurztext from the subnodes of Anwendungs-Registry:

 

'-Begin---------------------------------------------------------------

 

  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

 

  Set Tree = _

    session.findById("wnd[0]/shellcont/shell/shellcont[2]/shell")

 

  colName = Tree.GetColumnNames.Item("2")

  Set col = Tree.GetColumnCol(colName)

 

  topNode = CStr(Tree.TopNode) : Key = topNode


  '-Counter to get correct index of node------------------------------

    cnt = 1 + Tree.GetNodeChildrenCountByPath(topNode)


  '-Scan nodes on the first level-------------------------------------

    For i = 1 To Tree.GetNodeChildrenCountByPath(topNode)

      cnt = cnt + 1

      nodeName = Tree.GetNodeTextByKey(Key)

      nodePath = Tree.GetNodePathByKey(Key)

      If nodeName = "Anwendungs-Registry" Then


      '-Scan nodes on the second level--------------------------------

        For j = 1 To Tree.GetNodeChildrenCount(Key)

          cnt = cnt + 1

          subNode = Tree.GetNodeKeyByPath(nodePath & "/" & CStr(j))

          subNodeName = Tree.GetNodeTextByKey(subNode)

          Select Case subNodeName

            Case "S_AREA_GDMA"

              MsgBox col.Item(cnt)

            Case "S_AREA_RMS"

              MsgBox col.Item(cnt)

          End Select

        Next


      End If

      If i < Tree.GetNodeChildrenCountByPath(topNode) Then

        Key = Tree.GetNextNodeKey(Key)

      End If

    Next

 

'-End-----------------------------------------------------------------

 

001.jpg

 

Hint: The variable cnt works only in this special case, if I open some nodes it doesn't work correct.

 

I talk with a friend of mine this week about scanning the SAP tree control with SAP GUI Scripting, and we are both the opinion that this is one of the most toughest tasks.

 

Additional questions are welcome.

 

Let us know your results.

 

Cheers

Stefan


Re: VBA Code to export data from SAP and save to Desktop

$
0
0

Hello Michael,

 

in my case your code works perfect, here my example code:

 

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

 

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

session.findById("wnd[1]/usr/ctxtPRI_PARAMS-PDEST").Text = "LOCL"

session.findById("wnd[1]/usr/cmbPRIPAR_EXT-OSPRINTER").Key = "Adobe PDF"

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

 

Set Wshell = CreateObject("WScript.Shell")

WScript.Sleep 10000

 

Do

  WScript.Sleep 100

  bWindowFound = Wshell.AppActivate("PDF-Datei speichern unter")

Loop Until bWindowFound

Wshell.SendKeys ("Parked and Blocked Report" & " " & FormatDateTime(Date, vbShortDate) & ".pdf")

WScript.Sleep 100

Wshell.SendKeys ("{ENTER}")

WScript.Sleep 100

 

It works with and without open print daemon window, it seems that this makes no difference.

 

Don't be hopeless, together we will find a solution.

 

Cheers

Stefan

script for downloading from SAP as excel without user input

$
0
0

Hello,

I am new with scripting, can someone help me with one problem that I am facing. I need to download from the transaction S_ALR_87013613 some data in excel format. The code works fine but it stops at the Save as popup window from SAP and requires user input for the file name , type and location in order to be saved. Is there a code that can be added in order for be the data to be automatically saved to a specified name ,address and type without requiring a user input?
Can you help?

Sub export_SAP()

  Set SapGuiAuto = GetObject("SAPGUI")  'Get the SAP GUI Scripting object
  Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
  Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
  Set session = SAPCon.Children(0) 'Get the first session (window) on that connection

  session.StartTransaction "S_ALR_87013613"

session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/ctxt$1KOKRE").text = "eu02"
session.findById("wnd[0]/usr/txt$1GJAHR").text = "2015"
session.findById("wnd[0]/usr/ctxt$1PERIV").text = "8"
session.findById("wnd[0]/usr/ctxt$1PERIB").text = "8"
session.findById("wnd[0]/usr/ctxt_1KOSET-LOW").text = "34210000"
session.findById("wnd[0]/usr/ctxt_1KOSET-HIGH").text = "34419999"
session.findById("wnd[0]/usr/ctxt_1KOSET-HIGH").SetFocus
session.findById("wnd[0]/usr/ctxt_1KOSET-HIGH").caretPosition = 8
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[6]/menu[5]/menu[2]/menu[2]").Select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").Select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").SetFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").SetFocus
session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 0
session.findById("wnd[1]").sendVKey 4
session.findById("wnd[1]/tbar[0]/btn[0]").press

End Sub

Re: How to save report using buton (VBA+Excel)

$
0
0

Hi ScriptMan

I want to do same thing but it doesn't works. It stop on line "session.findById("wnd[0]/tbar[1]/btn[43]").press" and don't keep run. Please check my code below and tell me where do I'm wrong.

 

Public Sub Buscar_ZGLPM051()

'Login no SAP
Set SapGuiAuto = GetObject("SAPGUI")  'Obtenha o objeto SAP GUI Scripting
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Obter o SAP GUI atualmente em execução
Set SAPCon = SAPApp.Children(0) 'Obter o primeiro sistema que está conectado
Set session = SAPCon.Children(0) 'Obter a primeira sessão (janela) nessa conexão

'inicia seção ZGLPM051
session.StartTransaction "ZGLPM051"
session.findById("wnd[0]").maximize
On Error Resume Next
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").unselectAll
      If Err.Number <> 0 Then
End If

'execução dos comandos "script" gerado pelo SAP
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").expandNode "F00039"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00018"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").topNode = "Favo"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00018"
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[33]").press
session.findById("wnd[1]/usr/lbl[1,19]").SetFocus
session.findById("wnd[1]/usr/lbl[1,19]").caretPosition = 7
session.findById("wnd[1]").sendVKey 2
session.findById("wnd[0]/tbar[1]/btn[43]").press

'Here still follow SAP GUI commands.
session.findById("wnd[1]/usr/radRB_OTHERS").SetFocus
session.findById("wnd[1]/usr/radRB_OTHERS").Select
session.findById("wnd[1]/usr/cmbG_LISTBOX").Key = "08"
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press

'Here are specific Excel - commands that one can not record. This one needs to know.
Set xclapp = GetObject(, "Excel.Application")
xclapp.DisplayAlerts = False
Set xclwbk = xclapp.Workbooks.Item("Worksheet in ALVXXL01 (1)")
xclapp.ActiveWorkbook.SaveAs ("C:\tmp\myWorkbook.xlsx")
xclapp.ActiveWorkbook.Close
Set xclwbk = Nothing
xclapp.DisplayAlerts = True
Set xclapp = Nothing

Range("A2").Select

End Sub

 

Regards,

Camilo

VBA and SAP Logon pad

$
0
0

Hi, I am new to SAP. I have the SAP Logon 740 screen up and need to bind Excel VBA so I can choose which logon to pick and open SAP. My goal is to choose one of my favorites and export some data. My code fails at ...

Set SapGuiAuto = GetObject("SAPGUI") with the error "Automation Error Invalid Syntax".

I have my reference "SAP Remote Function Call Unicode Control" and "SAP GUI Scripting API" added. I connect through Citrix, not sure if that matters.

 

 

Sub Test()

   Dim SapGuiAuto As Object

  Dim Application As SAPFEWSELib.GuiApplication

  Dim Connection As SAPFEWSELib.GuiConnection

  Dim Session As SAPFEWSELib.GuiSession

  Dim Window As SAPFEWSELib.GuiModalWindow

  Dim Coll As SAPFEWSELib.GuiCollection

 

  Set SapGuiAuto = GetObject("SAPGUI")

  If Not IsObject(SapGuiAuto) Then

    Exit Sub

  End If

...

 

Another option could be login scripts:

I have seen logon scripts, but I don't know where to get all the details...

sapConnection.client = "xxx"

sapConnection.user = "know this"

sapConnection.Language = "EN"

sapConnection.hostname = "xxx"

sapConnection.Password = "know this"

sapConnection.SystemNumber = "x"

sapConnection.Destination = "xxx"

sapConnection.logon

 

I can see the properties from my connection type,

I have systemId, Message Server, Group/Server, InstanceNumber

 

I am also trying to get Script Recording and Playback activated, that may not happen.

 

Any help appreciated.

Re: Scripting not working since upgrade to Windows 7

$
0
0

Hello Tim,


 

I faced the same issue you posted on SAP community (http://scn.sap.com/thread/3301231). The scripts I have recorded just run from excel vba or if I drop them into SAP screen. I am using 32bit system. I was wondering if you could give me any idea of what I could do to run it by just double clicking over it?

 

Appreciate your help.

 

Thank you!

Viewing all 1708 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>