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

Script to view change in orders

Hi Experts,

I'm new here and I need your help.
I've created an script to save a file with changes in order.
The script works fine, but i need to know, if it´s possible get this information from a list of orders (Excel or access)?
I also need to know if it´s possible to save on the same file the informations from diferent orders.

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]/tbar[0]/okcd").text = "va03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text = "1009023776"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "testemodificacao.xls"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 20


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Sep 10, 2013 at 05:10 AM

    Hello Filipe,

    welcome at the scripting forum.

    I think sure is it possible, because you can integrate in your SAP GUI Scripting code any VBS code you want. So you can combine an access to Excel like this:


    Option Explicit

    Dim oExcel, oWorkBook, oWorkSheet, OrderNumber

    Set oExcel = CreateObject("Excel.Application")
    If IsObject(oExcel) Then
    oExcel.Visible = True
    Set oWorkBook = oExcel.Workbooks.Open("D:\Dummy\Test.xlsx")
    Set oWorkSheet = oWorkBook.Sheets(1)

    '-Write an order number to a cell---------------------------------
    oWorkSheet.Range("A1").Formula = "4711"
    MsgBox "Insert ordernumber"

    '-Read an order number from a cell--------------------------------
    OrderNumber = oWorkSheet.Range("A1").Formula
    MsgBox OrderNumber

    Set oExcel = Nothing
    End If


    As you can see, you can read and write any information you want and on this way you can get your information from Excel, e.g. a list of orders, and you can store informations from different orders.

    I don't know VA03 but I think you must loop around here to set the information:

    For i = 1 To 10

    session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text = _

    oWorkSheet.Range("A" & CStr(i)).Formula

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



    Let us know your result.



    Add a comment
    10|10000 characters needed characters exceeded

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.