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

Re: Menu "Script Recording and Playback..." randomly greyed out

$
0
0

Script recording and Playback Dialog can only started once. So if this Dialog is called you won´t be able to have a second instance.

 

Why you will open it in another session?


Re: Menu "Script Recording and Playback..." randomly greyed out

$
0
0

Yes, it can be started multiple times. This function has been working for me in the past several times. The function stopped working when I switched laptops. We are thinking that it has to due with the SAP version... we are still investigating?

 

Opening the "Script Recording and Playback" on each SAP window allows me run multiple scripts at once ... in order to save time.

Re: Menu "Script Recording and Playback..." randomly greyed out

$
0
0

When I have started script recording and playback in one session this is greyed out in all other sessions. So this is not possible for me either.

 

I run my scripts from Excel VBA and have some functions to Loop over all open sessions (which are not busy) and Scripting is enabled.

 

When I want to run parallel scripts I open an new Excel Instance -> open my SAP Scripting workbook in there and select an non-busy session in the right System.

SAP_Sessions1.png

Re: Menu "Script Recording and Playback..." randomly greyed out

$
0
0

I am interested in the call/select the "Available SAP Session's"

 

I have not seen that dialog box. Is that a macro to view the available sessions?

Re: Menu "Script Recording and Playback..." randomly greyed out

$
0
0

Yes, I have developed an standard macro-enabled Excel template which I enhance with required coding from script recording.

 

In the document section of htis Forum I have placed an guidance how to rebuild this template. It Looks more difficult then it is in real life. As most of this coding is just the required Framework for script recording coding.

Error handling for Changing GUI Size?

$
0
0

I'm having a bit of an issue with regards to a small script i wrote to update purchase order vendor payment terms as well as advancement of the PO version after said payment term has been updated (post save).

 

Very strange error that i'm hitting... depending on what tabs i'm utilizing within a PO for entering data (Delivery/Invoice or Version), it seems that the onscreen GUI size is changing which then alters the background code for the script.  I've highlighted the portions of the script below that are failing.  The element seems to be jumping between 0010, 0013, 0018, and 0020.  I've had no luck in making an integer replacement for those elements and incrementing through the 4 variables.

 

If anyone could provide a bit of VBA insight here i'd appreciate it.

 

Dim session

 

 

Function MODPO()

Dim Application

Dim material, plant As String

Dim xPO As String

Dim sbarmessage As String

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

    InputRow = InputBox("Enter the Starting Row", "Starting Row", 3)

    Row = CInt(InputRow)

    xPO = Worksheets("MODPO").Cells(Row, 1)

While xPO <> ""

    xPO = Worksheets("MODPO").Cells(Row, 1)

    xPAYTERMS = Worksheets("MODPO").Cells(Row, 2)

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

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

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

        session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").Text = xPO

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

        sbarmessage = session.findById("wnd[0]/sbar").Text

            If InStr(sbarmessage, "does not exist") Then

                GoTo ROWPLUS

            End If

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1").Select

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT1/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1226/ctxtMEPO1226-ZTERM").Text = xPAYTERMS

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

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

            If session.ActiveWindow.Name = "wnd[1]" Then

                If session.findById("wnd[1]").Text Like "Save*" Then

                    session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press

                    GoTo MODVERSION

                End If

            End If

            If session.ActiveWindow.Name = "wnd[1]" Then

                If session.findById("wnd[1]").Text Like "Information*" Then

                    session.findById("wnd[1]").Close

                    GoTo ROWPLUS

                End If

            End If

MODVERSION:

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

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT13").Select

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT13/ssubTABSTRIPCONTROL2SUB:SAPLMEDCMV:0100/cntlDCMGRIDCONTROL1/shellcont/shell").modifyCheckbox 0, "REVOK", True

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT13/ssubTABSTRIPCONTROL2SUB:SAPLMEDCMV:0100/cntlDCMGRIDCONTROL1/shellcont/shell").currentCellColumn = "REVOK"

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

            If session.ActiveWindow.Name = "wnd[1]" Then

                If session.findById("wnd[1]").Text Like "Save*" Then

                    session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press

                End If

            End If

