Quantcast
Channel: SCN : All Content - Scripting Languages
Viewing all articles
Browse latest Browse all 522

Logon to SESSION MANAGER in SAP with VBA

$
0
0

Hi...

I have Excel macro which extract data from SAP using transaction code via session manager , so when run this macro it's should manually log onto sap first then pop up session manager , the macro then can work smoothly.

 

Now, I want  Excel macro run automatically at night thus need to auto logon to sap until pop up session manager screen.

Please help me if you have code to enable excel macro to auto logon to sap or pls guide me to link which provide more details explanation on how to log on to session manager in sap.

 

However, I have dig into internet for couple of days to find some clues but still can not find it yet. the only code that during my trial can work is below code , but it's works under  vbs file and when translated to excel vba can not works.

 

If Not IsObject(SAPguiApp) Then    Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(Connection) Then    Set Connection = SAPguiApp.OpenConnection("SYSTEM", True)
End If
If Not IsObject(Session) Then    Set Session = Connection.Children(0)
End If
Session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "100"
Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "USER"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "PASSW"
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

 

Thank you .

 

Best regards,

Agung


Viewing all articles
Browse latest Browse all 522

Latest Images

Trending Articles



Latest Images