2009 Aug 24 10:34 AM
Hi Friends,
I'm getting problem in reading data from the flat file using the READ DATASET statement.
I have include coding below
With Regards,
Baskaran
Hi,
READ DATASET is used to read data from the application server.
If you want to read data from presentation server then use the FM GUI_UPLOAD.
pls elaborate ur reuirement
Regards,
Rahul
2009 Aug 24 10:37 AM
Hi,
READ DATASET is used to read data from the application server.
If you want to read data from presentation server then use the FM GUI_UPLOAD.
pls elaborate ur reuirement
Regards,
Rahul
2009 Aug 24 10:41 AM
2009 Aug 24 10:45 AM
I dont have idea about read dataset to read a file either..
try gui_upload
Regards,
Sumit.
DATA P_FILET TYPE STRING.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = P_FILET
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_DATA
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2009 Aug 24 11:00 AM
WHAT PROBLEM DO YOU HAVE ? (we won't spend time to read your code and find all the eventual bugs)
2009 Aug 24 12:03 PM
Hi,
This code may be of some help..
chk out:
*Open the flat file present in the given location to read the data in
*text mode
OPEN DATASET LV_FILENAME FOR INPUT IN TEXT MODE.
*Throw an error when the file is unavailable
IF SY-SUBRC <> 0.
MESSAGE E127(SY) WITH LV_FILENAME.
ENDIF.
DO.
*Read the file from Unix and move the data to the work area
READ DATASET LV_FILENAME INTO WA_DATAFILE.
*Check for the existance of data
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
*Close the flat file after the data is copied to the internal table
CLOSE DATASET LV_FILENAME.
2009 Aug 24 12:08 PM
Hi,
To read the data from application server:
DATA: lv_app_server_file TYPE string.
lv_app_server_file = pa_afile.
To read file from Application server
OPEN DATASET lv_app_server_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET lv_app_server_file INTO wa_file_data.
IF sy-subrc = 0.
APPEND wa_file_data TO gi_file_data.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET lv_app_server_file.
To upload the data from text file from machine:
lv_filetype = 'ASC'.
lv_gui_sep = 'X'.
lv_file_name = pa_dfile.
FM call to upload file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file_name
filetype = lv_filetype
has_field_separator = lv_gui_sep
TABLES
data_tab = gi_zhralcon_file.
Regards,
Rajesh Kumar
2009 Aug 25 7:46 AM
if you want to read a flat file you need to use gui_upload
try this example for more info
http://saplab.blogspot.com/2007/10/sample-abap-program-to-upload-table.html
2009 Dec 09 11:38 AM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |