Importing parameters:
I_TEXTNAME TYPE RSSCE-TDNAME -> text name
I_TITLE TYPE CSEQUENCE -> our titile
I_SUBTITLE TYPE CSEQUENCE ->our subtitle
VALUE( C_XSTRING ) TYPE XSTRING -> I’ll use that in next part
method chart_customizing.
*This is the code from IT虾米网
data: ft_raw255 type solix_tab.
data: fs_raw255 type solix.
data: f_tablenght type i.
data: f_string type string.
data: f_xstring type xstring.
data: fo_ixml type ref to if_ixml.
data: fo_streamfactory type ref to if_ixml_stream_factory.
data: fo_istream type ref to if_ixml_istream.
data: fo_document type ref to if_ixml_document. “<=== here is IF_IXML_DOCUMENT
data: fo_parser type ref to if_ixml_parser.
data: f_ostream type ref to if_ixml_ostream.
data: f_subtitle type string.
data: f_title type string.
data: ft_itf_text type table of tline.
field-symbols: <itf> type tline.
f_subtitle = i_subtitle.
f_title = i_title.
call function ‘READ_TEXT’
exporting
id = ‘ST‘
language = ‘E‘
name = i_textname
object = ‘TEXT’
tables
lines = ft_itf_text
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
others = 8.
if sy–subrc <> 0.
* raise error_reading_standard_text.
else.
loop at ft_itf_text assigning <itf>.
concatenate f_string <itf>–tdline into f_string.
endloop.
endif.
if f_string is not initial. “if you have other special html characters in titles or variables in configurations then add it here
replace all occurrences of ‘&’ in f_subtitle with ‘&’.
replace all occurrences of ‘&’ in f_title with ‘&’.
replace all occurrences of ‘<‘ in f_subtitle with ‘<’.
replace all occurrences of ‘<‘ in f_title with ‘<’.
replace all occurrences of ‘>’ in f_subtitle with ‘>’.
replace all occurrences of ‘>’ in f_title with ‘>’.
replace all occurrences of ‘SUBTITLE_REPLACE’ in f_string with f_subtitle.
replace all occurrences of ‘TITLE_REPLACE’ in f_string with f_title.
clear f_xstring.
call function ‘SCMS_STRING_TO_XSTRING’
exporting
text = f_string
* MIMETYPE = ‘ ‘
* ENCODING = ENCODING
importing
buffer = f_xstring
exceptions
failed = 1
others = 2
.
if sy–subrc eq 0.
call function ‘SCMS_XSTRING_TO_BINARY’
exporting
buffer = f_xstring
* APPEND_TO_TABLE = ‘ ‘
importing
output_length = f_tablenght
tables
binary_tab = ft_raw255
.
endif.
check ft_raw255[] is not initial.
fo_ixml = cl_ixml=>create( ).
fo_streamfactory = fo_ixml->create_stream_factory( ).
fo_document = fo_ixml->create_document( ).
fo_istream = fo_streamfactory->create_istream_itable(
size = f_tablenght
table = ft_raw255 ).
fo_parser = fo_ixml->create_parser( stream_factory = fo_streamfactory
istream = fo_istream
document = fo_document ).
fo_parser->parse( ).
clear c_xstring.
f_ostream = fo_streamfactory->create_ostream_xstring( c_xstring ).
call method fo_document->render
exporting
ostream = f_ostream.
endif.
endmethod.
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/20167.html