2006 Jan 11 4:36 PM
Hi all,
Here is the sample code with which I am trying to write the contents of an internal table to a local file using ws_download function module.
The error it shows is : error when opening the download file.
please check the code and tell where i am going wrong.
REPORT zv_ittable_localfile.
DATA : BEGIN OF itab OCCURS 0 ,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF itab.
SELECT carrid connid fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM sflight.
*loop at itab.
*write 😕 itab-carrid,itab-connid,itab-fldate.
*endloop.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'C:/Documents and
Settings/nsi/Desktop/vijay'
FILETYPE = 'ASC'
MODE = ' '
TABLES
data_tab = itab
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
points will be awarded.
Regards,
Vijay.
Hi all,
Here is the sample code with which I am trying to write the contents of an internal table to a local file using ws_download function module.
The error it shows is : error when opening the download file.
please check the code and tell where i am going wrong.
REPORT zv_ittable_localfile.
DATA : BEGIN OF itab OCCURS 0 ,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF itab.
SELECT carrid connid fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM sflight.
*loop at itab.
*write 😕 itab-carrid,itab-connid,itab-fldate.
*endloop.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'C:/Documents and
Settings/nsi/Desktop/vijay'
FILETYPE = 'ASC'
MODE = ' '
TABLES
data_tab = itab
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
points will be awarded.
Regards,
Vijay.
2006 Jan 11 4:39 PM
Give an extension to the file.
Hi Vijay,
Close the file when you are uploading or executing the program.
Message was edited by: Phani Kiran Nudurupati
2006 Jan 11 4:40 PM
Hi,
The file is already closed. check what I have to specify at the mode in export parameters I do not know what should be spcified there.
Regards,
Vijay.
2006 Jan 11 4:44 PM
2006 Jan 11 4:46 PM
The function module GUI_DOWNLOAD is a more recent version, please try using it.
report zrich_0001.
data : begin of itab occurs 0 ,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
end of itab.
select carrid connid fldate
into corresponding fields of table itab
from sflight.
*loop at itab.
*write :/ itab-carrid,itab-connid,itab-fldate.
*endloop.
call function 'GUI_DOWNLOAD'
exporting
filename
= 'C:/Documents and Settings/heilmanr/Desktop/text.txt'
tables
data_tab = itab
exceptions
others = 22
.
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,
Rich Heilman
2006 Jan 11 4:46 PM
Hi rich,
what are the values you have passed to file name, file type and write mode expport parameters.
Reards,
vijay.
2006 Jan 11 4:47 PM
Nothing to specify vijay.Its absolutely fine.It worked for me too.
2006 Jan 11 4:48 PM
REPORT ZTESTAA .
DATA : BEGIN OF itab OCCURS 0 ,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF itab.
SELECT carrid connid fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM sflight.
*loop at itab.
*write :/ itab-carrid,itab-connid,itab-fldate.
*endloop.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'C:test.txt'
FILETYPE = 'ASC'
MODE = ' '
TABLES
data_tab = itab
* FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.the code is working fine...
i checked it is working,i changed the filename.
may be the file path you have give wrong. give properly
regards
vijay
2006 Jan 11 4:50 PM
When you give mode as 'A' it will append the file with the new data when ever you execute the program.IF mode is space it will Overwrite the data.
File name & file type is as given by you.
2006 Jan 11 4:53 PM
Hi Vijay,
When you are downloading to desktop and using the directories that are longer than 8 characters, particularly with spaces etc, you cannot hardcode the directory as you did. You have to take it from the screen as a parameter and pass it to the call. That way the conversion from the long name directories to underlying DOS 8 character directory names will be taken care of by the system. Here is the code.
DATA : BEGIN OF itab OCCURS 0 ,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate.
DATA: END OF itab.
PARAMETERS: p_file LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
* EXPORTING
* program_name = syst-repid
* dynpro_number = syst-dynnr
* field_name = ' '
* static = ' '
* mask = ' '
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
START-OF-SELECTION.
SELECT carrid connid fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM sflight.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = p_file
filetype = 'ASC'
mode = ' '
TABLES
data_tab = itab
* FIELDNAMES =
EXCEPTIONS
file_open_error = 1
file_write_error = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
2006 Jan 11 4:45 PM
2006 Jan 11 4:50 PM
try
FILENAME = 'C:\Documents and
Settings\nsi\Desktop\vijay.txt'
2006 Jan 11 5:12 PM
Hi Vijay,
The thing is u did not mention the file type like (.txt).
it is as simple as that.
please go through below code.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'C:/vijay.txt'
FILETYPE = 'ASC'
MODE = ' '
TABLES
data_tab = itab
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
use the code like this.
cheers,
vengal.
2006 Jan 12 7:29 AM
DATA : BEGIN OF itab OCCURS 0 ,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF itab.
SELECT carrid connid fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM sflight.
*loop at itab.
*write 😕 itab-carrid,itab-connid,itab-fldate.
*endloop.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'C:\test.txt'
FILETYPE = 'ASC'
MODE = ' '
TABLES
data_tab = itab
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2006 Jan 12 7:30 AM
DATA : BEGIN OF itab OCCURS 0 ,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF itab.
SELECT carrid connid fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM sflight.
*loop at itab.
*write 😕 itab-carrid,itab-connid,itab-fldate.
*endloop.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'C:\test.txt'
FILETYPE = 'ASC'
MODE = ' '
TABLES
data_tab = itab
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |