05-16-2008 12:46 PM
Hi gurus
i need help regarding unploading a text file ,then reading its contents into an internal table .
05-16-2008 12:51 PM
Hello.
Use FM GUI_UPLOAD.
TYPES: BEGIN OF ty_tab,
lines TYPE string,
END OF ty_tab.
DATA: itab TYPE STANDARD TABLE OF ty_tab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Documents and Settings\valter\Desktop\nota1084207.txt'
filetype = 'ASC'
TABLES
data_tab = itab
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.
Reward if usefull,
Best regards.
Valter Oliveira.
05-16-2008 9:58 PM
Hi Sayanto,
There are two servers where you can import text files: from the presentation server (that's what Valter told you; GUI_UPLOAD) and from the application server.
Application Server:
For importing text files into an internal table you can use the following pseudo coding"
DATA: itab type table itab_type,
wa_struct type itab_type.
OPEN DATASET <full filepath on the appl-server> for INPUT.
WHILE SY-SUBRC = 0.
READ DATASET <full filepath on ...> INTO wa_struct.
APPEND wa_struct INTO itab.
ENDWHILE.
CLOSE DATASET <full filepath ....>.
Hope this helps,
Heinz