Hi guys,
i would need help with few things
1. Is it possible to extract excel format from SAP reather than file format?
2. Is it possible to use vba code for copying data from excel to SAP? Can you proivide sample of the code (from column A, rows 1-10 for example) to SAP transaction code FBL1N?
3. Can you help me merge below two VBA codes....aparently I am doing something wrong
Thank you in advance!!
PART1:
Sub SAP_Open()
Dim SapGui
Dim Applic
Dim connection
Dim session
Dim WSHShell
Shell "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbNormalFocus
Set WSHShell = CreateObject("WScript.Shell")
Do Until WSHShell.AppActivate("SAP Logon ")
Application.Wait Now + TimeValue("0:00:01")
Loop
Set WSHShell = Nothing
Set SapGui = GetObject("SAPGUI")
Set Applic = SapGui.GetScriptingEngine
On Error Resume Next
Set connection = Applic.OpenConnection("SG00 - P34: SHAPE Production ERP (with SSO)", True)
Set connection = Applic.OpenConnection("SP01 - P34 : SHAPE ERP Production (with SSO)", True)
End Sub
PART2:
Sub test_transaction()
Dim App, connection, session As Object
Set SapGuiAuto = GetObject("SAPGUI")
Set App = SapGuiAuto.GetScriptingEngine
Set connection = App.Children(0)
Set session = connection.Children(0)
session.findById("wnd[0]/tbar[0]/okcd").Text = "FBL1N" 'change tranasaction
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/usr/txtV-LOW").Text = "USER1" 'change variant name
session.findById("wnd[1]/usr/txtENAME-LOW").Text = "USER1" ' change variant creator
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press 'start process
'save as local file - spreadsheet
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[2]").Select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\Users\..." 'filepath for export
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "TEST" 'filename
session.findById("wnd[1]/tbar[0]/btn[11]").press
End Sub
i would need help with few things
1. Is it possible to extract excel format from SAP reather than file format?
2. Is it possible to use vba code for copying data from excel to SAP? Can you proivide sample of the code (from column A, rows 1-10 for example) to SAP transaction code FBL1N?
3. Can you help me merge below two VBA codes....aparently I am doing something wrong
Thank you in advance!!
PART1:
Sub SAP_Open()
Dim SapGui
Dim Applic
Dim connection
Dim session
Dim WSHShell
Shell "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbNormalFocus
Set WSHShell = CreateObject("WScript.Shell")
Do Until WSHShell.AppActivate("SAP Logon ")
Application.Wait Now + TimeValue("0:00:01")
Loop
Set WSHShell = Nothing
Set SapGui = GetObject("SAPGUI")
Set Applic = SapGui.GetScriptingEngine
On Error Resume Next
Set connection = Applic.OpenConnection("SG00 - P34: SHAPE Production ERP (with SSO)", True)
Set connection = Applic.OpenConnection("SP01 - P34 : SHAPE ERP Production (with SSO)", True)
End Sub
PART2:
Sub test_transaction()
Dim App, connection, session As Object
Set SapGuiAuto = GetObject("SAPGUI")
Set App = SapGuiAuto.GetScriptingEngine
Set connection = App.Children(0)
Set session = connection.Children(0)
session.findById("wnd[0]/tbar[0]/okcd").Text = "FBL1N" 'change tranasaction
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/usr/txtV-LOW").Text = "USER1" 'change variant name
session.findById("wnd[1]/usr/txtENAME-LOW").Text = "USER1" ' change variant creator
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press 'start process
'save as local file - spreadsheet
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[2]").Select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\Users\..." 'filepath for export
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "TEST" 'filename
session.findById("wnd[1]/tbar[0]/btn[11]").press
End Sub