Code is as follow:
TYPES: BEGIN OF st_item,
mandt TYPE mandt,
mblnr TYPE mblnr,
mjahr TYPE mjahr,
zeile TYPE mblpo,
status TYPE yumm0154,
timestamp TYPE timebegin,
message TYPE char255,
END OF st_item.
DATA: itab_item TYPE STANDARD TABLE OF st_item INITIAL SIZE 0,
wa_item TYPE st_item.
DATA: itab_final TYPE STANDARD TABLE OF st_item INITIAL SIZE 0,
wa_final TYPE st_item.
DATA: l_filename TYPE string.
* At Selection screen on Value Request
PARAMETERS: p_ppath TYPE char128.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ppath.
PERFORM sub_get_filename CHANGING p_ppath.
* Start-of-selection
START-OF-SELECTION.
IF p_ppath IS NOT INITIAL.
l_filename = p_ppath.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filename
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab_item[]
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.
ENDIF.
WRITE: 10 'MBLNR', 30 'MJHAR', 40 'ZEILE', 60 'STATUS', 80 'TIMESTAMP'.
LOOP AT itab_item INTO wa_item.
MOVE-CORRESPONDING wa_item TO wa_final.
SKIP.
WRITE : 10 wa_item-mblnr,
30 wa_item-mjahr ,
40 wa_item-zeile,
60 wa_item-status,
80 wa_item-timestamp.
APPEND wa_final TO itab_final.
CLEAR: wa_item, wa_final.
ENDLOOP.
REFRESH itab_item.
IF NOT itab_final[] IS INITIAL.
LOOP AT itab_final INTO wa_final.
INSERT table_name FROM wa_final .
COMMIT WORK.
ENDLOOP.
ENDIF.
* Form sub_get_filename
FORM sub_get_filename CHANGING p_file TYPE char128.
DATA : l_path TYPE string. " For Directory
DATA : l_path1 TYPE string. " For Directory
DATA : l_path2 TYPE string. " For Directory
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
ENDFORM. "sub_get_filename
Then the screen is as this is:
Hiç yorum yok:
Yorum Gönder