Skip to Content
0
Former Member
Jul 17, 2012 at 11:36 AM

VB SCRIPT - POPUP MASSAGE HANDLING

3656 Views

HI

I'M RUNNING A VBSCRIPT (RECORDED AT SAP SYSTEM AND MODIFIED)

THE SCRIPT CONNECTS TO A SESSION AND ACTIVATE A TRANSACTION +

FILLS IN SOME FIELDS.

IN SOME SCENARIOS A POPUP MASSAGE APPEAR.

I NEED TO RECOGNIZE THAT THE POPUP MASSAGE APPEARED AND

IN THIS CASE I WANT TO BE ABLE TO GIVE THE USER THE OPTION

TO READ THE MASSAGE , AND DECIDE (BY ENTER KEYSTROKE) TO CONTINUE THE SCRIPT FLOW

OR (BY ESC KEYSTROKE) TO STOP THE SCRIPT AND KEEP ON MANUALLY .

MY SCRIPT :

Set WshShell = WScript.CreateObject("WScript.Shell")

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

If (Wscript.Arguments.Count < 7) Then

Wscript.Echo "Required Parameter missing"

Do While Not WScript.StdIn.AtEndOfLine

Input = WScript.StdiN.Read(1)

Loop

End If

' Retrieve the first argument (index 0).

PATNR = Wscript.Arguments(0)

ORG = Wscript.Arguments(1)

YOMAN = Wscript.Arguments(2)

SERV1 = Wscript.Arguments(3)

SERV2 = Wscript.Arguments(4)

SERV3 = Wscript.Arguments(5)

SERV4 = Wscript.Arguments(6)

SERV5 = Wscript.Arguments(7)

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

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

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

session.findById("wnd[0]/usr/ctxtZNRN04-PATNR").text = PATNR

session.findById("wnd[0]/usr/ctxtZNRN04-ORGPF").text = ORG

session.findById("wnd[0]/usr/ctxtZNRN04-PLOBJ").text = YOMAN

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,0]").text = SERV1

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,0]").setFocus

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,0]").caretPosition = 9

-----------------------------------

HERE THE MASSAGE MIGHT APPEAR

-----------------------------------

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

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").text = SERV2

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").setFocus

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").caretPosition = 9

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

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE").verticalScrollbar.position = 1

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE").verticalScrollbar.position = 2

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,0]").text = SERV3

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,0]").setFocus

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,0]").caretPosition = 9

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

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").text = SERV4

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").setFocus

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").caretPosition = 9

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

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE").verticalScrollbar.position = 3

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").text = SERV5

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").setFocus

session.findById("wnd[0]/usr/tblSAPLZISH_SCHEDULINGTC_SERVICE/ctxtNLEI-LEIST[1,1]").caretPosition = 9

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

WshShell.AppActivate "זימון מטופל אמבולטורי"