Export tables to one (csv) multiple spreadsheets in one workbook
Hi,
I have a script for auditing users and parameters and so far I have exported the tables to different csv files.
Is it possible to export e.g. two tables to two spreadsheet in one csv file?
Thanks! :)
Hi,
A csv in not an excel document - it can be opened as if it it an excel file but there is no way to turn a .csv into a multi worksheet file.
You need some tool that can wtire this natively do this or some vba or something inside excel to fetch the data and populate multiple sheets?
Regards,
Harry
Similar Messages
-
Exporting table data in csv format
hi all...
my schema has total 672 tables and i need to export thedatas of all tables in separate csv files(i.e for one table there will be one csv)..
I am using plsql developer...but i got no tool to do that..
Manually doing that is next to impossible for all the tables...
Is there any way out???
please help...hi...is it possible to do this using simple cursor...
i have tried this...but its not working...
SQL> spool d:\abcd.csv
Started spooling to d:\abcd.csv
SQL>
SQL> declare
2 cursor c1 is select table_name from user_tables;
3 v_c1 c1%rowtype;
4
5 begin
6 open c1;
7 loop
8 fetch c1 into v_c1;
9 exit when c1%notfound;
10 select * from v_c1.table_name;
11 end loop;
12 close c1;
13
14 end;
15 /
declare
cursor c1 is select table_name from user_tables;
v_c1 c1%rowtype;
begin
open c1;
loop
fetch c1 into v_c1;
exit when c1%notfound;
select * from v_c1.table_name;
end loop;
close c1;
end;
ORA-06550: line 11, column 20:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 11, column 1:
PL/SQL: SQL Statement ignored
SQL> -
Reg: Export table data into CSV
Hi Experts,
I'm stuck up with a requirement, where I have to export data of all tables from a schema into separate table specific CSV files.
I tried using SQL Plus 'SPOOL' but it gives me additional queries executed on top of CSV generated.
Also, i'm not getting the headers (coz i'm using pagesize 0 )
Any help id highly appreciated?
Ranit B.Starting point...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required.
With this you can call the procedure for each of your tables, querying whatever columns you want, and specifying whatever filename(s) you want. -
Export tables from one database in other.
hi,
I want to export the all tables and views (only structure) from remote database in my local database. How can i do the same?
Is ther anyay to export only 5 rows of each table as export of all rows from table will take lot of space..
AshishBut i dont knw where to write that code.. Can u explain me a bit?I have to say that I don't underdand... Didn't you want export the table structure from one database ? If so, I send you a link to the documentation about the option on the command line which you waited for.
Moreover, there is an example. I don't know what can I say more ?
Ah yeah, expdp is an OS prompt command, not sql*plus.
Nicolas. -
Exporting table data to .csv file
How to export the table data (this table is having 18 million records) to .csv file. using SQL Developer and PL/SQL deveoloper it is taking too long time to complete. Please let me know is there any faster way to complete this task.
Thanks in advanceAlso bear in mind that SQL Developer and PL/SQL Developer are running on your local client, so it's transferring all 18 million rows to the client before formatting and putting them out to a file. If you had some PL/SQL code to export it on the database server it would run a lot faster as you wouldn't have the network traffic delay to deal with, although your file would then reside on the server rather than the client (which isn't necessarily a bad thing as a lot of companies would be concerned about the security of their data especially if it ends up being stored on local machines rather than on a secure server).
As already asked, why on earth do you need to store 18 million rows in a CSV file? The database is the best place to keep the data. -
I am having to export a schema's tables in CSV format. The largest has 10,000,000 rows.
I've written an SQL*Plus script that automatically creates a SQL script for each table using the USER_TABLES view. So far, so good...
Unfortunately, running the 10,000,000 row export script, for example, takes 20 hours (down from 40 hours thanks to several SET commands to aid efficiency). The output file is 900Mb.
Is there a better (as in quicker) way? I threw it at TOAD which, er, croaked!Tom Kyte has a few utilities to do this kind of thing. Try this link to see what he has available.
http://asktom.oracle.com/~tkyte/flat/index.html
HTH
John -
Export tables from one db to another
Hi,
I would like to copy/export a table of X database to Y database.
Is it posible to use an export statement using SQL command so that I could use it in my profram (as I have sevral tables to export) in a loop.
Tnx
PapsHello guys!
I have the same problem and I already did everything but its still wont work.
When using COPY in SQL*Plus:
=======================
COPY FROM user1/user1PW@ipDataRemote
TO user2/user2PW@mylocalDB
create loadTestingTable
using select ID FROM ipdata.table;
Error messsage:
================
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
ERROR:
ORA-00904: invalid column name
When using EXP:
================
exp user1/user1PW@ipDataRemote
tables=(ipdata.table)
file=ipdataTableFile.dat
Then I use IMP to import ipdataTableFile.dat file:
==================================================
imp user2/user2PW@mylocalDB file=ipdataTableFile.dat tables=myLocalTable show=y ignore=y COMMIT=Y
It gives me the following:
==========================
Import: Release 8.1.7.0.0 - Production on Mon Mar 15 15:48:34 2004
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production
Export file created by EXPORT:V08.01.07 via conventional path
Warning: the objects were exported by USER1, not by you
import done in WE8ISO8859P1 character set and WE8ISO8859P1 NCHAR character set
export server uses UTF8 NCHAR character set (possible ncharset conversion)
Import terminated successfully without warnings.
I thought it was running fine but it never imported those records.
Do you guys know what I did wrong here? -
How to give path in plsql while exporting table data into .csv file
hi,
i have a code like this
PROCEDURE dump_table_to_csv (
p_tname IN VARCHAR2,
p_dir IN VARCHAR2,
p_filename IN VARCHAR2
IS
l_output UTL_FILE.file_type;
l_thecursor INTEGER DEFAULT DBMS_SQL.open_cursor;
l_columnvalue VARCHAR2 (4000);
l_status INTEGER;
l_query VARCHAR2 (1000) DEFAULT 'select * from ' || p_tname;
l_colcnt NUMBER := 0;
l_separator VARCHAR2 (1);
l_desctbl DBMS_SQL.desc_tab;
BEGIN
l_output := UTL_FILE.fopen (p_dir, p_filename, 'w');
EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss''';
DBMS_SQL.parse (l_thecursor, l_query, DBMS_SQL.native);
DBMS_SQL.describe_columns (l_thecursor, l_colcnt, l_desctbl);
FOR i IN 1 .. l_colcnt
LOOP
UTL_FILE.put (l_output,
l_separator || '"' || l_desctbl (i).col_name || '"'
DBMS_SQL.define_column (l_thecursor, i, l_columnvalue, 4000);
l_separator := ',';
END LOOP;
UTL_FILE.new_line (l_output);
l_status := DBMS_SQL.EXECUTE (l_thecursor);
WHILE (DBMS_SQL.fetch_rows (l_thecursor) > 0)
LOOP
l_separator := '';
FOR i IN 1 .. l_colcnt
LOOP
DBMS_SQL.column_value (l_thecursor, i, l_columnvalue);
UTL_FILE.put (l_output, l_separator || l_columnvalue);
l_separator := ',';
END LOOP;
UTL_FILE.new_line (l_output);
END LOOP;
DBMS_SQL.close_cursor (l_thecursor);
UTL_FILE.fclose (l_output);
EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-MON-yy'' ';
EXCEPTION
WHEN OTHERS
THEN
EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-MON-yy'' ';
RAISE;
END;
I am getting error like :-------
SQL> exec dump_table_to_csv('deptair','c:/csv','aa.deptair');
BEGIN dump_table_to_csv('deptair','c:/csv','aa.deptair'); END;
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 8
ORA-29280: invalid directory path
ORA-06512: at "SCOTT.DUMP_TABLE_TO_CSV", line 58
ORA-06512: at line 1
pplease help me out
thanks
vickylook at your other thread, answer is already there.
-
How can we export table data to a CSV file??
Hi,
I have the following requirement. Initially business agreed upon, exporting the table data to Excel file. But now, they would like to export the table data to a CSV file, which is not being supported by af:exportCollectionActionListener component.
Because, when i opened the exported CSV file, i can see the exported data sorrounded with HTML tags. Hence the issue.
Does someone has any solution for this ... Like, how can we export the table data to csv format. And it should work similar to exporting the data to excel sheet.
For youre reference here is the code which i have used to export the table data..
><f:facet name="menus">
><af:menu text="Menu" id="m1">
><af:commandMenuItem text="Print" id="cmi1">
><af:exportCollectionActionListener exportedId="t1"
>title="CommunicationDistributionList"
>filename="CommunicationDistributionList"
>type="excelHTML"/> ---- I tried with removing value for this attribute. With no value, it did not worked at all.
></af:commandMenuItem>
></af:menu>
></f:facet>
Thanks & Regards,
Kiran KonjetiHi Alex,
I have already visited that POST and it works only in 10g. Not in 11g.
I got the solution for this. The solution is :
Use the following code in jsff
==================
<af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="text/csv; charset=utf-8"
>filename="test.csv"
>method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
></af:commandButton>
OR
<af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="application/vnd.ms-excel; charset=utf-8"
>filename="test.csv"
>method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
></af:commandButton>
And place this code in ManagedBean
======================
> public void test(FacesContext facesContext, OutputStream outputStream) throws IOException {
> DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
>DCIteratorBinding itrBinding = (DCIteratorBinding)dcBindings.get("fetchDataIterator");
>tableRows = itrBinding.getAllRowsInRange();
preparaing column headers
>PrintWriter out = new PrintWriter(outputStream);
>out.print(" ID");
>out.print(",");
>out.print("Name");
>out.print(",");
>out.print("Designation");
>out.print(",");
>out.print("Salary");
>out.println();
preparing column data
> for(Row row : tableRows){
>DCDataRow dataRow = (DCDataRow)row;
> DataLoaderDTO dto = (DataLoaderDTO)dataRow.getDataProvider();
>out.print(dto.getId());
>out.print(",");
>out.print(dto.getName());
>out.print(",");
>out.print(dto.getDesgntn());
>out.print(",");
>out.print(dto.getSalary());
>out.println();
>}
>out.flush();
>out.close();
> }
And do the following settings(*OPTIONAL*) for your browser - Only in case, if the file is being blocked by IE
==================================================================
http://ais-ss.usc.edu/helpdoc/main/browser/bris004b.html
This resolves implementation of exporting table data to CSV file in 11g.
Thanks & Regards,
Kiran Konjeti -
How-To : bapi export table webdynpro bapi import table
Hi folks!
This is proving to be very difficult. my appreciation is <b>10 points to the first helpful answer!!</b>
I am receiving an export table from one bapi (z_xxx_getlist) into my webdynpro. I want to then import the same table into another bapi (z_xxx_savelist) so it can be saved in R/3.
- firstly I tried to map the the view's context attributes to the 2nd bapi, but that didn't work because it deleted the original mapping.
- then I created a new context node for the save bapi and tried to sync data between the nodes, but only ran into nullpointer exceptions.
What's the standard procedure for such a requirement?
Great thanks,
faB
ps. this is related to this previously posted topic:
copying data of 1 view context node to another></b><b></b><b></b>Never mind, the nullpointer exception was because ".currentZlo_Price_Display_InputElement()" should have been ".currentOutput_DisplayElement()"
Hi.
I have tried your suggestion, but I only get a nullpointer exception on the line shown below.
RFC1 was already called and the data shown in a table.
Many thanks,
faB
wdContext.currentZlo_Price_Change_InputElement()
.modelObject()
<b> .setRelatedModelObjects(</b>
"Zlo_Price_Ypr02",
wdContext
.currentZlo_Price_Display_InputElement()
.modelObject()
.getEt_Ypr02());
stack trace:
java.lang.NullPointerException
at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.retrieveListClass(DynamicRFCModelClass.java:1248)
at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.setRelatedModelObjects(DynamicRFCModelClass.java:779)
at com.xxx.crm.pricemaintenance.PriceMaintCust.executeZlo_Price_Change_Input(PriceMaintCust.java:225)
at com.xxx.crm.pricemaintenance.wdp.InternalPriceMaintCust.executeZlo_Price_Change_Input(InternalPriceMaintCust.java:392)
at com.xxx.crm.pricemaintenance.ResultView.onActionUpdatePrices(ResultView.java:208)
at com.xxx.crm.pricemaintenance.wdp.InternalResultView.wdInvokeEventHandler(InternalResultView.java:233)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:100)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:299)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:635)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:249)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
Message was edited by: faB -
Multiple CSV exports from the one button or pl/sql procedure?
I need to have multiple csv exports from the one press of a button. The easiest way I found to do this is it to use javascript to popup three windows, each as a CSV link. This is a bit ugly though, and leaves the browser popup windows open when the file has been downloaded.
I guess I could also make a solution based on branching, but I think that would be difficult to maintain and reeks of bad design (im not a fan of this spagetti GOTO style code!).
I implemented Scott's custom CSV as found here: http://spendolini.blogspot.com/2006/04/custom-export-to-csv.html
However I would like to know if its possible to download more than one file using this method. I could not work out how to do this .
Has anyone got any ideas? Simply repeating the code puts the second table into the original csv file. Is there a way to 'reset' the htp writer or smoething?
Any help greatly appreciated,
AlexSorry for the confusion - I guess I mean its easy in .NET because you can simply compress files together and then send 1 zip file down as the response. See http://www.developer.com/net/net/article.php/11087_3510026_2 for details.
I guess I could ask how to do this in APEX - but it seems to me that my original wording addresses the concept at a much more abstract level. I may not find the best solution for my problem if I just asked 'how can I dynamically zip together three tables as seperate files and send them to the client?'. I also suspect that this method is not possible in APEX without custom packages. Please prove me wrong!
I guess even if I could find some kind of javascript that didnt open a new window, but was a direct download to the CSV, that would be a good compromise. At the moment when you click on the link, three windows come up and stay blank until the files are ready for downloading. Then after the files have been downloaded the windows must be shut manually. Yes, I could use javascript to make the windows 1x1 pixel perhaps, and then shut them after a predetermined timeframe - but this is hardly an elegant solution!
Thanks for your responses. -
Importing CSV files into Multiple Tables in One Database
I have a web based solution using Microsoft SharePoint and SQL Server that is created to centralize dat collection and reporting of program metrics used in montly reviews.
A person from each program enters dat manual or by pushing the data using automated data import tools. The user then is able to generate reports and provide presentations to their stakeholders.
There are are programs that are located in US and 2 that are located in Japan. All, including programs in Japan use the MS Project with a plug-in tool that allows them to auto input data. When the user click the "Send To.." button, the data goes
in to multiple tables in one database.
Everything is set up exactly the same for every program; however, we have discovered becase of a firewall, along with some of the different settings that the MS Project has over in Japan, the 2 program users are not able to auto import their data.
The suggestion is to have the program users export the MS Project file into a CSV and email it. I will then take it and convert the data, such as the dates and place them on a Network Drive. There will be 2 folders, one for each program.
I feel it will be an easy process just to load the data from the Network Drive into the same tables that are created for auto import.
My Concerns/Questions:
1. Should I create 1 SSIS package or should there be 2, one for each program?
2. US and Japan program users send their data once a month. The converted files are going to be saved in the location marked with a date (ex:201402). How can i have it to where SSIS will automatically load the data every time i place new files in the designated
folders or when i update an exsisting file?
Can you provide an example with your suggestion please?
I greatly appreciate the assistance!
Y_TylerHello Vikash,
Thank you! This will help me get started.
There will be 2 folders, one with files with Program A data and the other with files with Program B data. All will have the same fields, just coming from different programs. You stated that I will be able to to load both in one package. Would there be two
paths since there will be two separate folders?
Using the example you provided, i am confident that I can create the package using one path into one table but not sure how to get the files from 2 paths (if there is) into multiple tables.
Can you help clarify this for me?
Thank you!
Y_Tyler -
Export multiple tables into one flat file
I have data in multiple tables on a processing database that I need to move up to a production database. I want to export the data into a flat file, ftp it to the production server and have another job pick up the file and process it. I am looking for
design suggestions on how to get multiple tables into one flat file using SSIS?
Thank You.Hey,
Without a bit more detail, as per Russels response, its difficult to give an exact recommendation.
Essentially, you would first add a data flow task to your control flow. Create a source per table, then direct the output of each into an union all task. The output from the union all task would then be directed to a flat file destination.
Within the union all task you can map the various input columns into the appropriate outputs.
If the sources are different, it would probably be easiest to add a derived column task in-between the source and the union all, adding columns as appropriate and setting a default value that can be easily identified later (again depending on your requirements).
Hope that helps,
Jamie -
ABAP Internal Tables to Multiple Excel Worksheets in One Workbook
I have an ABAP List report that shows data from two dozen internal tables. Each internal table has different fields, formats, column headers, etc.
I need to allow the user to export this data into one Excel file. The file should contain multiple worksheets (each on a separate tab), but it should only be one XLS file. Each worksheet is formatted differently.
I just coded it with the OLE Automation commands. It runs too SLOW.... way way too slow. Is there another technique to use that runs faster? Examples?
Thanks in advance!I should add...
the slow part of this process is setting the value of each cell.
SET PROPERTY OF gh_cell 'Value' = p_lv_value
I am looking into function modules XXL_SIMPLE_API and XXL_FULL_API. They appear to work faster, but they only create a single worksheet.
Maybe it would be fastest to use the XXL modules to create multiple spreadsheet files and then use the OLE commands to merge them into a single workbook file? -
ACCESSING MULTIPLE TABLES THRU ONE SELECT STATEMENTS
How to access multiple tables through one single select statement and also using where condition in it for multiple fields which are from different tables. please give me any example from any tables ....thanks in advance
See the below example code :
REPORT ZMM_COST no standard page heading
line-size 255
message-id zwave .
type-pools
type-pools : slis.
Tables
tables : mara,
makt,
mbew,
konp,
pgmi,
marc,
RMCP3,
sscrfields,
mvke.
Internal Table for MARC and MARA
data : begin of i_join occurs 0,
matnr like mara-matnr, " Material #
meins like mara-meins, " Unit of Measure
werks like marc-werks, " Plant
zzdept like marc-zzdept," Department
end of i_join.
Internal table for PGMI
data : begin of i_pgmi occurs 0,
werks like pgmi-werks, " Plant,
nrmit like pgmi-nrmit, " Material #
wemit like pgmi-wemit, " Plant
end of i_pgmi.
Internal Table for MBEW
data i_mbew like mbew occurs 0 with header line.
Internal Table for Output
data : begin of i_output occurs 0 ,
matnr like mara-matnr, " Material #
maktx like makt-maktx, " Material Desc
VPRSV like mbew-VPRSV, " Price Control Indicator
VERPR like mbew-VERPR, " Moving Avg Price
meins like mara-meins, " Base Unit of Measure
STPRS like mbew-STPRS, " Standard Price
LPLPR like mbew-LPLPR, " Current Planned Price
ZPLPR like mbew-ZPLPR, " Future Planned Price
VPLPR like mbew-VPLPR, " Previous Planned Price
kbetr like konp-kbetr, " Sales Price
KMEIN like konp-KMEIN, " Sales Unit
margin(5) type p decimals 2,
vmsta like mvke-vmsta, " Material Status.
end of i_output.
Internal Table for A004
data : i_a004 like a004 occurs 0 with header line.
Variables
data : wa_lines type i,
wa_maktx type makt-maktx,
v_flag type c.
ALV Function Module Variables
DATA: g_repid like sy-repid,
gs_layout type slis_layout_alv,
g_exit_caused_by_caller,
gs_exit_caused_by_user type slis_exit_by_user.
DATA: gt_fieldcat type slis_t_fieldcat_alv,
gs_print type slis_print_alv,
gt_events type slis_t_event,
gt_list_top_of_page type slis_t_listheader,
g_status_set type slis_formname value 'PF_STATUS_SET',
g_user_command type slis_formname value 'USER_COMMAND',
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_top_of_list type slis_formname value 'TOP_OF_LIST',
g_end_of_list type slis_formname value 'END_OF_LIST',
g_variant LIKE disvariant,
g_save(1) TYPE c,
g_tabname_header TYPE slis_tabname,
g_tabname_item TYPE slis_tabname,
g_exit(1) TYPE c,
gx_variant LIKE disvariant.
data : gr_layout_bck type slis_layout_alv.
Selection-screen
selection-screen : begin of block blk with frame title text-001.
parameters : p_werks like marc-werks default '1000' obligatory.
select-options : s_dept for marc-zzdept obligatory,
s_matnr for mara-matnr,
s_mtart for mara-mtart,
s_vprsv for mbew-VPRSV,
s_PRGRP for RMCP3-PRGRP MATCHCODE OBJECT MAT2 ,
s_vmsta for mvke-vmsta.
selection-screen: end of block blk.
*SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
*PARAMETERS: p_vari LIKE disvariant-variant.
*SELECTION-SCREEN END OF BLOCK b3.
At slection screen events *
*-- Process on value request
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
Initialization *
Initialization.
g_repid = sy-repid.
sscrfields-functxt_01 = 'Clear Selection'.
selection-screen function key 1.
AT SELECTION-SCREEN.
case sscrfields-ucomm.
when 'Clear Selection' or 'FC01'.
clear: s_matnr,
p_werks.
refresh: s_matnr,
s_dept,
s_mtart,
s_vprsv,
s_PRGRP,
s_vmsta.
endcase.
Start-of-selection.
start-of-selection.
Clear the all data.
perform clear_data.
Get the data from PGMI Table
perform get_pgmi.
Get the data from MARC and MARA Table
perform get_mara_marc.
Get the data from MBEW Table
perform get_mbew.
Move the data into OUTPUT Table
perform move_output_internal.
*end-of-selection.
end-of-selection.
if not i_output[] is initial.
ALV Function Module
perform print_alv.
endif.
*& Form get_pgmi
Select the data from PGMI Table
FORM get_pgmi.
clear v_flag.
If Product group has a value at Selection-screen.
if not s_prgrp is initial.
select werks nrmit wemit from pgmi into table i_pgmi
where prgrp in s_prgrp
and werks = p_werks
and wemit = p_werks.
v_flag = 'X'.
endif.
ENDFORM. " get_pgmi
*& Form get_mara_marc
Select the data from MARA and MARC
FORM get_mara_marc.
if v_flag = 'X'.
select amatnr ameins bwerks bzzdept into table i_join
from mara as a inner join marc as b on amatnr = bmatnr
for all entries in i_pgmi
where a~matnr in s_matnr
and b~werks = p_werks
and b~zzdept in s_dept
and a~mtart in s_mtart
and a~matnr = i_pgmi-nrmit
and b~werks = i_pgmi-werks.
else.
Get the data from MARA and MARC Table
select amatnr ameins bwerks bzzdept into table i_join
from mara as a inner join marc as b on amatnr = bmatnr
where a~matnr in s_matnr
and b~werks = p_werks
and b~zzdept in s_dept
and a~mtart in s_mtart.
endif.
clear wa_lines.
describe table i_join lines wa_lines.
if wa_lines is initial.
message i000(zwave) with 'List contains no data'.
stop.
endif.
sort i_join by matnr werks zzdept.
ENDFORM. " get_mara_marc
*& Form get_mbew
Select the data from MBEW Table
FORM get_mbew.
Get the data from MBEW.
select * from mbew into table i_mbew
for all entries in i_join
where matnr = i_join-matnr.
clear wa_lines.
describe table i_mbew lines wa_lines.
if wa_lines is initial.
message i000(zwave) with 'List contains no data'.
stop.
endif.
sort i_mbew by matnr bwkey.
ENDFORM. " get_mbew
*& Form move_output_internal
Final Results
FORM move_output_internal.
loop at i_join.
clear wa_maktx.
Compare the data with MVKE Table
select single vmsta from mvke into mvke-vmsta
where matnr = i_join-matnr
and vkorg = '0001'
and vtweg = '01'
and vmsta in s_vmsta.
if sy-subrc ne 0.
continue.
else.
i_output-vmsta = mvke-vmsta.
endif.
read table i_mbew with key matnr = i_join-matnr
bwkey = i_join-werks
binary search.
if sy-subrc eq 0.
Price Control Indicator
i_output-VPRSV = i_mbew-VPRSV.
Moving Average Price
i_output-VERPR = i_mbew-VERPR / i_mbew-peinh.
Standard Price
i_output-STPRS = i_mbew-STPRS / i_mbew-peinh.
Current Planned Price
i_output-LPLPR = i_mbew-LPLPR / i_mbew-peinh.
Future Planned Price
i_output-ZPLPR = i_mbew-ZPLPR / i_mbew-peinh.
Previous Planned Price
i_output-VPLPR = i_mbew-VPLPR / i_mbew-peinh.
Base Unit of Measure - Added by Seshu 01/09/2007
i_output-meins = i_join-meins.
else.
continue.
endif.
Get the sales Price.
perform get_sales_data.
if i_mbew-VPRSV = 'V'.
Get the Percentage of Margin
if i_output-kbetr ne '0.00'.
i_output-margin = ( ( i_output-kbetr - i_mbew-VERPR )
/ i_output-kbetr ) * 100 .
endif.
else.
Get the Percentage of Margin
if i_output-kbetr ne '0.00'.
i_output-margin = ( ( i_output-kbetr - i_output-stprs )
/ i_output-kbetr ) * 100 .
endif.
endif.
Get the material Description from MAKT Table
select single maktx from makt into wa_maktx
where matnr = i_join-matnr
and spras = 'E'.
if sy-subrc eq 0.
i_output-matnr = i_join-matnr.
i_output-maktx = wa_maktx.
endif.
append i_output.
clear : i_output,
i_join,
i_mbew.
endloop.
ENDFORM. " move_output_internal
*& Form get_sales_data
Get the Sales Price for each material
FORM get_sales_data.
Get the data from A004 table to get KNUMH
Added new field Sales Unit - Seshu 01/09/2006
refresh : i_a004.
clear : i_a004.
data : lv_kbetr like konp-kbetr," Condition value
lv_KPEIN like konp-kpein , "per
lv_KMEIN like konp-KMEIN. " Sales Unit
select * from a004 into table i_a004
where matnr = i_join-matnr
and vkorg = '0001'
and vtweg = '01'.
if sy-subrc eq 0.
sort i_a004 by DATAB descending.
Get the Latetest Date
read table i_a004 with key matnr = i_join-matnr
vkorg = '0001'
vtweg = '01'
binary search.
Get the Sales Value
select single kbetr KPEIN KMEIN from konp
into (lv_kbetr,lv_KPEIN, lv_KMEIN)
where knumh = i_a004-knumh
and kappl = i_a004-kappl
and kschl = i_a004-kschl.
if sy-subrc eq 0.
i_output-kbetr = lv_kbetr / lv_KPEIN.
i_output-KMEIN = lv_KMEIN.
endif.
endif.
clear : lv_kbetr,
lv_kpein,
lv_KMEIN.
ENDFORM. " get_sales_data
*& Form print_alv
ALV Function Module
FORM print_alv.
Fill the Fiedlcat
PERFORM fieldcat_init using gt_fieldcat[].
gr_layout_bck-edit_mode = 'D'.
gr_layout_bck-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = g_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = g_user_command
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = gr_layout_bck
IT_FIELDCAT = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = g_save
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = i_output
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " print_alv
*& Form fieldcat_init
Fieldcat
FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
Material #
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-ref_fieldname = 'MATNR'.
LS_FIELDCAT-ref_tabname = 'MARA'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Material'.
ls_fieldcat-seltext_M = 'Material'.
ls_fieldcat-seltext_S = 'Material'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Material Description
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MAKTX'.
LS_FIELDCAT-OUTPUTLEN = 35.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Description'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Price Indicator
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VPRSV'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Price Control Indicator'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Moving Avg Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VERPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Moving Avg Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Base Unit of Measure
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MEINS'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Base Unit'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Standard Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'STPRS'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Standard Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Current Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'LPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Current Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Future Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'ZPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Future Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Previous Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Previous Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Sales Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KBETR'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Sales Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Sales Unit
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KMEIN'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Sales Unit'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
% of Gross Margin
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MARGIN'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = '% of Gross Margin'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Material Status
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VMSTA'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Material Status'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
ENDFORM. " fieldcat_init
**& Form f4_for_variant
text
*FORM f4_for_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_variant
i_save = g_save
i_tabname_header = g_tabname_header
i_tabname_item = g_tabname_item
it_default_fieldcat =
IMPORTING
e_exit = g_exit
es_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = gx_variant-variant.
ENDIF.
ENDIF.
*ENDFORM. " f4_for_variant
*& Form clear_data
Clear the Internal table
FORM clear_data.
clear : i_output,
i_join,
i_mbew,
i_a004,
i_pgmi.
refresh : i_output,
i_join,
i_mbew,
i_a004,
i_pgmi.
ENDFORM. " clear_data
FORM USER_COMMAND *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield. "#EC CALLED
CASE R_UCOMM.
WHEN '&IC1'.
read table i_output index rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD i_output-matnr.
SET PARAMETER ID 'WRK' FIELD p_werks.
if not i_output-matnr is initial.
call transaction 'MD04' and skip first screen.
endif.
ENDCASE.
ENDFORM.
Reward Points if it is helpful
Thanks
Seshu
Maybe you are looking for
-
IPAD usb no longer recognized by itunes
Why does the windows 7 PC not recognize USB from the iPAD in iTunes?
-
HT4859 how do i use the hard disc to store data
I find that my hard disc is huge but the Mac itself has a memory of 4 GB. I am new to Macs so this might be pretty basic... I used to just move items beween hard discs on my PC. Is there anyway to to do this on the Imac?
-
Content Server 6.40 on Windows 2003 64bit
Hello everyone, I'm trying to find any kind of information on Content Server 6.40 on a 64 bit windows machine. The latest doc I can find is about 6.30 on a windows 2000 machine. The reason why i'm looking for this doc is because i have a lot of quest
-
Unsupported image format after using external editor
A new twist (for me) on the familiar unsupported image format problem: On my MacBook Pro (running Aperture 2.1.4) I export an image to PS as a 16 bit TIFF 300 dpi to work on it; when I'm done it comes back as a TIFF. But Aperture won't open the edite
-
my daughters lost her ipod somewhere while she was out, can it be located?