Interview Questions

From Excel to ABAP - Is batch mode possible ?

SAP ABAP questions and answers


(Continued from previous question...)

From Excel to ABAP - Is batch mode possible ?

DATA w_file TYPE string.
* Convert the file path into string
w_file = p_input.

* Internal Table should have same field sequence as EXL File.

CLEAR t_upload.
REFRESH t_upload.

* Call function to upload the data into internal table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = t_upload
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.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ELSE.
* Delete the first row of heading from the uploaded table
DELETE t_upload INDEX 1.
ENDIF. " IF sy-subrc EQ 0.

(Continued on next question...)

Other Interview Questions