Create a nice looking chart with CL_GUI_CHART_ENGINE – Part 2 – Customization详解编程语言

In part one for this tutorial I quickly shown you how to create a chart customizing using Chart Designer, in this part I will show how I store and use such customizing. For the beginning I’ll tell you that there are many ways to store the customizing, you can keep it in GOS, or in APP server or load it directly from PC, but my favorite one is to keep the customizing in standard texts (SO10) and read it from there. It’s easy to do changes there and it can be restricted in authorizations who can do changes for such text.
So I’ll go to SO10 and create new text for customization there:
Create a nice looking chart with CL_GUI_CHART_ENGINE - Part 2 - Customization详解编程语言
Then I’ll paste the XML content here and save:
Create a nice looking chart with CL_GUI_CHART_ENGINE - Part 2 - Customization详解编程语言
 
After it’s done I can prepare a module to read the text, replace title and subtitle and to create an xstring from it. I will use this xstring in next part of tutorial to render the chart.

Importing parameters:

I_TEXTNAME TYPE RSSCE-TDNAME  -> text name
I_TITLE TYPE CSEQUENCE -> our titile
I_SUBTITLE TYPE CSEQUENCE ->our subtitle

Returning parameters:

VALUE( C_XSTRING ) TYPE XSTRING -> I’ll use that in next part

Implementation:

method chart_customizing.
*This is the code from IT虾米网
  dataft_raw255 type solix_tab.
  datafs_raw255 type solix.
  dataf_tablenght type i.
  dataf_string type string.
  dataf_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.
  dataf_subtitle type string.
  dataf_title type string.
  dataft_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 sysubrc <> 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 ‘&amp;’.
    replace all occurrences of ‘&’ in f_title with ‘&amp;’.
    replace all occurrences of ‘<‘ in f_subtitle with ‘&lt;’.
    replace all occurrences of ‘<‘ in f_title with ‘&lt;’.
    replace all occurrences of ‘>’ in f_subtitle with ‘&gt;’.
    replace all occurrences of ‘>’ in f_title with ‘&gt;’.
    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 sysubrc 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_parserstream_factory fo_streamfactory
                                        istream        
fo_istream
                                        document       
fo_document ).
    fo_parser->parse( ).
    clear c_xstring.
    f_ostream fo_streamfactory->create_ostream_xstringc_xstring ).
    call method fo_document->render
      
exporting
        ostream f_ostream.

  endif.

endmethod.

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/20167.html

(0)
上一篇 2021年7月19日 23:06
下一篇 2021年7月19日 23:06

相关推荐

发表回复

登录后才能评论