2007 Apr 18 9:31 AM
Dear All,
I want to know that how to write text in exsisting notepad file stored in the C drive of my pc. Is there any FM to do this or something else. Pls suggest.
With Regards
Gaurav Lashkari
2007 Apr 18 9:34 AM
try this...
*"Table declarations...................................................
tables:
kna1. " General Data in Customer Master
*"Selection screen elements............................................
select-options:
s_kunnr for kna1-kunnr. " Customer Number 1
*" Type declarations...................................................
"----
types:
begin of type_s_customer_details,
name like kna1-kunnr,
address like kna1-adrnr,
title like kna1-anred,
createdon like kna1-erdat,
createdby like kna1-ernam,
end of type_s_customer_details.
data:
t_customer_details type table
of type_s_customer_details
with header line.
start-of-selection.
perform select.
form select .
select kunnr
adrnr
anred
erdat
ernam
into table t_customer_details
from kna1
where kunnr in s_kunnr.
if sy-subrc ne 0.
write : / 'DATABASE SELECTION FAILED'.
else.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = 'd:\customer_details.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'
IMPORTING
FILELENGTH =
tables
data_tab = t_customer_details
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.
write : / 'Upload Failed' , sy-subrc.
else.
write : / 'Upload Completed'.
endif.
endif.
endform. " SELECT
2007 Apr 18 9:34 AM
Use GUI_DOWNLOAD in APPEND mode.
you should pass the parameter APPEND = 'X' and give the ful file path to the filename parameter.
The text you want to write should be there in the internal table.
Regards,
Ravi
2007 Apr 18 9:35 AM
2007 Apr 18 9:35 AM
Hi,
Use this Function Module for download.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_load_file
filetype = 'ASC'
write_field_separator = '#'
TABLES
data_tab = l_errdata_leg
Hope it will work.
Regards,
-->Suresh
2007 Apr 18 9:36 AM
Hi,
Try the following code n let me know.
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 9:38 AM
Hi,
u have pass parameter to Append.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_load_file
filetype = 'ASC'
append = 'X'
write_field_separator = '#'
Regards,
-->Suresh
2007 Apr 18 9:45 AM
Gaurav,
U can achive it in a simple way by assigning 'X' to APPEND , which is one of the parameters of GUI_DOWNLOAD.
Regards,
Sujatha.
2007 Apr 18 9:51 AM
Hi gaurav,
1. We have to use GUI_DOWNLOAD.
2. (we can also use GUI_UPLOAD to get the contents of the file)
3. This program will do both.
(u can change the filename)
4.
report abc.
*----
DATA : BEGIN OF ITAB OCCURS 0,
MYLINE(100) TYPE C,
END OF ITAB.
DATA : FILENAME TYPE STRING.
*----
FILENAME = 'D:\ABC.TXT'.
*----
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB.
*----
REFRESH ITAB.
CLEAR ITAB.
ITAB-MYLINE = 'EXTRA LINE'.
APPEND ITAB.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
APPEND = 'X'
TABLES
DATA_TAB = ITAB.
BREAK-POINT.
regards,
amit m.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |