Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

generate flat file

Former Member
0 Likes
945

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.

5 REPLIES 5
Read only

Former Member
0 Likes
624

Hi sivangalakshmi,

1. Very simple

2. Just use the FM GUI_DOWNLOAD

pass the filename, and the internal table.. thats all!

regards,

amit m.

Read only

Former Member
0 Likes
624

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

Read only

Former Member
0 Likes
624

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

Read only

Former Member
0 Likes
624

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>

Read only

Former Member
0 Likes
624

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