Skip to Content
author's profile photo Former Member
Former Member

how to get data from a me1m transaction to excel through scripting

hi, all the below is a me1m transaction. i would like to get the vendor names for a part number from sap, as you can see i some vendor names displayed for a part number I entered, i would like to have a sap scripting that would open me1m transaction and get part number info from for it and copy vendor names for the part number and paste it to the excel sheet, i can open me1m and enter part number to it, but i cant get the data from me1m, so anyone knowledge plse help

the below mentioned is script file.

'vb code

Dim oSapGuiAuto As Object

Dim oGuiApplication As Object

Dim oConnection As Object

Dim oSession As Object

Dim indexOD As Long

Dim lngCountOD As Long


' Activate Scripting

Set oSapGuiAuto = GetObject("SAPGUI")

Set oGuiApplication = oSapGuiAuto.GetScriptingEngine

If oConnection Is Nothing Then Set oConnection = oGuiApplication.Children(0)

If oSession Is Nothing Then Set oSession = oConnection.Children(0)

If oSession Is Nothing Then Exit Sub

' Exit if you don't sure

If MsgBox("Now connecting [ " & oSession.PassportSystemId & " ], Continue Processing?", _

vbOKCancel) = vbCancel Then Exit Sub


'//********** Put recorded code here *******************///'

With oSession


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

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

'part number is taken from excel sheet

.findById("wnd[0]/usr/ctxtIF_MATNR-LOW").Text = "partnumber"

.findById("wnd[0]/usr/ctxtI_EKORG-LOW").Text = "282b"


.findById("wnd[0]/usr/ctxtI_EKORG-LOW").caretPosition = 4


.findById("wnd[0]").resizeWorkingPane 265,39,false

.findById("wnd[0]/usr/ctxtIF_LIFNR-LOW").text = ""


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


.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellColumn = "LIFNR"


End With

'//********** Put recorded code here *******************///'

Next indexOD

End With

MsgBox "All DONE!"

' Cleanup

Set oSession = Nothing

Set oConnection = Nothing

Set oGuiApplication = Nothing

Set oSapGuiAuto = Nothing


End Sub

the issues i am facing ctrl + y and ctrl +c function to get data from sap to excel cannot be scripted. i want some soluction to locate vendor column and get data from it.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Dec 02, 2015 at 12:28 PM

    Hi Deepan

    You can find the Column specified Column with this little peace of Code:

    Set grid = sapsession.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell")
            Set colValues = grid.SelectedColumns()
            IntColCount = colValues.Count
            For i = 0 To IntColCount - 1
                If grid.GetDisplayedColumnTitle(colValues(i)) = "Vendor" Then
                    Exit For
                End If
            v_text = grid.GetCellValue(1, colValues(i))

    This returns the first Value in the Vendor Column

    have fun

    Bg Thomas B

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Script Man


      thanks scriptman and thomas too, the code worked, issue is i have only one row with value and thomas have given reference to row 1,whereas sap row starts from row0,so i changed code

      v_text = grid.GetCellValue(0 , "LIFNR") and it worked, thank you both the gentlemen for your help in time.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.