ABAP顾问
分类:
2010-09-30 16:44:36
REPORT z_barry_test NO STANDARD PAGE HEADING LINE-SIZE 400.
DATA: BEGIN OF itab OCCURS 0 ,
line(1024),
END OF itab.
DATA: itab2 LIKE itab OCCURS 0 WITH HEADER LINE .
DATA: BEGIN OF it_file OCCURS 0 ,
file(50),
END OF it_file.
DATA: filename TYPE string ,
find TYPE c ,
count TYPE i.
PARAMETERS: p_path TYPE string .
SELECT-OPTIONS s_file FOR it_file-file NO INTERVALS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path .
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
initial_folder = 'C:\'
CHANGING
selected_folder = p_path
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
START-OF-SELECTION.
IF s_file[] IS INITIAL.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = p_path
filter = 'Z*.TXT'
CHANGING
file_table = it_file[]
count = count
EXCEPTIONS
OTHERS = 6.
IF count = 0.
MESSAGE e000(oo) WITH 'No file selected!'.
ENDIF.
s_file-sign = 'I'.
s_file-option = 'EQ'.
LOOP AT it_file.
s_file-low = it_file-file.
APPEND s_file.
ENDLOOP.
ENDIF.
LOOP AT s_file.
CLEAR:itab2[],itab2,find.
CONCATENATE p_path '\' s_file-low INTO filename.
REPLACE ALL OCCURRENCES OF '\\' IN filename WITH '\'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
TABLES
data_tab = itab
EXCEPTIONS
OTHERS = 17.
IF sy-subrc = 0.
LOOP AT itab INTO itab2.
APPEND itab2.
IF itab2-line+0(8) = '????ATTR'.
find = 'X'.
EXIT.
ENDIF.
ENDLOOP.
IF find = 'X'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = filename
TABLES
data_tab = itab2
EXCEPTIONS
OTHERS = 22.
ENDIF.
ENDIF.
ENDLOOP.