Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7185064
  • 博文数量: 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)

分类:

2008-12-12 12:52:25

REPORT  z_barry_zip_file.

DATA: IZIP       TYPE REF TO CL_ABAP_ZIP,
      CONT       TYPE XSTRING ,
      XZIP_FILE  TYPE XSTRING,
      BINARY_TAB TYPE STANDARD TABLE OF X255 ,
      BIN_LEN TYPE I .

DATA: ITAB TYPE STANDARD TABLE OF SDOKCNTASC .
 
START-OF-SELECTION.
  DO 20 TIMES.
    APPEND 'ABAP¿ª·¢' TO ITAB.
  ENDDO.
  CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
    EXPORTING
      MIMETYPE = 'text/html;charset=gb2312'
    IMPORTING
      BUFFER   = CONT
    TABLES
      TEXT_TAB = ITAB
    EXCEPTIONS
      FAILED   = 1
      OTHERS   = 2.
 
  CREATE OBJECT IZIP.
  CALL METHOD IZIP->ADD
    EXPORTING
      NAME    = 'ITAB.TXT'
      CONTENT = CONT.
  CALL METHOD IZIP->SAVE
    RECEIVING
      ZIP = XZIP_FILE.
 
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      BUFFER        = XZIP_FILE
    IMPORTING
      OUTPUT_LENGTH = BIN_LEN
    TABLES
      BINARY_TAB    = BINARY_TAB.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE = BIN_LEN
      FILENAME     = 'C:\sf.zip'
      FILETYPE     = 'BIN'
    TABLES
      DATA_TAB     = BINARY_TAB.
 
 
解压缩ZIP文件:
TYPES: BEGIN OF t_file,
         name TYPE string,
         date TYPE d,
         time TYPE t,
         size TYPE i,
       END OF t_file .
TYPES: t_files TYPE TABLE OF t_file .
DATA: cl_zip TYPE REF TO cl_abap_zip,
      xstr   TYPE xstring,
      binary_tab TYPE STANDARD TABLE OF x255 ,
      bin_len TYPE i ,
      ls_file TYPE t_file ,
      it_files TYPE t_files .

DATA: itab TYPE STANDARD TABLE OF sdokcntasc .

START-OF-SELECTION.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename   = 'C:\upload.zip'
      filetype   = 'BIN'
    IMPORTING
      filelength = bin_len
    TABLES
      data_tab   = binary_tab.

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
    EXPORTING
      input_length = bin_len
    IMPORTING
      buffer       = xstr
    TABLES
      binary_tab   = binary_tab
    EXCEPTIONS
      failed       = 1
      OTHERS       = 2.

  CREATE OBJECT cl_zip.

  CALL METHOD cl_zip->load
    EXPORTING
      zip = xstr.

  LOOP AT cl_zip->files INTO ls_file .
    WRITE: /  ls_file-name,
              ls_file-date,
              ls_file-time,
              ls_file-size .
    CALL METHOD cl_zip->get
      EXPORTING
        name    = ls_file-name
      IMPORTING
        content = xstr.
  ENDLOOP.


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

soukyo2011-06-10 19:56:20

User cannot save and open template with filename in Chinese, Japanese, Korean, Cyrillic, German, etc. 参见:Note 1283040 - Replacement of CL_ABAP_ZIP for supporting of Unicode

chinaunix网友2010-02-04 21:45:38

REPORT z_barry_test . DATA: izip TYPE REF TO cl_abap_zip, cont TYPE xstring , xzip_file TYPE xstring, binary_tab TYPE STANDARD TABLE OF x255 , bin_len TYPE i . DATA: itab TYPE STANDARD TABLE OF sdokcntasc . START-OF-SELECTION. * DO 20 TIMES. * APPEND 'ABAP¿ª·¢' TO ITAB. * ENDDO. * CALL FUNCTION 'SCMS_TEXT_TO_XSTRING' * EXPORTING * MIMETYPE = 'text/html;charset=gb2312' * IMPORTING * BUFFER = CONT

chinaunix网友2010-02-04 01:22:54

老大 能不能说说 怎么把EXCEL包进去 或者把本地的文件包进去

qdbarry2009-01-02 13:54:14

写顺手了

chinaunix网友2009-01-02 13:07:39

老大你还是换成gbk吧,否则生僻字又乱码了