ROWPLUS:

        Row = Row + 1

        xPO = Worksheets("MODPO").Cells(Row, 1)

        Worksheets("MODPO").Cells(Row, 1).Select

    Wend

End Function

Re: SAP.Functions and VBA connectivity fail

$
0
0

Hello Ekaterina,

 

it seems that the trace protocoll dosn't help us.

 

But your oberservation with the saplogon.ini file seems to be promising.

 

I check it on my test system. The saplogon.ini file is in access of SAP logon control in the following direction

"C:\Users\MyUser\Documents\AppData\Roaming\SAP\Common\saplogon.ini"

"C:\Dummy\SAPLOGON.INI" (Your actual directory)

"C:\WINDOWS\SAPLOGON.INI"

 

You use the attribute ApplicationServer and SystemNumber, these identifies your target system unique. I suggest - only for experimental reasons - that you rename all saplogon.ini files on a computer where your script doen't run and check if it works now. Don't forget to rename the files back. In my case a saplogon.ini is not necessary, it works without perfect. If it runs you know it is a saplogon.ini conflict.

 

Let us know your results.

 

Cheers

Stefan

Re: Error handling for Changing GUI Size?

$
0
0

Hello Ehren,

 

welcome in the Scripting Language forum.

 

You can try this:

 

Dim session As Object

Dim Container As Object

 

Sub Test()

 

  On Error Resume Next

  Set Container = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010")

  If Err.Number = 0 Then

    On Error GoTo 0

    Exit Sub

  End If

  Err.Clear

 

  Set Container = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013")

  If Err.Number = 0 Then

    On Error GoTo 0

    Exit Sub

  End If

  Err.Clear

 

End Sub

 

Sub Test2()

 

  Set SapGuiAuto = GetObject("SAPGUI")

  Set App = SapGuiAuto.GetScriptingEngine

  Set Connection = App.Children(0)

  Set session = Connection.Children(0)

 

  Set Container = Nothing

  Test

  MsgBox Container.ID

 

End Sub

 

With On Error Resume Next you disable the automatic error routine. If the object doesn't exists nothing happens, but Err.Number is <> 0. If Err.Number = 0 the object exists and you leave the sub routine. The global variable Container is set and you can work with it.

 

Let us know your results.

 

Cheers

Stefan


Re: Error handling for Changing GUI Size?

$
0
0

This is an got Approach from Stefan.

 

You can make an function as well which can set "0010", "0013"...aso according to the Container which exist. Using an SELECT-method.

Re: Script recording doesn't record save of file

$
0
0

You are right :-(

This is not an option for me. I'm using GUI 720

Re: Script recording doesn't record save of file

$
0
0

There are some more Options. One is to use API-functions checking in a Loop for SAP MS SaveAS Dialog in a seperate Excel instance. In this Forum and many other places you will find a lot of examples how to use.

 

This is done via some USER32.DLL API functions.

Re: Error handling for Changing GUI Size?

$
0
0

Stefan - Thank you for the input.  Unfortunately, i'm still having difficulty.  How are you implementing the subcommand into the body of the script?  Are you calling Test in place of the SAP .Select command? How is the Container object being utilized outside of the subcommand?

 

Apologies... i'm not trying to be obtuse.  I just haven't dealt with this type of error handling before.

Re: Error handling for Changing GUI Size?

$
0
0

Actually... I modified your info a bit to meet my need.  I doubt it's as elegant as it could be, but the solution ended up working per the below, having declared X as an integer beginning at 8:

 

        Do

            On Error Resume Next

            session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:00" & X & "/stuff goes here.Select

                If Err.Number = 0 Then

                    On Error GoTo 0

                    Err.Clear

                    Exit Do

                End If

            X = X + 1

        Loop

Re: Error handling for Changing GUI Size?

$
0
0

As required number need to have 4-digits you should implement an string handling if X <10 to ensure always 4-digits.

Re: Error handling for Changing GUI Size?

$
0
0

Understood.

 

I was using 8 as a starter to test the effectivity of the error handle.  The sizing won't return below 10.  My final declares the integers utilized at 10.

 

Thank you for the input though, Holger.  Much appreciated.


Re: Error handling for Changing GUI Size?

$
0
0

Hello Ehren,

 

thanks for your reply. Two years ago I wrote here about a method how to check the existence of an object without a message box. My design pattern here is a simple approach of that, to show a possible procedure for your case. I coded it in a VBA environment, so it looks a little bit different from VBScript, e.g. the variable types.

 

To your questions:

 

  1. As far as I can see you are checking the ID of a GuiContainer object, but this object doesn't contain the property select. So I assume this is not an option.

  2. You can define sub procedures in VBScript where you want, look at this example:

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

      '-Sub TestTwo-----------------------------------------------
        Sub TestOne()
          MsgBox "TestOne"
          TestTwo
        End Sub

      '-Main------------------------------------------------------
        TestOne
        TestTwo

      '-Sub TestTwo-----------------------------------------------
        Sub TestTwo()
          MsgBox "TestTwo"
        End Sub

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

  3. No, the Test sub routine is not a replacement for the select property.It is only a structuring element.

  4. I defined the Container variable in the global context of the program, so you can use it in any procedure easily. Sometimes it is practicable to work on this way, but it is not really good - keyword encapsulation.

Hope my explanations answers your questions.

 

You are welcome.

 

Cheers

Stefan

Re: SAP.Functions and VBA connectivity fail

$
0
0

Hi Stefan,

 

And what GUI build and version do you use?

 

Ekaterina

Re: SAP.Functions and VBA connectivity fail

$
0
0

Hello Ekaterina,

 

Version 7.30 PL 12.

But I will try also Version 7.40 in the next days.

 

Cheers

Stefan

Re: SAP.Functions and VBA connectivity fail

$
0
0

So, saplogon.ini files exist in the following directories.

C:\Users\MyUser\AppData\Roaming\SAP\Common\

C:\WINDOWS\

 

And SAPUILandscape.xml in

C:\Users\MyUser\AppData\Roaming\SAP\Common\

 

Loaded local file is SAPUILandscape.xml and really I do not need saplogon.ini, SAPUILandscape.xml is enough for all SAP GUI purposes now.

 

But until I renamed them all I had an error. Code looks for the entry with the first alphabetical name in the section "name" of SAPUILandscape.xml, if doesn't find, in [Description] of saplogon.ini (one of the paths above), and only if all three destinations have nothing - the variables or values.

 

I have now SAP GUI 7.40 SP4 + BEx P3 and it doesn't work, so I think it is now the time to create an OSS Message.

VBA Code to export data from SAP and save to Desktop

$
0
0

Hi Script Gurus,

 

Good day.

 

I just wanna ask for your help in figuring out what is the solution to my problem.

I want to export a report in SAP and save it as PDF. When i click the "Ok" button to save the report, a new dialog box with name "Pdf995 Save As" appear after 3 seconds. Im trying to control the dialog box using SendKeys but it is not working. Below is the code:

 

Please help.

 

 

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

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

   

   

    WScript.Sleep 10000

    Set Wshell = CreateObject("Wscript.Shell")

    Do

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

    WScript.Sleep 1000

    Loop Until bWindowFound

    WScript.Sleep 5000

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

    If (bWindowFound) Then

    WScript.Sleep 5000

    Wshell.AppActivate "Pdf995 Save As"

    WScript.Sleep 100

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

    WScript.Sleep 100

    Wshell.SendKeys ("{ENTER}")

    WScript.Sleep 100

    End If

Viewing all 1708 articles
Browse latest View live


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