Re: Table to flat text file
Yuo are writing to the file without adding any field delimiters or record seperators so your text file endup as a long line of text which is meaningless
Yuo are writing to the file without adding any field delimiters or record seperators so your text file endup as a long line of text which is meaningless
Similar Messages
-
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 -
SQL Loader-How to insert -ve & date values from flat text file into coloumn
Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide.Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide. Try something like
someDate DATE 'DDMMYYYY'
someNumber1 "TO_NUMBER ('s99999999.00')"
someNumber2 "TO_NUMBER ('99999999.00s')"Good luck,
Eric Kamradt -
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 -
Download Internal Table into a Text File in BSP?
I have an internal table which i need to download into my local pc. I know i can not use FM gui_download. Could some one please post code on how to download the internal table into a text file in BSP. Also i am not sure if i can use save dialog FM. Also need suggestion on which FM to use for save dialog which tells where to save the file.
Any help will be appreciated.
Thanks
NahmanThis might be a good starting point.
<a href="/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table">/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table</a> -
HOW CAN I SEND A TABLE TO A TEXT FILE
Hi,
I have a table with a lot of values , and i need to transfer this table to a text file (.txt) , without lose the position
of this values in that table .Someone can help me with this?
Thx
Solved!
Go to Solution.There is some conflicting and incorrect information here. First, to get the column headers of a table, you use a property node and the property 'Column Header Strings[]'. This is a string array and you can append it to the 2D string array that is the table contents.
In 6.0, the Write to Spreadsheet File was not able to write a string array. However, there are instructions on the block diagram that describe what needs to be modified. After making the modifications, save the VI with a new name and in a new location. I know for a fact that the modified VI has been posted to the forum. You can do a search but the actual modifications should take less time. -
Downloading two internal tables in same text file
I have one internal table as like below.
Data:begin of itab1 occurs 0,
rec(5),
end of itab1.
Itab1 is getting updated from input text file(Continuous text).
Here Itab1 contains one record with Indicator '01 and n number of records with indicator '02'.
This needs to be seperated in to two internal tables.
data:Begin of Itab_Head occurs 0,
Rec_ind(2) type C,
Name(3) type C,
end of itab_Head.
data:Begin of Itab_Item occurs 0,
Rec_ind(2) type C,
Id(3) type C,
Status(10,
end of itab_Item.
loop at itab1.
If itab1-Rec+0(2) = '01'.
Itab_Head-Rec_Ind = itab1-rec+0(2).
Itab_Head-Name = itab1-rec+2(3).
Append Itab_Head.
elseif itab1-rec+0(2) = '02'.
Itab_Item-Rec_Ind = itab1-rec+0(2).
Itab_Item-Id = itab1-rec+2(3).
Append Itab_Item.
endif.
endloop.
After moving to the internal tables I am doing some processing and updating the status of Itab_item.
After all these again I have to download the internal table as a text file.Now my question is.
I have values in 2 diff internal tables.How to download the two in same file.See this sample code.
data: itab1 type string occurs 0 with header line,
itab2 type string occurs 0 with header line.
itab1 = 'itab1_text'.
append itab1.
itab2 = 'itab2_text'.
append itab2.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
exporting
FILENAME = 'C:\ftext.txt'
APPEND = 'X'
changing
DATA_TAB = itab1[].
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
exporting
FILENAME = 'C:\ftext.txt'
APPEND = 'X'
changing
DATA_TAB = itab2[].
Svetlin -
Internal table to a text file in Unix
Hi ,
I was trying to download data from Internal table to a text file in Unix.
How do I do this?
One more thing is the fields on each record of the file should be delimited by the! (pipe) character.
Any one please me with the code.
Thankscheck these links...
ASCII value
ASCII value
Creating a Unix File
or do you mean application server?
then use open dataset. transfer and close dataset.
example:
DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
open dataset e_file for output in text mode.
lOOP AT it_datatab......
transfer it_datatab to e_file.
ENDLOOP.
close dataset e_file.
regds,
kiran -
Sql/Plsql code to store data into a temporary table from a text file
Dear all,
I need to create a temporary table getting data from a text file. I am very new to data loading could you please help me how to read the text file in to a temporary table.
i have text file like as below:
order* items : books Purchasing
start date:
8-11-09
Notes: Books are selling from aug10 to aug 25
Action performed*
Time*
Verified By*
sold* out from shop, sold out date:_________
+1.+
physics _______ book sold to ravi
+2.+
social _______ book this is a good book
sold to kiran
aug10th
ronald
+3.+
maths book to sal
+4.+
english book__________ this was a newbook
to raj
jak
return* to shop, return date:____________
+1.+
maths book return by:_____________ Verify book
aug11th
john
+2.+
story book by:_________ checked
aug14th
Now i need to create a temporary table with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
Now i need to create a temporary table named as books_order with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
Order status Action_Performed Time Verified_By
books Purchasing sold physics _______ book sold to ravi _______ _________
books Purchasing sold social _______ book this is a good book sold to kiran aug10th ronald
books Purchasing sold maths book to sal _____ __________
books Purchasing sold english book__________ this was a newbook to raj __________ jak
books Purchasing return maths book return by:_____________ Verify book aug11th john
books Purchasing return story book by:_________ checked aug14th _________
Thanks in advance.Hi,
Thanks for your suggestions. I Was able to get the data using utl_file.get_line. But i was not able to the data if it is in the below format:
I was able to read the data and storing if it is in the same line.But i dont know how to read below data
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
In this data i have to search for 'Book. type' and then i need to save the word 'Story' to the column 'Book_type'
Then i need to search for 'Name' and i need to save 'SL' into the column into 'Name'
Then i need to search for 'Location' and i need to save 'hyd' into the column into 'Location'
I was able to extract the data if it is in below format using utl_file.get_line
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Any one can explain me how to solve the above criteria.
Below i am explaining the same problem in detail.
I have a text file as below and i have a table having 12 columns. Now i need to insert this text file into the table story_books.
CREATE TABLE story_books
book_id NUMBER,
Category VARCHAR2(100 BYTE),
Book_type VARCHAR2(100 BYTE),
Name VARCHAR2(700 BYTE),
Location VARCHAR2(700 BYTE),
Ownership_code VARCHAR2(700 BYTE),
Author VARCHAR2(700 BYTE),
Less_Sel_fact VARCHAR2(700 BYTE),
Reason VARCHAR2(700 BYTE),
Buying VARCHAR2(700 BYTE),
Suspected Book VARCHAR2(700 BYTE),
Conditions VARCHAR2(700 BYTE)
-------------------------text file---------------
Books Out Table: Books
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Buying (if applicable):
Not Applicable
Suspected Book:
Unknown
Conditions to increace sales:
Advertisement in all areas
i was able to read the data and storing if it is in the same line.But i dont know how to read below data
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
In this data i have to search for 'Book. type' and then i need to save the word 'Story' to the column 'Book_type'
Then i need to search for 'Name' and i need to save 'SL' into the column into 'Name'
Then i need to search for 'Location' and i need to save 'hyd' into the column into 'Location'
I was able to extract the data if it is in below format using utl_file.get_line
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Any one can explain me how to solve the above criteria.
Thanks in advance. -
Sql/Plsql code to export data into a temporary table from a text file
Dear all,
I need to create a temporary table getting data from a text file. I am very new to data loading could you please help me how to read the text file in to a temporary table.
i have text file like as below:
order items : books Purchasing
start date:
8-11-09
Notes: Books are selling from aug10 to aug 25
Action performed
Time
Verified By
sold out from shop, sold out date:_________
1.
physics _______ book sold to ravi
2.
social _______ book this is a good book
sold to kiran
aug10th
ronald
3.
maths book to sal
4.
english book__________ this was a newbook
to raj
jak
return to shop, return date:____________
1.
maths book return by:_____________ Verify book
aug11th
john
2.
story book by:_________ checked
aug14th
Now i need to create a temporary table and insert the data into the table from this text file.
Now i need to create a temporary table named as books_order with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
Order status Action_Performed Time Verified_By
books Purchasing sold physics _______ book sold to ravi _______ _________
books Purchasing sold social _______ book this is a good book sold to kiran aug10th ronald
books Purchasing sold maths book to sal _____ __________
books Purchasing sold english book__________ this was a newbook to raj __________ jak
books Purchasing return maths book return by:_____________ Verify book aug11th john
books Purchasing return story book by:_________ checked aug14th _________
Thanks in advance.Isn't school work marvelous?
Create an external table.
http://www.morganslibrary.org/reference/externaltab.html
Getting the data into a temporary table may make sense in SQL Server ... but not in Oracle. -
Hash Table copy to Text file : urgent
HI
I have a hash Table which cintaine id's and name pair Now i want to copy or dump this whole table into a Text file, But i do not know how to do this .
This is very urgent for me.
Please help me .
PreetiHashTable is Serializable
use ObjectOutputStream to write to the file and use ObjectInputStream to read from the file
HashTable ht=new HashTable()
ht.put("key1","value1");
ht.put("key2","value2");
FileOutputStream ostream = new FileOutputStream
("Hash.txt");
ObjectOutputStream oos = new ObjectOutputStream(ostream);
oos.writeObject(ht);
oos.flush();
oos.close();//dont forget thisuse ObjectInputStream To read HashTable from file
use readObject() method -
Wirte the content of an internal table into a text file
Hello Experts,
how can I wirte the content of an internal table into a text file and putit on my local
desktop ?
Regards
ertasHi,
You can use the FM GUI_DOWNLOAD for this purpose.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'c:\testmmv.txt'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
SHOW_TRANSFER_STATUS = ABAP_TRUE
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = LT_STR
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
Implement suitable error handling here
ENDIF.
With regards,
Vamsi -
Creating mails with attachments from flat text files
Hello XI community-
we need to send emails containing attachments via the email adapter. The input comes from a flat ascii file.
The source file contains the message body, receiver and one or more lines that have to be converted into one or more (text) attachments.
As far as I know, the mail adapter can create attachments only from SOAP attachments.
Does anybody know a way to create SOAP attachments from the message payload?
Cheers,
LinusHello,
See these weblogs to do it :
/people/michal.krawczyk2/blog/2005/03/07/mail-adapter-xi--how-to-implement-dynamic-mail-address
/people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure
https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/1685 [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]
Regards,
Chris -
Dynamic table linking to text file
Access 2013.accdb
A large quantity of text files will be arriving to the user. They will all have the same fixed width format, but their file names will vary, and their stored location.
The data needs to be appended into Table1
I am thinking this approach: Link to a model text file Model.txt, and as part of that normal table linking I can set up the fixed width definitions for the fields. I have already done this ok. So I have this linked table 'Model1' in the navigation
pane
When a new text file comes the user will archive it in a folder: New1.txt
I can then get the path as a string: "C:blah blah \New1.txt" lets call this NewString
So what I am thinking is in order to Append in the new data; to first dynamically change the link table path to Model1 into the NewString and refresh the connect.
The AppendQuery is looking for Model1 so that table name must not change, and the fixed widths that were part of the Model1 initial linking must not change.
Does this sound viable - and what is the code for Model1 table relinking? Table Def connect properties is not something I've delved into and much of the research I've found is seriously old mdb vintage
I do not think the import spec feature of 2013 allows a dynamic change in file location / name - though if I am wrong on this point please let me know. And I think in terms of a TransferText import I would lose the fixed widths definition and
it would come in only as a single field file. So these are the reasons I am thinking of manipulating the table path connection.
Definitely would welcome advice on this one. TIAgetting a path to a file is pretty straight forward code out there for Windows Explorer file selection:
'file select
Dim strFile As String
With Application.FileDialog(1)
If .Show Then
strFile = .SelectedItems(1)
Else
MsgBox "No file selected", vbInformation
Exit Sub
End If
End With
'end file select
so strFile would be what I termed NewString in my original post; I have found code to change links to Access tables and even excel files - but haven't found what works to a text file....the code that I've experimented with does not like the .connect
refresh...... -
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.
Maybe you are looking for
-
I've upgraded to Windows 8 and having trouble running CS3 after re-installing it. Can you help?
-
How to create automatic timer process in BPM?
Can anyone tell me how to create an automatic timer process in BPM? Can I just create an manual process, and drag the timer event into the swam lane, can connect the timer to the service and then to the end event? Thank you
-
Icons are missing from my home screen. The TV show icon was missing today. I updated with the latest software - now the TV and movie icons are both missing. Can someone point this newbie in the right direction? Many thanks!
-
VA01 dump..because of include tables in enhancement in MM06E005
Hi, In enhancement MM06E005, I have created a structure under 'Include tables'. I am facing serious consequences of this such..as not able to enter VA01 and not able to save Invoice. Can anyone tell me how to get rid of this problem? thanks,
-
Problem Viewing and Opening Files from the Creative Cloud
I am using Photoshop Touch v1.7.5 on an iPad4. When I try to open an existing file from the creative cloud not all of my files and folders are displayed. My list of folders appear alphabetically and stop at those starting with the letter L. Therefore