ABAP---如何将内表数据转成HTML格式文件

<!--StartFragment --> <style type="text/css"> 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; } </style>本代码使用下列三个函数来完成将内表数据转换成本地的 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.

REPORTzdownload_table_html.
*-InternaltableDeclaration
TYPES:BEGINOFty_vbap,
vbelnTYPEvbeln,
posnrTYPEposnr,
matnrTYPEmatnr,
ENDOFty_vbap.
*-ALLrelatedDeclarations
DATA:t_headerTYPESTANDARDTABLEOFw3headWITHHEADERLINE,"Header
t_fieldsTYPESTANDARDTABLEOFw3fieldsWITHHEADERLINE,"Fields
t_htmlTYPESTANDARDTABLEOFw3html,"Html
wa_headerTYPEw3head,
w_headTYPEw3head.
DATA:it_vbapTYPESTANDARDTABLEOFty_vbap,
it_fcatTYPElvc_t_fcatWITHHEADERLINE.
START-OF-SELECTION.
SELECTvbelnposnrmatnr
FROMvbap
INTOTABLEit_vbap
UPTO20ROWS.

END-OF-SELECTION.
*-PopulatetheColumns
it_fcat-coltext='SalesOrder'.
APPENDit_fcat.
it_fcat-coltext='ItmeNumber'.
APPENDit_fcat.
it_fcat-coltext='Material'.
APPENDit_fcat.
*-FilltheColumnheadingandFiledProperties
LOOPATit_fcat.
w_head-text=it_fcat-coltext.
CALLFUNCTION'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
field_nr=sy-tabix
text=w_head-text
fgcolor='black'
bgcolor='green'
TABLES
header=t_header.
CALLFUNCTION'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
field_nr=sy-tabix
fgcolor='black'
size='3'
TABLES
fields=t_fields.
ENDLOOP.
*-TitleoftheDisplay
wa_header-text='SalesOrderDetails'.
wa_header-font='Arial'.
wa_header-size='2'.
*-PreparingtheHTMLfromIntenalTable
REFRESHt_html.
CALLFUNCTION'WWW_ITAB_TO_HTML'
EXPORTING
table_header=wa_header
TABLES
html=t_html
fields=t_fields
row_header=t_header
itable=it_vbap.
*-DownloadtheHTMLintofrontend
CALLFUNCTION'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.
IFsy-subrc<>0.
MESSAGEIDsy-msgidTYPEsy-msgtyNUMBERsy-msgno
WITHsy-msgv1sy-msgv2sy-msgv3sy-msgv4.
ENDIF.
*-DisplaytheHTMLfile
CALLMETHODcl_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.
IFsy-subrc<>0.
MESSAGEIDsy-msgidTYPEsy-msgtyNUMBERsy-msgno
WITHsy-msgv1sy-msgv2sy-msgv3sy-msgv4.
ENDIF.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值