Hi Team,
I have written the below mentioned code. Problem - every time code is executed, its successfully login in SAP and show me the first screen for 1 second and then, its gets closed automatically. Can you please help
Code:-
Set app = CreateObject("Sapgui.ScriptingCtrl.1")
Set Connection = app.OpenConnection("P1P", True)
Set session = Connection.Children(0)
'here is what you enter when you connect manualy:
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "010"
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "username"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "password"
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus
session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
Further, I want to open T code "YFPF" and code VBA to pick up year & period from sheet "Base" cell C4 for year and C5 for period from file "SAP log on". then, go to variants and get variant "manres us" and make all fields blank. execute and extract the report into excel and save it on location. Can you please help.
Thanks in advance.
I have written the below mentioned code. Problem - every time code is executed, its successfully login in SAP and show me the first screen for 1 second and then, its gets closed automatically. Can you please help
Code:-
Set app = CreateObject("Sapgui.ScriptingCtrl.1")
Set Connection = app.OpenConnection("P1P", True)
Set session = Connection.Children(0)
'here is what you enter when you connect manualy:
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "010"
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "username"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "password"
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus
session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
Further, I want to open T code "YFPF" and code VBA to pick up year & period from sheet "Base" cell C4 for year and C5 for period from file "SAP log on". then, go to variants and get variant "manres us" and make all fields blank. execute and extract the report into excel and save it on location. Can you please help.
Thanks in advance.