Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Message box if sap session is not open

Hi SAP Experts,

I am new to SAP Vbscript. I have created a vbscript in SAP. My scripts extract the data from FBL1N and save it into a folder as .xls formate. Before run this VBscript I have to open SAP session.

So I would like to edit one message box in to my VBscript. This message box should warn If any user run this Vbscript before opening SAP session.

The messaage should be like (Please open SAP Session).

Here is my script:-

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

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

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

session.findById("wnd[0]/usr/ctxtSD_SAKNR-HIGH").setFocus

session.findById("wnd[0]/usr/ctxtSD_SAKNR-HIGH").caretPosition = 0

session.findById("wnd[0]/usr/btn%_SD_SAKNR_%_APP_%-VALU_PUSH").press

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL-SLOW_I[1,0]").text = "40305120"

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL-SLOW_I[1,1]").text = "40305130"

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL-SLOW_I[1,1]").setFocus

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL-SLOW_I[1,1]").caretPosition = 8

session.findById("wnd[1]").sendVKey 8

session.findById("wnd[0]/usr/ctxtSD_BUKRS-LOW").text = "2350"

session.findById("wnd[0]/usr/ctxtPA_STIDA").text = '02102014"

session.findById("wnd[0]/usr/ctxtPA_STIDA").setFocus

session.findById("wnd[0]/usr/ctxtPA_STIDA").caretPosition = 10

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

session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[2]").select

session.findById("wnd[1]/usr/sub:SAPLSPO5:0101/radSPOPLI-SELFLAG[1,0]").select

session.findById("wnd[1]/usr/sub:SAPLSPO5:0101/radSPOPLI-SELFLAG[1,0]").setFocus

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

session.findById("wnd[1]/usr/ctxtRLGRAP-FILENAME").text = str & "\Consignment dump GP1.XLS"

session.findById("wnd[1]/usr/ctxtRLGRAP-FILENAME").caretPosition = 48

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

Could you please help on this.

Sorry for my poor englsih

Thanks & regards,

Pradeep

Former Member
Not what you were looking for? View more on this topic or Ask a question