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

分类:

2007-12-12 21:09:24

*&---------------------------------------------------------------------*
*& Report  ZRS08186                                                    *
*&                                                                     *
*&---------------------------------------------------------------------*
*& 用 HTML 输出 LIST 报表                                                *
*& Submit一个程序,然后把结果保存为HTML文件                                *
*&---------------------------------------------------------------------*
REPORT  z_barry_html_out   LINE-SIZE 450     .
DATA: mtab_report_list LIKE abaplist OCCURS 0 WITH HEADER LINE,
      mtab_report_html LIKE w3html OCCURS 0 WITH HEADER LINE.
PARAMETERS: p_fname LIKE rlgrap-filename OBLIGATORY DEFAULT 'C:\testhtm.htm' ,
            p_sname(128) DEFAULT '/usr/sap/DEV/DVEBMGS00/work/TESThtml.htm' LOWER CASE NO-DISPLAY .
SUBMIT z_barry_html_out_alv EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
  TABLES
    listobject = mtab_report_list
  EXCEPTIONS
    not_found  = 1.
CALL FUNCTION 'WRITE_LIST'
  TABLES
    listobject = mtab_report_list
  EXCEPTIONS
    empty_list = 1
    OTHERS     = 2.
*CALL FUNCTION 'WWW_LIST_TO_HTML'
*  TABLES
*    html = mtab_report_html.
CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
  TABLES
    html       = mtab_report_html
    listobject = mtab_report_list.
IF sy-subrc NE 0.
  WRITE: / 'ERROR IN GENERATING THE HTML FORMAT'.
  EXIT.
ENDIF.
*CALL FUNCTION 'WS_DOWNLOAD'
*  EXPORTING
*    filename = p_fname
*    mode     = 'BIN'
*  TABLES
*    data_tab = mtab_report_html
*  EXCEPTIONS
*    OTHERS   = 1.
*
*IF sy-subrc <> 0.
*  WRITE:/ 'ERROR DOWNLOADING', p_fname.
*ELSE.
*  WRITE: / 'OUTPUT SAVED IN FILE', p_fname.
*ENDIF.
OPEN DATASET p_sname FOR OUTPUT IN BINARY MODE.
LOOP AT mtab_report_html.
  TRANSFER mtab_report_html TO p_sname.
ENDLOOP.
CLOSE DATASET p_sname.
PERFORM down_file USING p_sname p_fname .
IF sy-subrc <> 0.
  WRITE:/ 'ERROR DOWNLOADING', p_fname.
ELSE.
  WRITE: / 'OUTPUT SAVED IN FILE', p_fname.
ENDIF.
*&--------------------------------------------------------------------*
*&      Form  down_file
*&--------------------------------------------------------------------*
FORM down_file USING    p_path file_name .
  DATA: path LIKE rcgfiletr-ftappl .
  DATA: localfile LIKE rcgfiletr-ftfront.
  path = p_path .
  localfile = file_name .
  CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
    EXPORTING
      i_file_front_end    = localfile
      i_file_appl         = path
      i_file_overwrite    = 'X'
    EXCEPTIONS
      fe_file_open_error  = 1
      fe_file_exists      = 2
      fe_file_write_error = 3
      ap_no_authority     = 4
      ap_file_open_error  = 5
      ap_file_empty       = 6
      OTHERS              = 7.
  IF sy-subrc <> 0.
    IF sy-msgty = '' .
      sy-msgty = 'E' .
    ENDIF .
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                               " DOWN_FILE
阅读(6434) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~