Skip to main content
Question

Line selection in SAP ME22N

  • February 20, 2025
  • 8 replies
  • 51 views

Forum|alt.badge.img+4
  • Cadet | Tier 2
  • 6 replies

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? 

 

 

8 replies

Vatsy
Mission Commander | Tier 5
Forum|alt.badge.img+12
  • Mission Commander | Tier 5
  • 93 replies
  • February 21, 2025

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.


Dineshkumar Muthu
Navigator | Tier 3
Forum|alt.badge.img+9

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


Forum|alt.badge.img+4
  • Author
  • Cadet | Tier 2
  • 6 replies
  • February 24, 2025

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-STATUSICON[0,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-STATUSICON[0,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


Dineshkumar Muthu
Navigator | Tier 3
Forum|alt.badge.img+9

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


Forum|alt.badge.img+4
  • Author
  • Cadet | Tier 2
  • 6 replies
  • February 24, 2025
Dineshkumar Muthu wrote:

@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.


Vatsy
Mission Commander | Tier 5
Forum|alt.badge.img+12
  • Mission Commander | Tier 5
  • 93 replies
  • February 25, 2025

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.


Forum|alt.badge.img+3

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

 

Flow looks like this:


 


Shreya.Kumar
Pathfinder Community Team
Forum|alt.badge.img+9
  • Pathfinder Community Team
  • 71 replies
  • March 3, 2025

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings