Skip to main content

Hello, 

Currently trying to automate line selection in ME22N. This doesn’t appear to be possible, outside of a VB Script running SAP. This isn’t ideal, so I wanted to see if this community had any other items? 

 

 

Hi ​@p1094,
Please explain the issue that you are facing along with your use case that you are trying to automate for a better understanding.


​@p1094 , have you tried these packages SAP,SAP BAPI, Recorder?


Hello, the SAP script path I’m trying to click does not store the line row number. For this reason the SAP select item package doesn’t work. I have tried using various actions in the SAP action package. I am using this script. But the control ID is not consistently found. 

 

Function SelectRow(rowNumber)
    On Error Resume Next ' Enable error handling

    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]").maximize

    ' Ensure rowNumber is set and valid
    If IsNumeric(rowNumber) And rowNumber <> "" Then
        Dim tablePath
        tablePath = "wnd<0]/usr/subSUB0:SAPLMEGUI:0020/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211"
        
        ' Check if the first path exists
        If Not session.findById(tablePath, False) Is Nothing Then
            session.findById(tablePath).getAbsoluteRow(CInt(rowNumber)).selected = true
            session.findById(tablePath & "/btnMEPO1211-STATUSICONe0,8]").setFocus
        Else
            ' Use the alternative path
            tablePath = "wndÂ0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211"
            session.findById(tablePath).getAbsoluteRow(CInt(rowNumber)).selected = true
            session.findById(tablePath & "/btnMEPO1211-STATUSICONe0,8]").setFocus
        End If
    Else
        MsgBox "Invalid row number: " & rowNumber
    End If

    If Err.Number <> 0 Then
       ' Log the error or handle it as needed
       MsgBox "An error occurred: " & Err.Description
       Err.Clear ' Clear the error
    End If

    On Error GoTo 0 ' Disable error handling
End Function


​@p1094 , Have you tried using the recorder package to capture? This capture will provide the ID and the path of the object.


​@p1094 , Have you tried using the recorder package to capture? This capture will provide the ID and the path of the object.

The recorder is not an option. It doesn’t have visibility into the SAP table at all.


Hi ​@p1094,

In SAP if you are not able to use recorder: capture action then please check if the GUI scripting option is enabled within your SAP Logon.

 

To enable SAP script recording and playback, you need to access your SAP GUI settings and activate the "Script Recording and Playback" feature, which can be found under "Customize Local Layout" in the SAP Logon window.

 

Please ensure the "Scripting" option is enabled within your SAP client settings to allow recording and playback of actions within the SAP interface.


Hi ​@p1094 you can actually capture the table in SAP 
 

 

Flow looks like this:


 


​@p1094 have you been able to try the suggestions that ​@Vatsy and ​@jeven.delacruz mentioned?


Reply