Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Setting Chart Title Dynamically

Hi Experts,

I am currently using a mime(created using Graphics chart designer) for displaying a graph.

But, I am not able to set the Chart title dynamically.

Could someone please let me know how to set these properties Dynamically.

Thnx.

Regards,

Kishore

Former Member
Former Member replied

Hi,

Try the code below:

DATA: lv_xml_str    TYPE         string,
      o_mr_api      TYPE REF TO  if_mr_api,
      is_folder     TYPE         boole_d,
      l_loio        TYPE         skwf_io,
      lt_itab       TYPE         sdokcntbins,
      lv_len        TYPE         i,
      lv_url        TYPE         string,
      lv_xml_xstr   TYPE         xstring.
* get the XML from MIME
IF o_mr_api IS INITIAL.
  o_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).
ENDIF.
* URL to MIME
IF lv_url IS INITIAL.
  lv_url = '/sap/bc/bsp/sap/zdump/'.         
* XML file name
  CONCATENATE lv_url 'screen1.xml' INTO lv_url.
ENDIF.
TRANSLATE lv_url USING '\/'.

* get the MIME as xstring
CALL METHOD o_mr_api->get
  EXPORTING
    i_url              = lv_url
  IMPORTING
    e_is_folder        = is_folder
    e_content          = lv_xml_xstr
    e_loio             = l_loio
  EXCEPTIONS
    parameter_missing  = 1
    error_occured      = 2
    not_found          = 3
    permission_failure = 4
    OTHERS             = 5.
* convert xstring to string
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer        = lv_xml_xstr
  IMPORTING
    output_length = lv_len
  TABLES
    binary_tab    = lt_itab.

CALL FUNCTION 'SCMS_BINARY_TO_STRING'
  EXPORTING
    input_length = lv_len
    mimetype     = 'text/xml'
  IMPORTING
    text_buffer  = lv_xml_str
  TABLES
    binary_tab   = lt_itab.

DATA: lr_xml_parser    TYPE REF TO cl_ixml_mini_parser,
      lr_xml_render    TYPE REF TO cl_ixml_mini_renderer,
      lr_dom           TYPE REF TO if_ixml_mini_dom.

CREATE OBJECT lr_xml_parser.

CALL METHOD lr_xml_parser->if_ixml_mini_parser~parse_string(
EXPORTING
stream = lv_xml_str
IMPORTING
dom = lr_dom ).

DATA: lt_dom  TYPE tixmltdom.
FIELD-SYMBOLS: <fs_dom>  LIKE LINE OF lt_dom.
LOOP AT lr_dom->dom_table ASSIGNING <fs_dom>.      "replace what ever you need here
  IF <fs_dom>-name CS 'text'.
    <fs_dom>-value = 'Hello testing'.
  ENDIF.
ENDLOOP.
CLEAR lv_xml_str.
CREATE OBJECT lr_xml_render.
CALL METHOD lr_xml_render->if_ixml_mini_renderer~render_string(
EXPORTING
dom = lr_dom
IMPORTING
stream = lv_xml_str ).

Hope this resolves the issue.

Good luck.

Abhinav

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question