on 01-14-2016 1:33 PM
Hello all,
My company implemented SAP approximately 6 months ago and since this time I have been able to create several "assistance tolls" within Microsoft Excel that will logon to SAP, run certain TCODES as required, download the data into Excel and format it for ease of use for our supervisors.
Here is my issue, if someone is already logged in to SAP and they run one of my tools it will error out due to the multiple logon screen that pops up. I have not been able to identify a work around, or code that will mark the "Continue with this logo, without ending any other logons in the system..." radio button.
I have discovered the issue and wanted to post it for others in case they have the same problem:
If Not IsObject(SAPguiApp) Then
Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(connection) Then
Set connection = SAPguiApp.OpenConnection("SAPERP", True)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
'logon to SAP
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "USERNAME_HERE"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "PW_HERE"
session.findById("wnd[0]").sendVKey 0
'process used if there are multiple sessions
If session.Children.Count Then
session.findById("wnd[1]/usr/radMULTI_LOGON_OPT2").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
End If
'proceed to the proper TCode screen using the desired layout (I used COOIS)
session.findById("wnd[0]").resizeWorkingPane 105, 31, False
session.findById("wnd[0]/tbar[0]/okcd").Text = "TCODE_TO_USE"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").press session.findById("wnd[1]/usr/txtV-LOW").Text = "LAYOUT_TO_USE"
session.findById("wnd[1]/usr/txtENAME-LOW").Text = ""
session.findById("wnd[1]/tbar[0]/btn[8]").press
'populate the WC ranges within COOIS
session.findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_ARBPL-LOW").Text = wc1
session.findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_ARBPL-HIGH").Text = wc2
'populate the date ranges within COOIS (firstDate and lastDate gathered by another macro)
session.findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_TEREN-LOW").Text = firstDate
session.findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_TEREN-HIGH").Text = lastDate session.findById("wnd[0]/tbar[1]/btn[8]").press
On Error Resume Next
'export to Excel
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").pressToolbarButton "&NAVIGATION_PROFILE_TOOLBAR_EXPAND"
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").selectContextMenuItem "&XXL"
'auto save the file to the desktop on certain versions (bypassed if the save window pops up
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\Users\" & usrId & "\Desktop\"
session.findById("wnd[1]").sendVKey 0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.