Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8735

how to get data from SAP into the excel

$
0
0

Hi all,

 


I need data from SAP to excel using VBA. till now I was able to log into SAP and run the desired transaction I need using excel and VBA now my second biggest Challenge is to export the data I see in SAP into the excel sheet. there are options in SAP to export the data but I need to do it using the VBA. Kindly help me


Please see below the VB code I have written so far, but its just takes me to the data I need but now as I said my second biggest chalange is to get that data from SAP back to Excel.



 

Sub TEST()

'setting the connection with sap:

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]").maximize

session.findById("wnd[0]/tbar[0]/okcd").Text = "iw29"

session.findById("wnd[0]/tbar[0]/btn[0]").press

session.findById("wnd[0]/tbar[1]/btn[17]").press

session.findById("wnd[1]/tbar[0]/btn[8]").press

session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").currentCellColumn = "TEXT"

session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "0"

session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").setCurrentCell -1, ""

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectAll

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").contextMenu

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectContextMenuItem "&XXL"

session.findById("wnd[1]/tbar[0]/btn[0]").press

 

End Sub




Regards,

Imran


Viewing all articles
Browse latest Browse all 8735

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>