Code to export table data into XL
Hi experts
I am creating a WD application. In which i have a table and I want data of table to transported to a XL file . can it be possible in WD java. If it is , kindly give me code sample .
Thanks in advance .
Regards
Abhay
Hi ,
tyr this blog
/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities
Regards,
Sudhir
Similar Messages
-
Exporting table data into text files
I got a request to export the data from about 85 tables into 85 text files. I assume that they will want a header row and some delimiter character. This is a process that must run every night by a sql job.
Obviously I want it to be flexible. Tables could be addede and removed and columns could be added and removed. There will probably be a control table that has the list of tables to export.
Looked at bcp - but seems that it is command line only?
SSIS package?
What other options are there?Wanted to post my solution. Ended up using bcp in a PowerShell Script. I was unable to use bcp in SQL because it requires xp_cmdshell and that is not allowed at many of our client sites. So wrote a Powershell script that executes bcp. The ps script
loops through a table that contains a row for each table/view to export along with many values and switches for the table/view export: export path, include column headers, enclose each field in double quotes, double up embedded double quotes, how to format
dates, what to return for NULL integers - basically the stuff that is not flexible in bcp. To get this flexibility I created a SQL proc that takes these values as input and creates a view. Then the PS bcp does a SELECT on the view. Many of my tables are
very wide and bcp has a limit of 4000/8000. Some of my SELECT statements ended up being GT 35k in length. So using a view got around this size limitation.
Anyway, the view creation and bcp download is really fast. It can download about 4 gb of data in 20 minutes. It can download it faster the 7z can zip it.
Below is the SQL proc to format the SELECT statement to create the view for bcp (or some other utility like SQLCMD, Invoke-SQLCMD) or SQL query by "SELECT * from v_ExportData". the proc can be used from SQL or PS, or anything that can call a SQL
Proc and then read a SQL view.
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExportTablesCreateView]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[ExportTablesCreateView]
GO
CREATE PROCEDURE [dbo].[ExportTablesCreateView]
ExportTablesCreateView
Description:
Read in a tablename or viewname with parameters and create a view v_ExportTable of the
data. The view will typically be read by bcp to download SQL table data to flat files.
bcp does not have the options to include column headers, include fields in double quotes,
format dates or use '0' for integer NULLS. Also, bcp has a limit of varhar 4000 and
wider tables could not be directly called by bcp. So create the v_ExportTable and have
bcp SELECT v_ExportTable instead of the original table or view.
Parameters:
@pTableName VARCHAR(128) - table or view to create v_ExportTable from
@pColumnHeader INT =1 - include column headers in the first row
@pDoubleQuoteFields INT = 1 - put double quotes " around all column values including column headers
@pDouble_EmbeddedDoubleQuotes INT = 1 - This is usually used with @pDoubleQuoteFields INT = 1. 'ab"c"d would be 'ab""c""d.
@pNumNULLValue VARCHAR(1) = '0' - NULL number data types will export this value instead of bcp default of ''
@pDateTimeFormat INT = 121 - DateTime data types will use this format value
Example:
EXEC ExportTablesCreateView 'custname', 1, 1, 1, '0', 121
@pTableName VARCHAR(128),
@pColumnHeader INT = 1,
@pDoubleQuoteFields INT = 1,
@pDouble_EmbeddedDoubleQuotes INT = 1,
@pNumNULLValue VARCHAR(1) = '0',
@pDateTimeFormat INT = 121
AS
BEGIN
DECLARE @columnname varchar(128)
DECLARE @columnsize int
DECLARE @data_type varchar(128)
DECLARE @HeaderRow nvarchar(max)
DECLARE @ColumnSelect nvarchar(max)
DECLARE @SQLSelect nvarchar(max)
DECLARE @SQLCommand nvarchar(max)
DECLARE @ReturnCode INT
DECLARE @Note VARCHAR(500)
DECLARE db_cursor CURSOR FOR
SELECT COLUMN_NAME, ISNULL(Character_maximum_length,0), Data_type
FROM [INFORMATION_SCHEMA].[COLUMNS]
WHERE TABLE_NAME = @pTableName AND TABLE_SCHEMA='dbo'
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @ColumnName, @ColumnSize, @Data_type
SET @HeaderRow = ''
SET @ColumnSelect = ''
-- Loop through each of the @pTableColumns to build the SELECT Statement
WHILE @@FETCH_STATUS = 0
BEGIN
BEGIN TRY
-- Put double quotes around each field - example "MARIA","SHARAPOVA"
IF @pDoubleQuoteFields = 1
BEGIN
-- Include column headers in the first row - example "FirstName","LastName"
IF @pColumnHeader = 1
SET @HeaderRow = @HeaderRow + '''"' + @ColumnName + '"'' as ''' + @columnname + ''','
-- Unsupported Export data type returns "" - example "",
IF @Data_Type in ('image', 'varbinary', 'binary', 'timestamp', 'cursor', 'hierarchyid', 'sql_variant', 'xml', 'table', 'spatial Types')
SET @ColumnSelect = @ColumnSelect + '''""'' as [' + @ColumnName + '],'
-- Format DateTime data types according to input parameter
ELSE IF @Data_Type in ('datetime', 'smalldatetime', 'datetime2', 'date', 'datetimeoffset')
-- example - CASE when [aaa] IS NULL THEN '""' ELSE QUOTENAME(CONVERT(VARCHAR,[aaa], 121), CHAR(34)) END AS [aaa],
SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''""'' ELSE QUOTENAME(CONVERT(VARCHAR,[' + @columnname + '],' + CONVERT(VARCHAR,@pDateTimeFormat) + '), CHAR(34)) END AS [' + @ColumnName + '],'
-- SET Numeric data types with NULL value according to input parameter
ELSE IF @Data_Type in ('bigint', 'numeric', 'bit', 'smallint', 'decimal', 'smallmoney', 'int', 'tinyint', 'money', 'float', 'real')
-- example - CASE when [aaa] IS NULL THEN '"0"' ELSE QUOTENAME([aaa], CHAR(34)) END AS [aaa],
SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''"' + @pNumNULLValue + '"'' ELSE QUOTENAME([' + @columnname + '], CHAR(34)) END AS [' + @ColumnName + '],'
ELSE
-- Double embedded double quotes - example "abc"d"ed" to "abc""d""ed". Only applicible for character data types.
IF @pDouble_EmbeddedDoubleQuotes = 1
BEGIN
-- example - CASE when [aaa] IS NULL THEN '""' ELSE '"' + REPLACE([aaa],'"','""') + '"' END AS [aaa],
SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @ColumnName + '] IS NULL THEN ''""'' ELSE ''"'' + REPLACE([' + @ColumnName + '],''"'',''""'') + ''"'' END AS [' + @ColumnName + '],'
END
-- DO NOT PUT Double embedded double quotes - example "abc"d"ed" unchanged to "abc"d"ed"
ELSE
BEGIN
-- example - CASE when [aaa] IS NULL THEN '""' ELSE '"' + [aaa] + '"' END AS [aaa],
SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @ColumnName + '] IS NULL THEN ''""'' ELSE ''"'' + [' + @ColumnName + '] + ''"'' END AS [' + @ColumnName + '],'
END
END
-- DO NOT PUT double quotes around each field - example MARIA,SHARAPOVA
ELSE
BEGIN
-- Include column headers in the first row - example "FirstName","LastName"
IF @pColumnHeader = 1
SET @HeaderRow = @HeaderRow + '''' + @ColumnName + ''' as ''' + @columnname + ''','
-- Unsupported Export data type returns '' - example '',
IF @Data_Type in ('image', 'varbinary', 'binary', 'timestamp', 'cursor', 'hierarchyid', 'sql_variant', 'xml', 'table', 'spatial Types')
SET @ColumnSelect = @ColumnSelect + ''''' as [' + @ColumnName + '],'
-- Format DateTime data types according to input parameter
ELSE IF @Data_Type in ('datetime', 'smalldatetime', 'datetime2','date', 'datetimeoffset')
-- example - CASE when [aaa] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[aaa], 121) END AS [aaa],
SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[' + @columnname + '],' + CONVERT(VARCHAR,@pDateTimeFormat) + ') END AS [' + @ColumnName + '],'
-- SET Numeric data types with NULL value according to input parameter
ELSE IF @Data_Type in ('bigint', 'numeric', 'bit', 'smallint', 'decimal', 'smallmoney', 'int', 'tinyint', 'money', 'float', 'real')
-- example - CASE when [aaa] IS NULL THEN '"0"' ELSE CONVERT(VARCHAR, [aaa]) END AS [aaa],
SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''' + @pNumNULLValue + ''' ELSE CONVERT(VARCHAR,[' + @columnname + ']) END AS [' + @ColumnName + '],'
ELSE
BEGIN
-- Double embedded double quotes - example "abc"d"ed" to "abc""d""ed". Only applicible for character data types.
IF @pDouble_EmbeddedDoubleQuotes = 1
-- example - CASE when [aaa] IS NULL THEN '' ELSE CONVERT(VARCHAR,REPLACE([aaa],'"','""')) END AS [aaa],
SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,REPLACE([' + @columnname + '],''"'',''""'')) END AS [' + @ColumnName + '],'
ELSE
-- example - CASE when [aaa] IS NULL THEN '' ELSE CONVERT(VARCHAR,[aaa]) END AS [aaa],
SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[' + @columnname + ']) END AS [' + @ColumnName + '],'
END
END
FETCH NEXT FROM db_cursor INTO @ColumnName, @ColumnSize, @Data_Type
END TRY
BEGIN CATCH
RETURN (1)
END CATCH
END
CLOSE db_cursor
DEALLOCATE db_cursor
BEGIN TRY
-- remove last comma
IF @pColumnHeader = 1
SET @HeaderRow = SUBSTRING(@HeaderRow , 1, LEN(@HeaderRow ) - 1)
SET @ColumnSelect = SUBSTRING(@ColumnSelect, 1, LEN(@ColumnSelect) - 1)
-- Put on the finishing touches on the SELECT
IF @pColumnHeader = 1
SET @SQLSelect = 'SELECT ' + @HeaderRow + ' UNION ALL ' +
'SELECT ' + @ColumnSelect + ' FROM [' + @pTableName + ']'
ELSE
SET @SQLSelect = 'SELECT ' + @ColumnSelect + ' FROM [' + @pTableName + ']'
---- diagnostics
---- PRINT truncates at 4k or 8k, not sure, my tables have many colummns
--PRINT @SQLSelect
--DECLARE @END varchar(max) = RIGHT(@SQLSelect, 3000)
--PRINT @end
--EXECUTE sp_executesql @SQLSelect
-- drop view if exists -- using view because some tables are very wide. one of my tables had a 33k select statement
SET @SQLCommand = '
IF EXISTS (SELECT * FROM SYS.views WHERE name = ''v_ExportTable'')
BEGIN
DROP VIEW v_ExportTable
END'
EXECUTE @ReturnCode = sp_executesql @SQLCommand
IF @returncode = 1
BEGIN
RETURN (1)
END
-- create the view
SET @SQLCommand = '
CREATE VIEW v_ExportTable AS ' + @SQLSelect
-- diagnostics
--print @sqlcommand
EXECUTE @ReturnCode = sp_executesql @SQLCommand
IF @returncode = 1
BEGIN
RETURN (1)
END
END TRY
BEGIN CATCH
RETURN (1)
END CATCH
RETURN (0)
END -- CREATE PROCEDURE [dbo].[ExportTablesCreateView]
GO -
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. -
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.
-
Export table data in a flat file without using FL
Hi,
I am looking for options where I can export table data into a flat file without using FL(File Layout) i.e., by using App Engine only.
Please share your experience if you did anything as this
ThanksA simple way to export any record (table/view) to an csv fiel, is to create a rowset and loop through all record fields, like below example code
Local Rowset &RS;
Local Record &Rec;
Local File &MYFILE;
Local string &FileName, &strRecName, &Line, &Seperator, &Value;
Local number &numRow, &numField;
&FileName = "c:\temp\test.csv";
&strRecName = "PSOPRDEFN";
&Seperator = ";";
&RS = CreateRowset(@("Record." | &strRecName));
&RS.Fill();
&MYFILE = GetFile(&FileName, "W", %FilePath_Absolute);
If &MYFILE.IsOpen Then
For &numRow = 1 To &RS.ActiveRowCount
&Rec = &RS(&numRow).GetRecord(@("RECORD." | &strRecName));
For &numField = 1 To &Rec.FieldCount
&Value = String(&Rec.GetField(&numField).Value);
If &numField = 1 Then
&Line = &Value;
Else
&Line = &Line | &Seperator | &Value;
End-If;
End-For;
&MYFILE.WriteLine(&Line);
End-For;
End-If;
&MYFILE.Close(); You can of course create an application class for generic calling this piece of code.
Hope it helps.
Note:
Do not come complaining to me on performance issues ;) -
RE: How to Export the Table data Into PDF File in ADF
Hi Experts,
I am using Jdeveloper 11.1.2.3.0
I am created employee VO and Drag and Drop as a Table in a page. So need to Export the Table data into A PDF file.
So please give me some suggestions regarding this Scnerio.
With Regards,
satishHi Guys ,
Any more answers for this question.
Please find my jsff below
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:f="http://java.sun.com/jsf/core" xmlns:report="http://www.adfwithejb.blogspot.com">
<af:panelGroupLayout layout="vertical" id="pgl2">
<af:query id="qryId1" headerText="Service Tariff Mapping Details" disclosed="true"
value="#{bindings.findByTarifValidFromQuery.queryDescriptor}"
model="#{bindings.findByTarifValidFromQuery.queryModel}"
queryListener="#{reportWiseInvoiceBean.genericQueryListener}"
queryOperationListener="#{bindings.findByTarifValidFromQuery.processQueryOperation}"
resultComponentId="pc1::t2">
<f:attribute name="queryExpression" value="bindings.findByTarifValidFromQuery.processQuery"/>
</af:query>
<af:panelCollection id="pc1" styleClass="AFStretchWidth">
<f:facet name="menus"/>
<f:facet name="toolbar">
<af:toolbar id="t1">
<af:menuBar id="pt_m1">
<report:reportDeclarative ButtonName="ExportToExcel" ReportName="ServiceTariffMappingDetails"
ReportType="PDF" TableId=":::pc1:t2" id="rd1" Pagination="true"/>
<af:commandButton text="excel" id="cb1" binding="#{exportToExcelBean.exportID}">
<af:setActionListener from="pt1:pgl1:pgl2:pc1:t2" to="#{viewScope['exporter.exportedId']}"/>
<af:setActionListener from="border:1px solid #cccccc" to="#{viewScope['exporter.thStyle']}"/>
<af:setActionListener from="border:1px solid #cccccc" to="#{viewScope['exporter.tdStyle']}"/>
<af:fileDownloadActionListener method="#{exportToExcelBean.exportToExcel}" filename="Service TariffMapping.xls"
contentType="text/excel;chatset=UTF-8;"/>
</af:commandButton>
<af:commandMenuItem id="pt_cmi133" icon="/images/common/Excel-icon.png"
shortDesc="ExportToExcel"
>
<af:exportCollectionActionListener exportedId="t2" type="excelHTML"
title="Service Tariff Mapping"
filename="Service Tariff Mapping.xls"/>
</af:commandMenuItem></af:menuBar>
</af:toolbar>
</f:facet>
<f:facet name="statusbar"/>
<af:table value="#{bindings.ServiceTariffMappingDtlsRVO1.collectionModel}" var="row"
rows="#{bindings.ServiceTariffMappingDtlsRVO1.rangeSize}"
emptyText="#{bindings.ServiceTariffMappingDtlsRVO1.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings.ServiceTariffMappingDtlsRVO1.rangeSize}" rowBandingInterval="0"
filterModel="#{bindings.findByTarifValidFromQuery.queryDescriptor}"
queryListener="#{bindings.findByTarifValidFromQuery.processQuery}" filterVisible="true" varStatus="vs"
id="t2" columnStretching="last" binding="#{ServiceTariffMappBean.testTable}">
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.label}"
id="c1">
<af:inputText value="#{row.bindings.NormalTariffCode.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.displayWidth}"
maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.precision}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.tooltip}" id="it1">
<f:validator binding="#{row.bindings.NormalTariffCode.validator}"/>
</af:inputText>
</af:column>
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.label}"
id="c2">
<af:inputText value="#{row.bindings.ServiceCode.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.displayWidth}"
maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.precision}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.tooltip}" id="it2">
<f:validator binding="#{row.bindings.ServiceCode.validator}"/>
</af:inputText>
</af:column>
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.label}" id="c3">
<f:facet name="filter">
<af:inputDate value="#{vs.filterCriteria.TrfVldFrm}" id="id1">
<af:convertDateTime pattern="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.format}"/>
</af:inputDate>
</f:facet>
<af:inputDate value="#{row.bindings.TrfVldFrm.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.displayWidth}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.tooltip}" id="id2">
<f:validator binding="#{row.bindings.TrfVldFrm.validator}"/>
<af:convertDateTime pattern="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.format}"/>
</af:inputDate>
</af:column>
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.label}"
id="c4">
<af:inputText value="#{row.bindings.ServiceDesc.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.displayWidth}"
maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.precision}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.tooltip}" id="it3">
<f:validator binding="#{row.bindings.ServiceDesc.validator}"/>
</af:inputText>
</af:column>
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.label}" id="c5">
<af:inputText value="#{row.bindings.OtTrfCode.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.displayWidth}"
maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.precision}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.tooltip}" id="it4">
<f:validator binding="#{row.bindings.OtTrfCode.validator}"/>
</af:inputText>
</af:column>
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.label}" id="c6">
<af:inputText value="#{row.bindings.OtUnitRate.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.displayWidth}"
maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.precision}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.tooltip}" id="it5">
<f:validator binding="#{row.bindings.OtUnitRate.validator}"/>
</af:inputText>
</af:column>
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.label}" id="c7">
<af:inputText value="#{row.bindings.NtUnitRate.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.displayWidth}"
maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.precision}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.tooltip}" id="it6">
<f:validator binding="#{row.bindings.NtUnitRate.validator}"/>
</af:inputText>
</af:column>
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.label}" id="c8">
<af:inputText value="#{row.bindings.TrfGrt.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.displayWidth}"
maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.precision}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.tooltip}" id="it7">
<f:validator binding="#{row.bindings.TrfGrt.validator}"/>
</af:inputText>
</af:column>
<af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.name}" filterable="true"
sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.label}"
id="c9">
<af:inputText value="#{row.bindings.ChargePartyCode.inputValue}"
label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.label}"
required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.mandatory}"
columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.displayWidth}"
maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.precision}"
shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.tooltip}" id="it8">
<f:validator binding="#{row.bindings.ChargePartyCode.validator}"/>
</af:inputText>
</af:column>
</af:table>
</af:panelCollection>
</af:panelGroupLayout>
</jsp:root> -
How to pass table data into below code for alv
hi
i want to pass table data into alvgrid
i dont know how to pass table data.
here instead of passing ABC into internal table
i want to pass table data .
please help me
ialv-test1 = 'ABC'.
form get_data.
ialv-test1 = 'ABC'.
ialv-test2 = 'DEF'.
append ialv.
ialv-test1 = 'GHI'.
ialv-test2 = 'JKL'.
append ialv.
ialv-test1 = '123'.
ialv-test2 = '456'.
append ialv.
endform
thanks in advanced.Have a look at below links. It gives you sample code of alv grid.
http://sap.niraj.tripod.com/id64.html
http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
Have a look at below links for SAP Help.
http://help.sap.com/saphelp_nw04/helpdata/en/8d/e994374c9cd355e10000009b38f8cf/content.htm
http://help.sap.com/saphelp_erp2004/helpdata/en/12/904f42d5f811d2b469006094192fe3/content.htm
Best Regards,
Vibha
*Please mark all the helpful answers -
How to download internal table data into xml file?
Hi,
Experts,
I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
Thank you,
Shabeer ahmed.check this
data : gd_repid type sy-repid.
GD_REPID = SY-REPID.
DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
data : l_element type ref to if_ixml_element,
xml_ns_prefix_sf type string,
xml_ns_uri_sf type string.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'REPAIRDATA'
DATAOBJECT = IT_FINAL_LAST1[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
*Start of code for Header
* namespace
t_mnr = sy-datum+4(2).
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
LANGU = 'E'
MONTH = t_mnr
IMPORTING
T247 = wa_t247
concatenate sy-datum+6(2)
wa_t247-ktx
sy-datum(4) into t_var1.
concatenate sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2) into t_var2.
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
l_element = m_document->get_root_element( ).
xml_ns_prefix_sf = 'TIMESTAMP'.
concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
clear : t_var1,
t_var2,
t_mnr,
wa_t247.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'FILECREATOR'.
xml_ns_uri_sf = 'SAP'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMGROUP'.
xml_ns_uri_sf = '1'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMTYPES'.
xml_ns_uri_sf = 'W'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
*End of Code for Header
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
*Start of Code for File name
concatenate p_file
'\R'
'000_119481'
sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
sy-uzeit(2) sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
*End of Code for File name
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = p_file
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Hi Gurus,
I am wondering if anyone can offer some advice in regards to export table data from a source and import it to another system.
We have a development environment (say, Banner_dev) and a production one (say, Banner_Prod). We routinely perform database refresh from Banner_Prod to Banner_dev, using Oracle Rman cloning. However, the developers are not happy with this approach saying that other things (such as packages, functions, procedures) get overwritten.
We (DBAs) have been asked to see if we can use export/import approach so that only data within a schema will be exported and imported, leaving other objects untouched in Banner_Dev when we refresh the database from Banner_Prod to Banner_Dev.
Is this doable with Oracle Data Pump? If it is, how can we accomplish this?
Thanks!You might consider a layered, scripted approach that takes into account the differences between the production and development environments. You might want to take into account things like differences between table DDL, data upgrading, coordinating code and so forth. The ideal is to be able to say "hey everybody, we're going to push this button tonight, be sure your work is saved into this system that will refresh everything."
Of course, I'm used to doing this with exp/imp because of various app and dba requirements (like, I really don't want to use the same schema name between dev and prod) and the scripts have been refined over time, but there isn't any reason you couldn't have a general post-clone procedure. Describe it in terms that developers see as beneficial to them. -
Reg: Exporting the data into excel in ADF 11g application.
Hi All,
We have developed an application in ADF 11g which retrieves the data from database in the form of table. Now we have a requirement to export that data into an excel sheet.
Can anyone please help us regarding this.
Thanks,
HarshaHi Harsha,
you can use <af:exportCollectionActionListener /> component to do that. Set the exportedId property to point to of the table. You have options to export all rows or only selected rows.
<af:commandToolbarButton text="Export All Rows to Excel" immediate="true"
id="exportAll">
<af:exportCollectionActionListener type="excelHTML" exportedId="table"
filename="export.xls"
title="ADF Faces Export - All" exportedRows="all"/>
</af:commandToolbarButton>
<af:commandToolbarButton text="Export Selected Rows to Excel" immediate="true"
id="exportSelected">
<af:exportCollectionActionListener type="excelHTML" exportedId="table"
filename="export.xls"
title="ADF Faces Export - Selected Rows"
exportedRows="selected"/>
</af:commandToolbarButton>Good Luck,
Luc Bors -
Problem in converting table data into CSV file
Hi All,
In my Process i need to convert my error table data into csv file,my data is converted as csv file by using OdisqlUnload function,but the column headers are not converted,i use another procedure for converting column headers but iam getting below error ...
com.sunopsis.sql.SnpsMissingParametersException: Missing parameter string.find, string.find
SQL: import string import java.sql as sql import java.lang as lang import re sourceConnection = odiRef.getJDBCConnection("SRC") output_write=open('C:/Oracle/Middleware/Oracle_ODI2/oracledi/pro/PRO.txt','r+') myStmt = sourceConnection.createStatement() my_query = "select * FROM E$_LOCAL_F0911Z1" my_query=my_query.upper() if string.find(my_query, '*') > 0: myRs = myStmt.executeQuery(my_query) md=myRs.getMetaData() collect=[] i=1 while (i <= md.getColumnCount()): collect.append(md.getColumnName(i)) i += 1 header=','.join(map(string.strip, collect)) elif string.find(my_query,'||') > 0: header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',') else: header = my_query[7:string.find(my_query, 'FROM')] print header old=output_write.read() output_write.seek(0) output_write.write (header+'\n'+old) sourceConnection.close() output_write.close()
And i used below code for converting.......
import string
import java.sql as sql
import java.lang as lang
import re
sourceConnection = odiRef.getJDBCConnection("SRC")
output_write=open('C:/Oracle/Middleware/Oracle_ODI2/oracledi/pro/PRO.txt','r+')
myStmt = sourceConnection.createStatement()
my_query = "select FROM E$_COMPANY"*
*my_query=my_query.upper()*
*if string.find(my_query, '*') > 0:*
*myRs = myStmt.executeQuery(my_query)*
*md=myRs.getMetaData()*
*collect=[]*
*i=1*
*while (i <= md.getColumnCount()):*
*collect.append(md.getColumnName(i))*
*i += 1*
*header=','.join(map(string.strip, collect))*
*elif string.find(my_query,'||') > 0:*
*header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',')*
*else:*
*header = my_query[7:string.find(my_query, 'FROM')]*
*print header*
*old=output_write.read()*
*output_write.seek(0)*
*output_write.write (header+'\n'+old)*
*sourceConnection.close()*
*output_write.close()*
Any one can you help regarding this
Edited by: 30021986 on Oct 1, 2012 6:04 PMThis may not be an option for you but in pinch you may want to consider outputing your data to an MS Spreadsheet, then saving it as a CSV. It's somewhat of a cumbersome process, but it will get you by for now.
You will need to change your content type to application/vnd.ms-excel.
<% response.setContentType("application/vnd.ms-excel"); %> -
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 -
FM to upload the Internal table data into application server.
Hi,
Could you please give me Function module to Upload the Internal table data into Application server ie., in Tcode AL11.
I know for downloading the Application server file into itab is "SUBST_GET_FILE_LIST" FM and using open dtaa set we get the data.
Regards,
deepthi.Hi Deepthi
Incase you are looking to upload data in the AL11 through a program , then you can make use of OPEN DATASET...CLOSE DATASET statements.
Here's the code snippet:
IF tb_alvdisplay[] IS INITIAL.
MESSAGE e999(/dcsea/zais_msg) WITH text-e01.
ELSE.
IF NOT cb_ufile IS INITIAL "Download to file
AND sy-pagno = 0. "Only down page headers for first page
PERFORM fm_concatenate_path_name USING p_path
p_file
CHANGING v_file.
*Open file for download.
PERFORM fm_open_file USING v_file .
ENDIF.
LOOP AT tb_alvdisplay.
IF NOT cb_ufile IS INITIAL.
*Passing the values of the respective headings to the structure.
ws_rec-vend_no = tb_alvdisplay-vendno.
ws_rec-vend_nm = tb_alvdisplay-vendnm.
ws_rec-title = tb_alvdisplay-vendtl.
ws_rec-add = tb_alvdisplay-add.
ws_rec-city1 = tb_alvdisplay-city1.
ws_rec-region = tb_alvdisplay-region.
ws_rec-country = tb_alvdisplay-country.
ws_rec-pobox = tb_alvdisplay-po.
ws_rec-phone = tb_alvdisplay-telf1.
ws_rec-extn = tb_alvdisplay-extn.
ws_rec-fax = tb_alvdisplay-telfx.
ws_rec-zterm = tb_alvdisplay-zterm.
ws_rec-remark = tb_alvdisplay-remark.
ws_rec-email = tb_alvdisplay-email.
*Passing the separator 'PIPE' to the structure.
ws_rec-sep01 = co_sep.
ws_rec-sep02 = co_sep.
ws_rec-sep03 = co_sep.
ws_rec-sep04 = co_sep.
ws_rec-sep05 = co_sep.
ws_rec-sep06 = co_sep.
ws_rec-sep07 = co_sep.
ws_rec-sep08 = co_sep.
ws_rec-sep09 = co_sep.
ws_rec-sep10 = co_sep.
ws_rec-sep11 = co_sep.
ws_rec-sep12 = co_sep.
ws_rec-sep13 = co_sep.
TRANSFER ws_rec TO v_file.
ENDIF.
AT LAST.
IF NOT cb_ufile IS INITIAL.
*Closing the DATASET file.
CLOSE DATASET v_file.
IF sy-subrc <> 0.
*Failure Message.
MESSAGE e999(/dcsea/zais_msg) WITH text-t04 text-t06.
ELSE.
*Success message.
MESSAGE s999(/dcsea/zais_msg) WITH text-t05.
ENDIF.
ENDIF.
ENDAT.
ENDLOOP.
ENDIF.
Also as Gautham suggested you can use tcode CG3Z or CG3Y incase you are looking to upload the data directly.
FInally, you can search SCN using the keywords, "Upload to AL11" and you'll get loads of results.
Hope this helps.
Harsh -
Can I use Bridge to export image data into a .txt file?
I have a folder of images and I would like to export the File Name, Resolution, Dimensions and Color Mode for each file into one text file. Can I use Bridge to export image data into a .txt file?
Hello
You may try the following AppleScript script. It will ask you to choose a root folder where to start searching for *.map files and then create a CSV file named "out.csv" on desktop which you may import to Excel.
set f to (choose folder with prompt "Choose the root folder to start searching")'s POSIX path
if f ends with "/" then set f to f's text 1 thru -2
do shell script "/usr/bin/perl -CSDA -w <<'EOF' - " & f's quoted form & " > ~/Desktop/out.csv
use strict;
use open IN => ':crlf';
chdir $ARGV[0] or die qq($!);
local $/ = qq(\\0);
my @ff = map {chomp; $_} qx(find . -type f -iname '*.map' -print0);
local $/ = qq(\\n);
# CSV spec
# - record separator is CRLF
# - field separator is comma
# - every field is quoted
# - text encoding is UTF-8
local $\\ = qq(\\015\\012); # CRLF
local $, = qq(,); # COMMA
# print column header row
my @dd = ('column 1', 'column 2', 'column 3', 'column 4', 'column 5', 'column 6');
print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
# print data row per each file
while (@ff) {
my $f = shift @ff; # file path
if ( ! open(IN, '<', $f) ) {
warn qq(Failed to open $f: $!);
next;
$f =~ s%^.*/%%og; # file name
@dd = ('', $f, '', '', '', '');
while (<IN>) {
chomp;
$dd[0] = \"$2/$1/$3\" if m%Link Time\\s+=\\s+([0-9]{2})/([0-9]{2})/([0-9]{4})%o;
($dd[2] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of CODE\\s/o;
($dd[3] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of DATA\\s/o;
($dd[4] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of XDATA\\s/o;
($dd[5] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of FARCODE\\s/o;
last unless grep { /^$/ } @dd;
close IN;
print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
EOF
Hope this may help,
H -
Exporting Table data to delimited txt file
I am trying to import the table data into delimited text file, I am running the following code from Tom Kyte's website on the server. When I run the procedure after I run the function it is not creating any .dat file for me.
I have also checked for the parameter 'utl_file_dir' in the database and it is set to the correct path. Is there anything that I am missing??
any suggestions/inputs would help.
create or replace function dump_csv( p_query in varchar2,
p_separator in varchar2
default ',',
p_dir in varchar2 ,
p_filename in varchar2 )
return number
AUTHID CURRENT_USER
is
l_output utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(2000);
l_status integer;
l_colCnt number default 0;
l_separator varchar2(10) default '';
l_cnt number default 0;
begin
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
for i in 1 .. 255 loop
begin
dbms_sql.define_column( l_theCursor, i,
l_columnValue, 2000 );
l_colCnt := i;
exception
when others then
if ( sqlcode = -1007 ) then exit;
else
raise;
end if;
end;
end loop;
dbms_sql.define_column( l_theCursor, 1, l_columnValue,
2000 );
l_status := dbms_sql.execute(l_theCursor);
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
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 := p_separator;
end loop;
utl_file.new_line( l_output );
l_cnt := l_cnt+1;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
return l_cnt;
end dump_csv;
create or replace procedure test_dump_csv
as
l_rows number;
begin
l_rows := dump_csv( 'select *
from doctype
where rownum < 25',
',', '/tmp', 'test.dat' );
end;
/Hi,
It works for me...
SQL> select dump_csv('select * from dba_users',',','/tmp','teste.txt') from dual;
DUMP_CSV('SELECT*FROMDBA_USERS',',','/TMP','TESTE.TXT')
149
SQL> show parameter utl_file_dir
NAME TYPE VALUE
utl_file_dir string /tmp
oracle@icaro:/tmp> ls -l teste.txt
-rw-r--r-- 1 rps users 394353 2006-07-31 17:40 teste.txtJust for information:
I'm using SUSE LINUX 10 and Oracle 10g 10.1.0.2
Cheers
Message was edited by:
Legatti
Maybe you are looking for
-
How do I get my new Mustek scanner to work over Airport Extreme?
We can't get our new scanner to even show up over our wireless network. When I hook it straight to my iMac (2.8 GHz Intel Core Duo, OS X 10.6.8 [Snow Leopard]), I can use the enclosed software (ImageAcquire), but it does NOT show up either in ImageCa
-
Regarding the Authorization in ABAP-HR
Hi all, I want to know about the Authorizations in the ABAP-HR. If any body is having any material regarding the can you plz share with me... thanks in advance, Suresh
-
Start Screen Listed as Unused in Library
Just recorded the following for the Adobe Captivate Bug Reporting system: ******BUG****** Concise problem statement: Steps to reproduce bug: 1.Set a PNG as start screen instead of Autoplay 2.Save project 3.Check Library for Unused Assets 4. Remove un
-
Mail Finder doesn't find new files
When I save a new file to a folder and then to add it as an attachment to a message in Mail, the finder window in Mail doesn't show the new file. I have to exit and restart Mail for the finder window to find the new file. What's going on?
-
Can't get past the welcome screen
I just purchased this and have been trying to set it up. I have been on the welcome screen for 2 hours now. I can't get past the screen where you check the country. That's it. It's selected but nothing works and the VO hasn't indicated anything ot