How can I impoprt data from SAP system to excel using VBA - vba

Can anyone help me out regarding A standard code for importing data from SAP SYSTEM TO EXCEL using VBA. I use SE16 transaction and a table named .I need to import data from TFACS table to excel using vba.

If you have access to SE16n you can export directly from there to csv or text file. You can also get with IT to create a nightly spool that will dump a text file into a folder and then link directly to that file with excel.

Related

Populating SQL database table by retrieving data from Excel spreadsheet

I'm new to SQL (but have experience in other programming languages) and I'm taking on a side project at work that involves creating a database of our team's financials. Ultimately what I want to do is have this database retrieve data from a specific table in a worksheet and then populate a database table. I'm sure this is possible but how would I go about doing this? I'm currently familiarizing myself with PostgreSQL as I found it to be the most beginner friendly.
I am using Dbeaver where i can export the data of any table in to CSV , once i have data in CSV , i can create .sql file back using online http://codebeautify.org/csv-to-sql-converter which then can be executed on any other same db.
This will help get you a cell range exported to CSV:
Export sheet from Excel to CSV
Then use this to get the CSV into PostgreSQL:
How to import CSV file data into a PostgreSQL table?

How to generate SQL results to Excel sheet (Oracle)

I am using SQL developer. I need to export the SQL result set to Excel sheet. I know how to export it by manually.
Currently I am using a batch file. Which in turn run's multiple SQL script files. At the end there is a 1 SQL script which contains multiple SQL select statements. Now I need to export these result to excel sheet while running batch file itself.
Batch file Name: Mytest.SQL it contain multiple script files as below.
##test1.sql;
##test2.sql;
##test3.sql;
##test4.sql;
The last script test4.sql contains multiple select statements, which needs to be exported into multiple excels. Please suggest any solution.
Months ago I have found this solution. A ready to use package to unload query result into xlsx file, also with formating. Here is the link. There is also a description how to use the package.
pl/sql package to unload as xlsx
Hope this helps.
I used to do this VB-script, ie I run queries from Excel:
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set ThisWorkbook.OraDatabase = OraSession.OpenDatabase(sDB$, sUSERID$, 0&)
Set OraDynaSet = ThisWorkbook.OraDatabase.CreateDynaset(QueryText, 0&)
You can in this macro calls a script and write cycle data in Excel
Do you need a specific xls file or a csv file?
If you want a csv you can spool a file with sql.
For xls files, you can't do it easily, you'll probably have to go through another programming langage like java or c# or whatever with a specific library to build your report (e.g. for Java Apache POI).

Searching SAS data sets from Excel

I am trying to find a way to search a sas7bdat file from excel for a specific value, and then copy and paste the data into an excel spreadsheet. Currently I can add the whole data set and then search it in excel, but it would be much better if I could search the data set before adding it to excel, as the data sets are sometimes too large for excel to handle.
Is there a way of doing this? Or alternatively is there a way of running some SAS code from excel that would perform the search for me?
Many thanks,
Alastair
SAS has a Microsoft Office add-in that you can use to connect to SAS datasets from excel. See their product page for more information.
There are a few other options for connecting to SAS as a data source; you can use ODBC for example. You also can do what you describe using DDE. Finally, you can produce excel spreadsheets (but not paste into particular spots, easily anyway) using PROC EXPORT or ODS EXCEL (the latter in 9.4 TS1M2+). You can filter the dataset to the appropriate size prior to exporting.

SSIS Import Excel Document Using Column Position, Not Name

I was wondering if it was possible to import Excel documents using SSIS by referencing a column by its position? For example, import columns A,D,M,AA, etc. I ask because I need to load in several Excel documents from a third party. Each document contains the same data type in the corresponding columns, except the column names are different for each document.
Thanks!
Yes but you won't be using the Excel driver and connection manager. Instead, you will use the OLE DB driver and write a SQL Query against the file. For anything but the most basic Excel files, this is my go-to approach for importing data out of Excel.
Various incarnations of my approach
Excel Source as Lookup Transformation Connection
script task in SSIS to import excel spreadsheet
Import a single Excel cell into SSIS

BCP utility to create a format file, to import Excel data to SQL Server 2008 for BULK insertion

Am trying to import Excel 2003 data into SQL table for SQL Server 2008.
Tried to add a linked server but have met with little success.
Now am trying to check if there's a way to use the BCP utility to do a BULK insert or BULK operation with OPENROWSET, using a format file to get the Excel mapping.
First of all, how can I create a format file for a table, that has differently named columns than the Excel spreadsheet colums?
Next, how to use this format file to import data from say a file at: C:\Folder1\Excel1.xsl
into table Table1 ?
Thank you.
There's some examples here that demonstrate what the data file should look like (csv) and what the format file should look like. Unless you need to do this lots I'd just hand-craft the format file, save the excel data to csv, then try using bcp or OPENROWSET.
The format file specifies the column names for the destination. The data file doesn't have column headings so you don't need to worry about the excel (source) cols being different.
If you need to do more mapping etc, then create an SSIS package. You can use the data import wizard to get you started, then save as SSIS package, then edit to your heart's content.
If it's a one-off I'd use the SQL data import size, from right-click on database in mgmt studio. If you just have a few rows to import from excel I typically open a query to Edit Top 200 rows, edit the query to match the columns I have in excel, then copy and paste the rows from excel into SQL mgmt studio. Doesn't handle errors very well, but quick.