‎2007 Apr 18 11:55 AM
hi all,
i have some internal table data .i want to create a flat file when we i click on the generate push button.
how to generate a flat file according to the internal table data.
pls help me
thanks and regards,
lakshmi.
‎2007 Apr 18 11:56 AM
Hi sivangalakshmi,
1. Very simple
2. Just use the FM GUI_DOWNLOAD
pass the filename, and the internal table.. thats all!
regards,
amit m.
‎2007 Apr 18 11:56 AM
hi,
if you want to generate a flat file at presentation server then call FM gui_download.
at the push button logic code.
regards,
Navneeth.K
‎2007 Apr 18 12:01 PM
Hi,
Try the following code.
data:
begin of fs_spfli,
carrid(3) type c, "spfli-carrid,
connid(4) type c, "spfli-connid,
countryfr(3) type c, " spfli-countryfr,
cityfrom(20) type c, " spfli-cityfrom,
airpfrom(3) type c, " spfli-airpfrom,
countryto(3) type c, " spfli-countryto,
cityto(20) type c, " spfli-cityto,
airpto(3) type c, " spfli-airpto,
end of fs_spfli.
data:
t_spfli like standard table
of fs_spfli.
select carrid
connid
countryfr
cityfrom
airpfrom
countryto
cityto
airpto
from spfli
into table t_spfli.
call function 'DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = 'D:\backup\spfli'
FILETYPE = ' '
ITEM = ' '
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
SILENT = 'S'
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
importing
ACT_FILENAME =
ACT_FILETYPE =
FILESIZE =
CANCEL =
tables
data_tab = t_spfli
FIELDNAMES =
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
regards,
kiran kumar k
‎2007 Apr 18 12:02 PM
hi
You can use <b>GUI_DOWNLOAD</b> to do this, but you need to pass a flat table with the data separated by commas.
report zrich_0001 .
data: it001 type table of t001 with header line.
data: iout type table of string .
data: xout type string.
field-symbols: <fs>.
select * into table it001 from t001.
loop at it001.
clear xout.
do.
assign component sy-index of structure it001 to <fs>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
xout = <fs>.
else.
concatenate xout <fs> into xout separated by ','.
endif.
enddo.
append xout to iout.
endloop.
call function<b> 'GUI_DOWNLOAD'</b>
exporting
filename = 'C:\test.csv'
tables
data_tab = iout.
hope it will definitely help u
regards
ravish
<b>plz dont forget to reward points if helpful</b>
‎2007 Apr 18 12:03 PM
Hi,
If you wnat to generate flat file in Presentation server then youse FM GUI_DOWNLOAD when you Press pushbutton
else if you wnat to get that into Application server
*move table contents you want to a char field table
LOOP AT T_SPFLI INTO FS_SPFLI.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE FS_SPFLI TO <FS1>.
IF SY-SUBRC EQ 0.
WRITE <FS1> TO W_FIELD.
IF SY-INDEX EQ 1.
CONCATENATE W_CHAR1 W_FIELD INTO W_CHAR1.
ELSE.
CONCATENATE W_CHAR1 ',' W_FIELD INTO W_CHAR1.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
CONDENSE W_CHAR1.
APPEND W_CHAR1 TO T_SPFLI1.
CLEAR W_CHAR1.
ENDLOOP.
OPEN DATASET W_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT T_SPFLI1 INTO W_CHAR1.
TRANSFER W_CHAR1 TO W_FNAME.
ENDLOOP.
CLOSE DATASET W_FNAME.
with regards,
Jay