How to export bulk data in text file
Dear,
We have an requirement to get data from GL CONTAINING below tables, but it's taking lot of time, could you share the best way to get data in text file as quick as possiable.
from gl_je_headers_v,gl_je_lines,GL_JE_CATEGORIES
,gl_code_combinations_v
where gl_je_headers_v.je_header_id = gl_je_lines.je_header_id
AND GL_JE_CATEGORIES.je_category_name = gl_je_headers_v.je_category
and gl_code_combinations_v.CODE_COMBINATION_ID =
gl_je_lines.code_combination_id
and gl_code_combinations_v.CHART_OF_ACCOUNTS_ID = 50349
AND gl_je_headers_v.PERIOD_NAME = 'SEP-2012'
it's based on formatting data in text file
you can use utl_file but it's row by row process your data
you can try spool
as example
spool c:\tmp\myfile.txt
select *
from emp;
spool off;or try export for example in sql developer
Similar Messages
-
How to export waveform data into text file
Hi..
I am trying to export my waveform graph data into write spreadsheet file. When running the proram, I am getting graph values (values in a matrix) when checking with the probe. But once I save it to a text file, the values recorded are just zeros. I have attached the text file along with this. Could anyone please tell me why the graph data is not recorded in the spreadsheet? I have extracted the Y component of the graph and then wired it to the write to spreadsheet function. It seems like the labview is getting the data.. but now the problem is how to get the data out of labview?Please find the attched image of the whole program. I tried running the program after removing the array to matrix but still I am not able to export the graph values to spreadsheet. The program as a whole is working as I am able to display the oscilloscope graph into the waveform graph but I am not able to export the values. When I tried using probes, I am getting differnet matrix values till the end of the connection given to 'write to spreadsheet' but not able to export the values. The second image shows the write to spreadsheet file inside the while loop as i thought it will reduce the memory.. but it is still not working...
Attachments:
Scanner complete program.jpg 713 KB
full scanner program 2.jpg 664 KB -
How to export structure DB to text file
I want to export structure DB to text file for report to my manager.
example: any objects(tables, indexs, constraints) and He need DDL command ("create table" command etc.)
How to do this?Varies by database version.
I would investigate DBMS_METADATA as described in the PL/SQL Packages and Types Reference manual and demoed in the Utilities guide at http://www.oracle.com/pls/db102/portal.portal_db?selected=3 -
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 -
How To Export BW Data to XML File
Hello All-
I am currently trying to find out how to <b>export </b>data in BW to an XML File. I have read previous posts but would like to know if one option is using Open Hub Services (through an Infospoke) toprovide me with the data I need while outputting a file in XML. We are currently on BW 3.5. Thank you.
ClaudiaHi Claudia,
Yes, you can export the data available in BW to XML files using Open Hub Service.
See the links below:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5f12a03d-0401-0010-d9a7-a55552cbe9da
http://help.sap.com/saphelp_nw04/helpdata/en/33/f3843b0af3de0ee10000000a114084/content.htm
Cheers!
Amit -
Export table data in text file
hi,
i am using oracle 8.0.7 , i want to export a table data in to text file, thanks in advance
Noman ul haq2 options:
1) Spool the query results into a file using SQL*PLUS
2) If you can use the Oracle Server, look at the UTL_FILE package. This writes files, but ONLY to the Oracle server. It will NOT write out to your client machine. Your DBA will need to add an entry to allow for the UTL_FILE package to write out to the directory you choose.
Hope that helps - the documentation should have detailed usage of UTL_FILE package. Or search on this site b/c this is a common question - see it at least 3 times a week. -
Exporting historical data to text file with MAX misses columns of data?
I am using Labview 7.1 with DSC module 7.1 and wants to export data to either excel format or .txt.
I have tried this with the historical data export in MAX, and also programmatically with the "write traces to spreadsheet file.vi" available in the DSC module. All my tags in my tag engine file (*.scf) are defined to log data and events. Both the update tag engine deadband and the update database are set to 0 %.
My exported excel or text file seems reasonalbe except that some columns of data are missing. I dont understand
why data from these tags are not in the exported files since they have the same setup in the (.scf) as other tags which are okay exported?
All defined tags can be seen using the NI hypertrend or MAX. Also the ones that are not correctly exported to file.
Appreciate comments on this.
Best regards,
Ingvald BardsenI am using LV and DSC 7.1 with PCI-6251 and max 4.2. In fact, just one column of values does not make sense. In attachment, follows the excel exported file. The last of column called ...V-002 that is the problem. I put probes for checking values but them shows correct. When the file is exported that to show values wrong.
The problem of missing values in column i solved putting 0% in field of deadband.
thank you for your help
Attachments:
qui, 2 de ago de 2007 - 132736.xls 21 KB -
How to export subtitles as a text file into DVDSP
Hi, I am trying to export subtitles from fcp 4.5 to dvdsp 3 as a .txt file. (Dvdsp can use .txt files in its subtitle track.)
I had already created all the subtitles in fcp, and I hope that there is a way where I do not have to create them again from scratch in dvdsp.
Thank you!Hi Hanumang,
So, I did the txt file piece by pice. It did not go into dvdsp perfectly; I had to shift some of the titles around a bit.
Now I have another problem which I jusdt posted.
Perhaps you can help me again?
New issue:
I now imported an improved (re-edited with a few brightness corrections) compressed file into DVDSP, deleted the previous file, dragged the new file into tracks in Dvdsp. (Let's call this project "new").
Now the subtitles from S1 have disappeared! (I had spend tons of time creating subtitles)
I did a new save, so, yesterdays DVDSP project (let's call this project "old") is still OK, with the perfect subtitles, but not-all-perfect video track (where I improved the brightness filter).
Can I re-import the subtitles from the "old" project into the "new" one? If yes, how?
Or, can I export the subtitles from "old" into a txt. file and then import it into project "new?"
Please help!
Thank you for your time!
Gabriele (without an intern -
Data getting truncated while exporting report to a text file in crystal 10?
Hi All,
I am using crystal 10.When exporting report to a text file ,a dialog prompts asking for Character perinch with a default value 9.If I change the value from 9 to 16 i am getting the correct data(that means character per inch value is 16) and it update "CharPerInch" value in registry under following location to 16.
HKEY_CURRENT_USER\Software\Crystal Decisions\10.0\Crystal Reports\Export\Text
The dialog asked for character per inch also has option to select not to prompt again and i also selected that in first go.
When i export the report again in text format it didn't prompt for number of character per inch but the data gets truncated.
What i believe is even though it updates entry in registry and reads, it is not using the same value for export. It never consider the value that is in registry, if the check box is not selected then it is using the value entered in the dialog and if the check box is selected then in the next run it uses the default value as 9.
Can anyone suggest me how to override this problem ? Is there any other setting place in registry where i can enter the number of character per inch.I don't want to crystal to prompt always for character per inch.Hi Venkateswaran,
The other option to avoid truncation of the data could be
Right click the text filed
Click on Format Text to open the Format Editor
On Common tab check the text box for Can Grow.
This will prevent the data from truncating in preview as well as while exporting to text.
Otherwise you will have to set the characters per inch to 16 each time. I donu2019t see changing the registry value causing any difference here.
Regards,
Aditya Joshi -
How to export a data as an XML file from oracle data base?
could u pls tell me the step by step procedure for following questions...? how to export a data as an XML file from oracle data base? is it possible? plz tell me itz urgent requirement...
Thankz in advance
BalaSQL> SELECT * FROM v$version;
BANNER
Oracle DATABASE 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS FOR 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
5 rows selected.
SQL> CREATE OR REPLACE directory utldata AS 'C:\temp';
Directory created.
SQL> declare
2 doc DBMS_XMLDOM.DOMDocument;
3 xdata XMLTYPE;
4
5 CURSOR xmlcur IS
6 SELECT xmlelement("Employee",XMLAttributes('http://www.w3.org/2001/XMLSchema' AS "xmlns:xsi",
7 'http://www.oracle.com/Employee.xsd' AS "xsi:nonamespaceSchemaLocation")
8 ,xmlelement("EmployeeNumber",e.empno)
9 ,xmlelement("EmployeeName",e.ename)
10 ,xmlelement("Department",xmlelement("DepartmentName",d.dname)
11 ,xmlelement("Location",d.loc)
12 )
13 )
14 FROM emp e
15 , dept d
16 WHERE e.DEPTNO=d.DEPTNO;
17
18 begin
19 OPEN xmlcur;
20 FETCH xmlcur INTO xdata;
21 CLOSE xmlcur;
22 doc := DBMS_XMLDOM.NewDOMDocument(xdata);
23 DBMS_XMLDOM.WRITETOFILE(doc, 'UTLDATA/marco.xml');
24 end;
25 /
PL/SQL procedure successfully completed.
. -
How to export the data to a excel file from RSA3?
Hi experts,
1.I am trying to save the RSA (SRM extractor) to excel spread sheet to compare SRM data with BI data. When i run the the transaction RSA3 it just showed me 10 different data packets. How to export the data to excel spread sheet for reconciliation?
2. Does any body know if the stepup tables exist for SRM extractors?
Thank in advance
Sharat.Hello Sharat,
You have two options of saving data to excel sheet:
Step 1:
Goto RSA3, change the "Data Records / Calls" to 1000 and then execute. This way instead of 10 different packets you will get one packet.
Step2:
Click on the list button, open the packet by double clicking it. You will see all the data on your screen.
Step3:
Goto System -> List -> Save - > Local File -> Spreadsheet and give some name for your xls file.
Assign points if helpful.
Regards,
F-S -
How to extract data from text file to database table
Hi ,
I am trying to upload data in text file to database table using GUI_UPLOAD function .what would be the program for that.
thanks in advance.Hi,
I don't think you have a standard sap program to upload data from file to database table...
Instead you can create a custom program like this..
DATA: T_FILEDATA(1000) OCCURS 0 WITH HEADER LINE.
DATA: T_ZTABLE LIKE ZTABLE OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEST.TXT'
tables
data_tab = T_FILEDATA
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT T_FILEDATA.
T_ZTABLE = T_FILEDATA.
APPEND T_ZTABLE.
ENDLOOP.
MODIFY ZTABLE FROM TABLE T_ZTABLE.
COMMIT WORK..
Thanks,
Naren -
How to write data to text file using external tables
can anybody tell how to write data to text file using external tables concept?
Hi,
Using external table u can load the data in your local table in database,
then using your local db table and UTL_FILE pacakge u can wrrite data to text file
external table
~~~~~~~~~~~
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2153251
UTL_FILE
~~~~~~~~~
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#sthref14093
Message was edited by:
Nicloei W
Message was edited by:
Nicloei W -
Export Screen to Flat Text file
Hello,
I'm very new in SAP and need to modify a little program.
I would like to export the current screen in a flat text file.
The file must be stored on the SAP server ( /usr/sap/data/bel) so not on my local harddrive.
I searched and found found functions like WS_download and GUI_download, but I'm not sure how to use them. Can somebody help me please?
Curent Code of my report:
REPORT ZAT_CLRDEP01.
Tables declaration
tables : vbrp,bkpf,bseg.
Data declaration
data: begin of itab1 occurs 0,
vbeln like vbrp-vbeln,
arktx like vbrp-arktx,
belnr like bkpf-belnr,
end of itab1.
data: begin of itab2 occurs 0,
vbeln like vbrp-vbeln,
arktx like vbrp-arktx,
belnr like bkpf-belnr,
end of itab2.
data: begin of itab3 occurs 0,
kunnr like bseg-kunnr,
name1 like kna1-name1,
vbeln like vbrp-vbeln,
zfbdt like bseg-zfbdt,
belnr like bkpf-belnr,
augcp like bseg-augcp,
augbl like bseg-augbl,
arktx like vbrp-arktx,
end of itab3.
data: begin of itab4 occurs 0,
kunnr like bseg-kunnr,
name1 like kna1-name1,
vbeln like vbrp-vbeln,
zfbdt like bseg-zfbdt,
augcp like bseg-augcp,
augbl like bseg-augbl,
arktx like vbrp-arktx,
pswbt like bseg-pswbt,
end of itab4.
data: vbeln_tst like vbrp-vbeln.
Selections
parameters accgrp like vbrp-ktgrm default '03' obligatory.
parameters compcde like bkpf-bukrs default 'LOI' obligatory.
select-options: billdoc for vbrp-vbeln.
select-options: customer for bseg-kunnr.
select-options: fiscyear for bkpf-gjahr.
select-options: reldate for bseg-augcp.
select-options amount for bseg-pswbt.
INITIALIZATION.
fiscyear-low = sy-datum(4).
fiscyear-high = sy-datum(4).
append fiscyear.
reldate-high = sy-datum.
append reldate.
amount-low = '100'.
amount-high = '2000'.
append amount.
START-OF-SELECTION.
refresh: itab1,itab2,itab3,itab4.
clear : itab1,itab2,itab3,itab4.
clear: vbeln_tst.
select * into corresponding fields of table itab1
from vbrp inner join bkpf
on vbrpmandt = bkpfmandt
and vbrpvbeln = bkpfxblnr
where vbrp~ktgrm = accgrp
and bkpf~bukrs = compcde
and bkpf~gjahr = fiscyear.
loop at itab1.
if itab1-vbeln ne vbeln_tst.
move itab1-belnr to itab2-belnr.
move itab1-vbeln to itab2-vbeln.
move itab1-arktx to itab2-arktx.
append itab2.
endif.
vbeln_tst = itab1-vbeln.
endloop.
loop at itab2.
select * from bseg
where bukrs = compcde
and belnr = itab2-belnr
and gjahr = fiscyear
and buzei = '001'
and augcp in reldate
and augbl ne ''
and vbeln in billdoc
and kunnr in customer.
if sy-subrc = 0.
move itab2-belnr to itab3-belnr.
move bseg-kunnr to itab3-kunnr.
select single name1 from kna1
into itab3-name1
where kunnr = itab3-kunnr.
move itab2-vbeln to itab3-vbeln.
move bseg-zfbdt to itab3-zfbdt.
move bseg-augcp to itab3-augcp.
move bseg-augbl to itab3-augbl.
move itab2-arktx to itab3-arktx.
append itab3.
endif.
endselect.
endloop.
loop at itab3.
select * from bseg
where bukrs = compcde
and belnr = itab3-belnr
and gjahr = fiscyear
and hkont = '0000488600'
and pswbt in amount.
if sy-subrc = 0.
move itab3-kunnr to itab4-kunnr.
move itab3-name1 to itab4-name1.
move itab3-vbeln to itab4-vbeln.
move itab3-zfbdt to itab4-zfbdt.
move itab3-augcp to itab4-augcp.
move itab3-augbl to itab4-augbl.
move itab3-arktx to itab4-arktx.
move bseg-pswbt to itab4-pswbt.
append itab4.
endif.
endselect.
endloop.
END-OF-SELECTION.
sort itab4 by kunnr.
loop at itab4.
at first.
write:/ ' customer ','billing doc.',
'Billing date',' Release date','Release doc.',
' material ','G/L amount'.
endat.
write:/ itab4-name1.
write at 36 itab4-vbeln.
write at 47 itab4-zfbdt.
write at 61 itab4-augcp.
write at 74 itab4-augbl.
write at 88 itab4-arktx.
write at 127 itab4-pswbt.
endloop.
Thanks in advance!
Kindly regards,
NicoHello,
Thanks for your help and fast reaction, I added the 'open dataset' but probably made some minor error:
I'm getting field "result" (name of my text file) is unknown. It is neither in one of the specified tables or defined by a 'DATA' statement
Currently have following code:
Objet du programme : *
Recherche de documents de facturation SD sur base de *
l' "account assignment group" de l'article *
Stocker ces valeurs dans une table interne afin *
de retrouver les pièces comptables correspondantes. *
Afficher le N° du document de facturation, celui de la *
pièce comptable, la date de release du release document. *
REPORT ZAT_CLRDEP01.
Tables declaration
tables : vbrp,bkpf,bseg.
Data declaration
data: begin of itab1 occurs 0,
vbeln like vbrp-vbeln,
arktx like vbrp-arktx,
belnr like bkpf-belnr,
end of itab1.
data: begin of itab2 occurs 0,
vbeln like vbrp-vbeln,
arktx like vbrp-arktx,
belnr like bkpf-belnr,
end of itab2.
data: begin of itab3 occurs 0,
kunnr like bseg-kunnr,
name1 like kna1-name1,
vbeln like vbrp-vbeln,
zfbdt like bseg-zfbdt,
belnr like bkpf-belnr,
augcp like bseg-augcp,
augbl like bseg-augbl,
arktx like vbrp-arktx,
end of itab3.
data: begin of itab4 occurs 0,
kunnr like bseg-kunnr,
name1 like kna1-name1,
vbeln like vbrp-vbeln,
zfbdt like bseg-zfbdt,
augcp like bseg-augcp,
augbl like bseg-augbl,
arktx like vbrp-arktx,
pswbt like bseg-pswbt,
end of itab4.
data: vbeln_tst like vbrp-vbeln.
Selections
parameters accgrp like vbrp-ktgrm default '03' obligatory.
parameters compcde like bkpf-bukrs default 'LOI' obligatory.
select-options: billdoc for vbrp-vbeln.
select-options: customer for bseg-kunnr.
select-options: fiscyear for bkpf-gjahr.
select-options: reldate for bseg-augcp.
select-options amount for bseg-pswbt.
INITIALIZATION.
fiscyear-low = sy-datum(4).
fiscyear-high = sy-datum(4).
append fiscyear.
reldate-high = sy-datum.
append reldate.
amount-low = '100'.
amount-high = '2000'.
append amount.
START-OF-SELECTION.
refresh: itab1,itab2,itab3,itab4.
clear : itab1,itab2,itab3,itab4.
clear: vbeln_tst.
select * into corresponding fields of table itab1
from vbrp inner join bkpf
on vbrp~mandt = bkpf~mandt
and vbrp~vbeln = bkpf~xblnr
where vbrp~ktgrm = accgrp
and bkpf~bukrs = compcde
and bkpf~gjahr = fiscyear.
loop at itab1.
if itab1-vbeln ne vbeln_tst.
move itab1-belnr to itab2-belnr.
move itab1-vbeln to itab2-vbeln.
move itab1-arktx to itab2-arktx.
append itab2.
endif.
vbeln_tst = itab1-vbeln.
endloop.
loop at itab2.
select * from bseg
where bukrs = compcde
and belnr = itab2-belnr
and gjahr = fiscyear
and buzei = '001'
and augcp in reldate
and augbl ne ''
and vbeln in billdoc
and kunnr in customer.
if sy-subrc = 0.
move itab2-belnr to itab3-belnr.
move bseg-kunnr to itab3-kunnr.
select single name1 from kna1
into itab3-name1
where kunnr = itab3-kunnr.
move itab2-vbeln to itab3-vbeln.
move bseg-zfbdt to itab3-zfbdt.
move bseg-augcp to itab3-augcp.
move bseg-augbl to itab3-augbl.
move itab2-arktx to itab3-arktx.
append itab3.
endif.
endselect.
endloop.
loop at itab3.
select * from bseg
where bukrs = compcde
and belnr = itab3-belnr
and gjahr = fiscyear
and hkont = '0000488600'
and pswbt in amount.
if sy-subrc = 0.
move itab3-kunnr to itab4-kunnr.
move itab3-name1 to itab4-name1.
move itab3-vbeln to itab4-vbeln.
move itab3-zfbdt to itab4-zfbdt.
move itab3-augcp to itab4-augcp.
move itab3-augbl to itab4-augbl.
move itab3-arktx to itab4-arktx.
move bseg-pswbt to itab4-pswbt.
append itab4.
endif.
endselect.
endloop.
END-OF-SELECTION.
sort itab4 by kunnr.
EXPORT OUTPUT TO FLAT TEXT FILE : *
open dataset result for output in text mode.
if sy-subrc = 0.
loop at itab4.
at first.
write:/ ' customer ','billing doc.',
'Billing date',' Release date','Release doc.',
' material ','G/L amount'.
endat.
write:/ itab4-name1.
write at 36 itab4-vbeln.
write at 47 itab4-zfbdt.
write at 61 itab4-augcp.
write at 74 itab4-augbl.
write at 88 itab4-arktx.
write at 127 itab4-pswbt.
transfer itab4 to result.
endloop.
close dataset result.
endif.
Thank you!
Regards,
Nico -
Spool SQl data into text file using dynamic sql
Hi,
I am spooling output data into text file using command
select 'select t.mxname,bo.lxtype,t.mxrev'||chr(10)||'from mx_1234567'||chr(10)||
'where <condition>';
here mxname varchar(128),lxtype(128),mxrev(128) all are of varchar type.I want the output in format
e.g Part|1211121313|A
but due to column width the output,I am getting is with spaces.
"Part then blank spaces |1211121313 then blank spaces |A"
how can I remove these spaces between columns.I used set space 0 but not working.
Thanks in advance.
Your help will be appreciated.Hi Frank,
I have seen your reply for SET LINE SIZE function. But, I could not be able to understand it.
I am facing similar kind of issue in my present project.
I am trying spool more than 50 columns from a table into flat file. Because of more column lengths in few columns, i am getting space. There are so many columns with the same issue. I want to remove that space.so that, data can fit perfectly in one line in .txt file without any wrap text.
Below is my sample query.sql. Please let me know the syntax. My mail id : [email protected]
--Created : Sep 22,2008, Created By : Srinivasa Bojja
--Export all Fulfillments
--Scheduled daily after 1:00am and should complete before 3:30am
WHENEVER SQLERROR EXIT SQL.SQLCODE
SET LINESIZE 800
SET WRAP OFF
SET PAGESIZE 800
SET FEEDBACK OFF
SET HEADING ON
SET ECHO OFF
SET CONCAT OFF
SET COLSEP '|'
SET UNDERLINE OFF
SPOOL C:\Fulfillment.txt;
SELECT SRV.COMM_METHOD_CD AS Method,
SRV.SR_NUM AS "Fulfillment Row_Id",
CON.LAST_NAME AS "Filled By"
SRV.SR_TITLE AS Notes,
SRVXM.ATTRIB_04 AS "Form Description"
FROM SIEBEL.S_SRV_REQ SRV,
SIEBEL.S_SRV_REQ_XM SRVXM,
SIEBEL.S_USER USR,
SIEBEL.S_CONTACT CON
WHERE SRV.ROW_ID = SRVXM.PAR_ROW_ID AND
SRV.OWNER_EMP_ID = USR.ROW_ID AND
CON.ROW_ID= SRV.CST_CON_ID;
SPOOL OFF;
EXIT;
Maybe you are looking for
-
Error while deploying bpel process from jdevelober
hi everybody , i am beginner and maybe i have some weakness in application server everything ,but i'm trying to handle this ;) i have installed a new SOA_suite server ,every thing is grate "actually my manager did ;) " ,i've moved from jazen to oid,t
-
Hello, I'm a new IT admin at a small company (10-12 PCs running Windows 7 or 8) which has 4 printers. I'd like to install the printers either connected to the server or as wireless printers (1 is old enough to require a USB connection to a PC, no ne
-
How to save info in a meta-data of a jpg file?
hi, i need to know how to save info in a meta-data of a jpg file: this is my code (doesn't work): i get an exception, javax.imageio.metadata.IIOInvalidTreeException: JPEGvariety and markerSequence nodes must be present at com.sun.imageio.plugins.jpeg
-
How can I manage my CMYK levels in Indesign?
I am working with an off set printer who has stated that my black levels (in CMYK) are too high (coloured illustrations). They stated that my black is at 350 and needs to be less than 200. -- and total CMYK ink charge can not be any more than 340. I
-
Preblems of .jar in JBuilder9 Enterprise
Is there someone that knows well Borland JBuilder 9 Enterpise?? I made a java application that needs, for working well, some file (.jpg .gif .ico )located in the same directory of the project, and an external library(a JNI),in the directory "lib" ins