ABAP---如何将内表数据转成HTML格式文件
2008-07-21 11:28
344 查看
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
.L1S31 { font-style: italic; color: #808080 }
.L1S32 { color: #3399FF }
.L1S33 { color: #4DA619 }
.L1S52 { color: #0000FF }
本代码使用下列三个函数来完成将内表数据转换成本地的 HTML文件,并使用 IE打开浏览。三个函数说明如下:
'WWW_ITAB_TO_HTML_HEADERS' "This is used to Set the Column properties
'WWW_ITAB_TO_HTML_LAYOUT' "This is used to set the layout properties
'WWW_ITAB_TO_HTML' "Using the Columns Definitions and Internal table this Function converts the internal table data into HTML format.
REPORT zdownload_table_html.
*-Internal table Declaration
TYPES: BEGIN OF ty_vbap,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
END OF ty_vbap.
*-ALL related Declarations
DATA: t_header TYPE STANDARD TABLE OF w3head WITH HEADER LINE, "Header
t_fields TYPE STANDARD TABLE OF w3fields WITH HEADER LINE, "Fields
t_html TYPE STANDARD TABLE OF w3html, "Html
wa_header TYPE w3head,
w_head TYPE w3head.
DATA: it_vbap TYPE STANDARD TABLE OF ty_vbap,
it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
START-OF-SELECTION.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE it_vbap
UP TO 20 ROWS.
END-OF-SELECTION.
*-Populate the Columns
it_fcat-coltext = 'SalesOrder'.
APPEND it_fcat.
it_fcat-coltext = 'ItmeNumber'.
APPEND it_fcat.
it_fcat-coltext = 'Material'.
APPEND it_fcat.
*-Fill the Column heading and Filed Properties
LOOP AT it_fcat.
w_head-text = it_fcat-coltext.
CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
field_nr = sy-tabix
text = w_head-text
fgcolor = 'black'
bgcolor = 'green'
TABLES
header = t_header.
CALL FUNCTION 'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
field_nr = sy-tabix
fgcolor = 'black'
size = '3'
TABLES
fields = t_fields.
ENDLOOP.
*-Title of the Display
wa_header-text = 'Sales Order Details' .
wa_header-font = 'Arial'.
wa_header-size = '2'.
*-Preparing the HTML from Intenal Table
REFRESH t_html.
CALL FUNCTION 'WWW_ITAB_TO_HTML'
EXPORTING
table_header = wa_header
TABLES
html = t_html
fields = t_fields
row_header = t_header
itable = it_vbap.
*-Download the HTML into frontend
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:/Sales.htm'
TABLES
data_tab = t_html
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-Display the HTML file
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = 'C:/Sales.htm'
operation = 'OPEN'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
.L1S31 { font-style: italic; color: #808080 }
.L1S32 { color: #3399FF }
.L1S33 { color: #4DA619 }
.L1S52 { color: #0000FF }
本代码使用下列三个函数来完成将内表数据转换成本地的 HTML文件,并使用 IE打开浏览。三个函数说明如下:
'WWW_ITAB_TO_HTML_HEADERS' "This is used to Set the Column properties
'WWW_ITAB_TO_HTML_LAYOUT' "This is used to set the layout properties
'WWW_ITAB_TO_HTML' "Using the Columns Definitions and Internal table this Function converts the internal table data into HTML format.
REPORT zdownload_table_html.
*-Internal table Declaration
TYPES: BEGIN OF ty_vbap,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
END OF ty_vbap.
*-ALL related Declarations
DATA: t_header TYPE STANDARD TABLE OF w3head WITH HEADER LINE, "Header
t_fields TYPE STANDARD TABLE OF w3fields WITH HEADER LINE, "Fields
t_html TYPE STANDARD TABLE OF w3html, "Html
wa_header TYPE w3head,
w_head TYPE w3head.
DATA: it_vbap TYPE STANDARD TABLE OF ty_vbap,
it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
START-OF-SELECTION.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE it_vbap
UP TO 20 ROWS.
END-OF-SELECTION.
*-Populate the Columns
it_fcat-coltext = 'SalesOrder'.
APPEND it_fcat.
it_fcat-coltext = 'ItmeNumber'.
APPEND it_fcat.
it_fcat-coltext = 'Material'.
APPEND it_fcat.
*-Fill the Column heading and Filed Properties
LOOP AT it_fcat.
w_head-text = it_fcat-coltext.
CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
field_nr = sy-tabix
text = w_head-text
fgcolor = 'black'
bgcolor = 'green'
TABLES
header = t_header.
CALL FUNCTION 'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
field_nr = sy-tabix
fgcolor = 'black'
size = '3'
TABLES
fields = t_fields.
ENDLOOP.
*-Title of the Display
wa_header-text = 'Sales Order Details' .
wa_header-font = 'Arial'.
wa_header-size = '2'.
*-Preparing the HTML from Intenal Table
REFRESH t_html.
CALL FUNCTION 'WWW_ITAB_TO_HTML'
EXPORTING
table_header = wa_header
TABLES
html = t_html
fields = t_fields
row_header = t_header
itable = it_vbap.
*-Download the HTML into frontend
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:/Sales.htm'
TABLES
data_tab = t_html
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-Display the HTML file
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = 'C:/Sales.htm'
operation = 'OPEN'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
相关文章推荐
- ABAP---如何将内表数据转成HTML格式文件
- ABAP---如何将内表数据转成HTML格式文件
- ABAP---如何将内表数据转成HTML格式文件
- ABAP---如何将内表数据转成HTML格式文件
- ABAP将内表数据转换为HTML格式的文件
- Android开发 解析JSON数据格式 如何去掉JSON数据文件的BOM头
- 如何把aspx页面中的某个控件输出成html页面(例如把一个页面中的datagrid数据输出成html格式的页面保存)
- 如何从html格式文件中获取M3u8的接口
- 如何隐藏aspx文件格式,变成html
- 文件如何转换成pdf或html格式
- matlab如何导入csv文件及matlab支持的数据格式,相应函数
- MySQL如何导入csv格式数据文件解决方案
- 用xmlhttp将html的数据打包成multipart/form-data格式,实现异步上传文件功能[转]
- 如何隐藏aspx文件格式,变成html
- 如何将jpg格式图像文件转化成一系列二进制数据,又如何将此二进制数据转化成jpg格式的文件?
- 如何将jpg格式图像文件转化成一系列二进制数据,又如何将此二进制数据转化成jpg格式的文件?
- 如何将matlab数据转换成libsvm格式文件
- 如何将mysql数据库的数据导出并转为.csv文件格式为UTF-8无BOM
- 如何调用HTML格式的帮助文件
- python:如何将txt文件中的数值数据读入到list中,且在list中存在的格式为float类型或者其他数值类型