Hi guys,
I am new to creating macro tools using excel VBA and SAP and I am studying on my own.
I just want to ask if you can help me with creating my macro tool for clearing in SAP tcode f-03 because we are having backlogs of open items and this would help.
Here is my recorded VBA from SAP.
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 = "f-03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/sub:SAPMF05A:0131/radRF05A-XPOS1[4,0]").Select
session.findById("wnd[0]/usr/ctxtRF05A-AGKON").Text = "1992010"
session.findById("wnd[0]/usr/ctxtBKPF-BUDAT").Text = "07.09.2014"
session.findById("wnd[0]/usr/txtBKPF-MONAT").Text = "9"
session.findById("wnd[0]/usr/ctxtBKPF-BUKRS").Text = "lb01"
session.findById("wnd[0]/usr/ctxtBKPF-WAERS").Text = "USD"
session.findById("wnd[0]/usr/sub:SAPMF05A:0131/radRF05A-XPOS1[4,0]").SetFocus
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[0,0]").Text = "2000007080"
session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").Text = "2000007101"
session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").SetFocus
session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").caretPosition = 10
session.findById("wnd[0]/tbar[1]/btn[16]").press
The data that I want to use is coming from my excel file. Below is the sample of the data.
<thead style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; background-color: transparent; ">
</thead><tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; background-color: transparent; ">
</tbody>
After the pair of document numbers are cleared, I also want to copy the message from SAP saying that is cleared and paste it in Excel.
I hope I was able to give you a clear view of what I want to achieve.. I also want the script to loop until all updated document numbers are cleared.
Hope you could help guys!
Thanks alot!
I am new to creating macro tools using excel VBA and SAP and I am studying on my own.
I just want to ask if you can help me with creating my macro tool for clearing in SAP tcode f-03 because we are having backlogs of open items and this would help.
Here is my recorded VBA from SAP.
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 = "f-03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/sub:SAPMF05A:0131/radRF05A-XPOS1[4,0]").Select
session.findById("wnd[0]/usr/ctxtRF05A-AGKON").Text = "1992010"
session.findById("wnd[0]/usr/ctxtBKPF-BUDAT").Text = "07.09.2014"
session.findById("wnd[0]/usr/txtBKPF-MONAT").Text = "9"
session.findById("wnd[0]/usr/ctxtBKPF-BUKRS").Text = "lb01"
session.findById("wnd[0]/usr/ctxtBKPF-WAERS").Text = "USD"
session.findById("wnd[0]/usr/sub:SAPMF05A:0131/radRF05A-XPOS1[4,0]").SetFocus
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[0,0]").Text = "2000007080"
session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").Text = "2000007101"
session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").SetFocus
session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").caretPosition = 10
session.findById("wnd[0]/tbar[1]/btn[16]").press
The data that I want to use is coming from my excel file. Below is the sample of the data.
Header 1 | Header 2 | Header 3 | Header 4 | Header 5 | Header 6 | ||
---|---|---|---|---|---|---|---|
<tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; background-color: transparent; "> </tbody> |
<tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; background-color: transparent; "> </tbody> | Year | Currency | Document number | Clearing Date | ||
1810205 | 7000 | 2014 | USD | 2000325777 | 09.09.2014 | ||
3400112282 | |||||||
<thead style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; background-color: transparent; ">
</thead><tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; background-color: transparent; ">
</tbody>
After the pair of document numbers are cleared, I also want to copy the message from SAP saying that is cleared and paste it in Excel.
I hope I was able to give you a clear view of what I want to achieve.. I also want the script to loop until all updated document numbers are cleared.
Hope you could help guys!
Thanks alot!