cancel
Showing results for 
Search instead for 
Did you mean: 

SCRIPT TO COPY AND PASTE SAP STATUS BAR MESSAGE GENERATED TO EXCEL SHEET

0 Kudos

Warms greetigs to fellow users.

I m a sap front end user using SAP PM module, where very often,SAP notifications are required to be created ,based on inputs provided.Later these notification are approved by two different users.After which based on this notifications,work order are created,and based on these work order ,work permits are generated.

I want to automate this process in parts.Starting with creation of notifications.The required inputs are fetched from excel during script playback and notification is created for each tag( fetched by script from excel file column 2).After creation of notification of a tag,a message is generated in the status bar,containing notification number(Notification 100002255102 saved).

The script then proceeds for creation of new notification.

i need help with script/cammand that can copy/tranfer this message generated in the status bar to a cell in the excel sheet(under column header-Notification).

The script im using ,which successfully creates notification as per data in excel sheet is as follows :

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

Dim objExcel

Dim objSheet, intRow, i

Set objExcel = GetObject(,"Excel.Application")

Set objSheet = objExcel.ActiveWorkbook.ActiveSheet

For i = 2 to objSheet.UsedRange.Rows.Count

Col1 = Trim(CStr(objSheet.Cells(i, 1).value)) 'column1

Col2 = Trim(CStr(objSheet.Cells(i, 2).value)) 'column2

Col3 = Trim(CStr(objSheet.Cells(i, 3).value)) 'column3

session.findById("wnd[0]/tbar[0]/okcd").text = "/NIW21"

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

session.findById("wnd[0]/usr/ctxtRIWO00-QMART").text = COL1

session.findById("wnd[0]/usr/ctxtRIWO00-QMART").caretPosition = 2

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

session.findById("wnd[0]/usr/subSCREEN_1:SAPLIQS0:1050/txtVIQMEL-QMTXT").text = COL2

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7322/subOBJEKT:SAPLIWO1:0140/ctxtRIWO1-TPLNR").text = COL3

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7322/subOBJEKT:SAPLIWO1:0140/ctxtRIWO1-TPLNR").setFocus

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7322/subOBJEKT:SAPLIWO1:0140/ctxtRIWO1-TPLNR").caretPosition = 21

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

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_2:SAPLIQS0:7715/cntlTEXT/shellcont/shell").setSelectionIndexes 0,0

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB02").select

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB02/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7330/cmbVIQMEL-PRIOK").key = "3"

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB02/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_1:SAPLIQS0:7330/cmbVIQMEL-PRIOK").setFocus

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

session.findById("wnd[1]/usr/btnBUTTON_2").press

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

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

aux=col1 & " " & col2 & " " & col3

CreateObject("Wscript.shell").run("cmd /c @echo %date% %time% " & aux & " >> C:\SCRIPT\PlOrCreationLog.txt")

next

msgbox "Process Completed"

your help would be appreciated.

Accepted Solutions (0)

Answers (1)

Answers (1)

daniel_mccollum
Active Contributor

ErrArea = session.FindById("wnd[0]/sbar/").MessageId

ErrNumber = session.FindById("wnd[0]/sbar/").MessageNumber

ErrType = session.FindById("wnd[0]/sbar/").MessageType

ErrText = session.FindById("wnd[0]/sbar/").text

0 Kudos

Great Job!