05-14-2006 2:00 PM
i want to download ztable as a flatfile(txt) but i want between the fields to have comma ','
05-14-2006 3:42 PM
Retrieve your data from the data table into an internal table, then loop at the internal table and concatenate all of the fields of the row into a flat string row of another internal table, use the SEPARATED BY ',' extenstion of the CONCATENATE statement. Then use GUI_DOWNLOAD to download the flat string internal table.
Regards,
Rich Heilman
05-14-2006 4:21 PM
Hi,
Use SEPARATED BY ',' extenstion of the <b>CONCATENATE</b> statement and then Use GUI_DOWNLOAD FM
DATA: V_FILE TYPE STRING.
CALL FUNCTION '<b>GUI_DOWNLOAD</b>'
EXPORTING
BIN_FILESIZE =
FILENAME = V_FILE
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'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = it_datei
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
Regards,
Santosh
05-14-2006 7:56 PM
this is a good solution
but if i have field as matnr(18) and i have only 10
its give me the 10 posotion and i want all
how i can solve it
05-14-2006 5:14 PM
Hello Yeheil,
Use this code.
***************************************
report abc.
data: ztable like table of xyz.
data: begin of it_final occurs 0,
rec(1000) type c,
end of it_final.
loop at ztable.
concatenate ztable-field1
ztable-field2
ztable-field3
into it_final
separated by ','.
condense it_final-rec no-gaps.
append it_final.
endloop.
call function 'GUI_DOWNLOAD'
exporting filename = 'C:/test.txt'
tables data_tab = it_final
exceptions others = 22.
**********************************************88
Hope it was useful.
Thanks,
Susmitha
05-14-2006 8:13 PM
Try:
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:file.txt'
<b> WRITE_FIELD_SEPARATOR = ','</b>
tables
data_tab = itab.
Rob
05-14-2006 8:46 PM
05-14-2006 9:29 PM
My mistake - I think it puts a tab between fields.
I guess you can do something like:
concatenate field1 matnr into field1.
field1+18(1) = ','.
concatenate etc...
Rob
Message was edited by: Rob Burbank
05-14-2006 10:01 PM
Hi
You should know the structure of the record of the file and so you can try to solve your problem using field-symbols:
FIELD-SYMBOLS: <FS_FIELD> TYPE ANY.
DATA: WA_STRING(10000) TYPE C.
DATA: LEN_FIELD TYPE I,
LEN_STRING TYPE I.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <RECORD> TO
<FS_FIELD>.
IF SY-SUBRC <> 0. EXIT. ENDIF.
DESCRIBE FIELD <FS_FIELD> LENGTH LEN_FIELD.
WRITE: <FS_FIELD> TO WA_STRING+LEN_STRING(LEN_FIELD).
LEN_STRING = LEN_STRING + LEN_FIELD.
WRITE: ',' TO WA_STRING+LEN_STRING.
CONDENSE WA_STRING NO-GAPS.
LEN_STRING = LEN_STRING + LEN_SEPAR.
ENDDO.
TRANSFER WA_STRING TO <FILE>.
or if you have to download to present server:
APPEND WA_STRING TO TB_FILE.
and after transfer that internal table to GUI_DOWNLOAD fm.
Max
05-15-2006 3:23 AM
hi,
take another internal table of char type.
data: begin of it_final occurs 0,
line(1000) type c,
end of it_final.
then looop your current internal table & append it to IT_FINAL after putting ',' as field separator like
loop it_temp.
concatenate it_temp-field1
it_temp-field2
it_temp-field3
*--
into it_final-line separated by ','.
append it_final.
clear it_temp.
endloop.
*--now IT_FINAL will have all the records of it_temp with COMMA as field separator.
now use GUI_DOWNLOAD & pass the file name & IT_FINAL to that.
regards
srikanth
05-15-2006 4:39 AM
Hi,
I guess you wanted fixed length records in the flat file with delimiter for fields also.
In that case,
in your internal table declaration, put a separator field of length 1 between every 2 data fields and fill it with a ','. then move your records into a string table before writing it into a file.
for example..
data: begin of it_material occurs 0,
matnr like mara-matnr,
delim1,
maktx like makt-maktx,
delim2,
meins like mara-meins,
-
-
end of it_material,
file your table with data...
at the end ... before wring it to a file do the following..
data it_string(250) type c occurs 0 with header line.
loop at it_material.
move ',' to: it_material-delim1,
it_material-delim2,
-
-
move it_material to it_string.
append it_string.
endloop.
Then download your it_string internal table to a file using normal downloading ...
Hope this helps.
Regards,
Nagaraju Chidurupalli.