Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7202772
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

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.

阅读(2828) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~