I am new to Excel VBA.
I don't know how to get the data from SAP table to Excel sheet.
The query is.
I have one Excel sheet containing 10 fields.
pcode field (in Excel),
PL will be imported from SAP table.
ID | name | pcode | PL (from SAP)
1 | kiran | 1234 |
2 | karan | 5001 |
There's a lot of documentation online for writing into Excel sheets from VB, as there is a lot of documentation for reading SQL table data into VB, you can google these things and find what you need. Something you might not find through Google is how to track down the tables you actually require. SAP data all comes from tables that I like to call "Background" tables. Although SAP presents all the data in a nice format which is easy on the eyes, it is all actually just a set of big ugly SQL tables. Lets say I want to extract all of the items that I have in stock (as far as SAP knows), then write this info into an excel sheet, here's where to begin:
Firstly TURN ON SYSTEM INFORMATION. To do this, press Ctrl + Shift + I (or go to View -> system information), now when you hover over a field, the bar at the bottom of the SAP screen will tell you all of the background information that you'll need to find the location of the data in SQL.
When you hover your cursor over a field, the bar highlighted in this image should show something like this:
Manual [Form = 142 Item = 38 Pane = 1 Column = 14700021 Row = 1 Variable = 11 POR1,UomCode]
Here the parts we are interested are the "POR1, UomCode" Here, "POR1" will be the name of the SQL table which contains the data you're after, and "UomCode" is the column name.
This example was for a purchase order, but for item master data this information will be different, the table name will be OITM, with item details being held in ITM1.
And so you would contruct a SQL query which will bring through all the info you need from the tables, package it up into variables in whatever programming language you choose (I use VB.NET), then spit it out into Excel.
Hope this helped!