04-24-2007 7:58 AM
Hi Friends,
I am facing a problem while uploading data to internal table using Function module GUI_UPLOAD,it is showing a dump.I have sent the code along with this mail,Can you please let me the problem.
Code:
DATA: i_file like rlgrap-filename value 'C:\upld.txt'.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
*START-OF-SELECTION
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = i_file
filetype = 'ASC'
has_field_separator = 'X' "file is TAB delimited
TABLES
data_tab = it_datatab
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 NE 0.
write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
skip.
endif.
Regards,
Dinesh
04-24-2007 8:01 AM
Hi dinesh,
change the hilighted code and reward if it solves.
DATA: i_file like rlgrap-filename value 'C:\upld.txt'.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
<b>data: v_file type string.</b>
*START-OF-SELECTION
START-OF-SELECTION.
<b>v_file = i_file.</b>
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = <u>i_file</u> <i><b>change to</b></i> <u><b>v_file</b></u>
filetype = 'ASC'
has_field_separator = 'X' "file is TAB delimited
TABLES
data_tab = it_datatab
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 NE 0.
write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
skip.
endif.
Thanks
eswar
04-24-2007 8:04 AM
Hi -
GUI Upload FM can take only String files as Input.
Change the file type and execute the report.
Thanks ,
Maheshwari V
04-24-2007 8:05 AM
Hi Dinesh,
check this sample code .
REPORT zupload MESSAGE-ID bd.
DATA: w_tab TYPE ZTEST.
DATA: i_tab TYPE STANDARD TABLE OF ZTEST.
DATA: v_subrc(2),
v_recswritten(6).
PARAMETERS: p_file(80)
DEFAULT 'C:TempZTEST.TXT'.
DATA: filename TYPE string,
w_ans(1) TYPE c.
filename = p_file.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Upload Confirmation'
* DIAGNOSE_OBJECT = ' '
text_question = p_file
text_button_1 = 'Yes'(001)
* ICON_BUTTON_1 = ' '
text_button_2 = 'No'(002)
* ICON_BUTTON_2 = ' '
default_button = '2'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
answer = w_ans
* TABLES
* PARAMETER =
* EXCEPTIONS
* TEXT_NOT_FOUND = 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.
CHECK w_ans = 1.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
* FILETYPE = 'ASC
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = i_tab
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.
* SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *
IF sy-subrc <> 0.
v_subrc = sy-subrc.
MESSAGE e899 WITH 'File Open Error' v_subrc.
ENDIF.
INSERT ZTEST FROM TABLE i_tab.
COMMIT WORK AND WAIT.
MESSAGE i899 WITH sy-dbcnt 'Records Written to ZTEST'.
Regards,
Raghav
04-24-2007 8:06 AM
Babu,
change the filename like below
DATA: i_file type string .
START-OF-SELECTION.
i_file = 'C:\upld.txt'.
Don't forget to reward if useful