*&---------------------------------------------------------------------*
*& 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) |