Hi,

Recently there was a question about sending a chart by mail from pavan kumar Mallipeddi

CL_GUI_CHART_ENGINE Graph As Email in Background

Using a hint from Jānis B I was able to generate a chart and to add it in the body of the message and also as attachment .

Program Y_R_EITAN_TEST_10_06 attached use cl_document_bcs and cl_igs_chart_engine .

cl_igs_chart_engine recieve XML documents as input so cl_ixml used .

In order to display the image in the body of the message cl_gbt_multirelated_service is used this allow the use of <img src=”cid:<image name>“> tag .

FORM do_igs_chart is reponsible to return the image as xstring .

The program is also send a smart form as attachment. (A bonus….. 😛 )

/wp-content/uploads/2014/08/screenshot_01_515124.png

/wp-content/uploads/2014/08/screenshot_02_515125.png

/wp-content/uploads/2014/08/screenshot_03_515162.png

/wp-content/uploads/2014/08/screenshot_04_515163.png

2014/08/28 Increase the picture size to 600X800

attachment chart.PNG

To report this post you need to login first.

23 Comments

You must be Logged on to comment or reply to a post.

  1. Danny Roussel

    indeed great post!

    I have tried to extend your exemple so that 1 chart contains 4 categories (EquipeA/Equipe2/Euipe3/Equipe4) , and every catergory has 4 series.

    Although the data is correctly shown, I don’t see the correct labels for the series, and all coloums of 1 category has the same colour…

    I must be doing something wrong…but what?

    Any idea please?

    Chart1.png

    (0) 
    1. Eitan Rosenberg Post author

      Hi,

      Thank you.

      I sugest you DL Chart Designer 

      See note 2072652 (SAP Chart Designer cannot be downloaded from SAP service marketplace)

      Also search for Chart Designer:

      In the zip file in the note there is a book XML Format.pdf

      Are you looking for somthing like that ?

      From page 5

      Regards.

      (0) 
      1. Danny Roussel

        Hi Eitan,

        thanks for your reply!

        I know the chartDesigner but when I save the customizing and and then re-open it, the changes I’ve done (for instances using 3 series and naming these series) are gone…

        or is this a normal behaviour?

        danny

        (0) 
        1. Eitan Rosenberg Post author

          Hi,

          I am not sure I understand what you are doing.

          I simply use the designer as prototype tool so later I can recreate the XML using if_ixml .

          Have a look at program GRAPHICS_GUI_CE_DEMO .

          Regards.

          (0) 
          1. Danny Roussel

            Eitan,

            I know this program…

            I was just wandering how I can use the customizing output from the Chart Designer for exemple in your program…

            danny

            (0) 
            1. Eitan Rosenberg Post author

              Chang the code in

              PERFORM do_igs_chart_1_cust_1

                  CHANGING

                    ob_igs_chart_engine

                    ob_ixml .

              so will it will use your xml.

              Regards.

              (0) 
              1. Danny Roussel

                That’s correct, but in your exemple you have only 1 serie for 1 category.

                I want to have several series (=columns) in 1 category…, and several categories…

                regards,

                Danny

                (0) 
  2. Lucas Leite Praça Gonçalves

    Hi Eitan,

        Please could help me I am using “Y_R_EITAN_TEST_10_06” very good program as an example for a development where the logo will be inserted in the email body and I am now having difficulty inserting special characters in the email body! 

      You could help me I do so that the special character is sent along with the logo correctly?

    Thank you very much,

    Regards,

    Lucas Leite

    (0) 
  3. Danny Roussel

    Beautifull job!!

    I have optimised it a bit:

    I have created a standard abap for formating data coming from whatever program: it receives the graph names, the bar names, the data for every bar and also to whom it must be mail (several users are possible).

    Just give me an email if interessed ( danny at libeert dot com )

    Regards,

    Danny

    ExGraph.png

    (0) 
  4. CHARLES FEERICK

    Hi Eitan,

    I’d like to give your solution a try, but I don’t see how I can download your program  Y_R_EITAN_TEST_10_06 to review.  I searched the site and contacted SAP support thinking my ‘S’ id was missing some authorizations, but without luck.  Was hoping you could point me in the right direction on how to download it.

    Happy Holidays!
    Matt

    (0) 
  5. Eitan Rosenberg Post author

    Hi all

    It seems that when the transition for the new site cause a lot of damage .

    A lot of attachments got deleted

    Regards.

    Here is the code:

    REPORT  y_r_eitan_test_10_06 .
    
    TYPE-POOLS: abap .
    
    TABLES: sflight .
    
    CONSTANTS: image_name_01 TYPE string VALUE 'Sailing.jpg' .
    CONSTANTS: image_name_02 TYPE string VALUE 'chart_01.jpg' .
    CONSTANTS: c_series_01 TYPE string VALUE 'series_01' .
    
    *----------------------------------------------------------------------*
    TYPES: BEGIN OF tp_suma_1 .
            INCLUDE TYPE sflight AS sflight RENAMING WITH SUFFIX _sflight .
    TYPES: END OF tp_suma_1 .
    
    TYPES: tp_suma_1_tab TYPE TABLE OF tp_suma_1  .
    *----------------------------------------------------------------------*
    *----------------------------------------------------------------------*
    CLASS cl_htm DEFINITION .
    
      PUBLIC SECTION.
    
        CONSTANTS: cr_lf TYPE string VALUE '<cr_lf>' .
    
        DATA: htm_string TYPE string .
    
        METHODS: append
            IMPORTING fragment TYPE any .
    
      PRIVATE SECTION.
    
        METHODS: edit_value
            IMPORTING fragment TYPE any
            CHANGING  buffer   TYPE string .
    
    ENDCLASS.                    "cl_htm DEFINITION
    *----------------------------------------------------------------------*
    *----------------------------------------------------------------------*
    CLASS cl_htm IMPLEMENTATION.
    *----------------------------------------------------------------------*
      METHOD: append .
    
        DATA: buffer  TYPE string .
    
        me->edit_value( EXPORTING fragment = fragment CHANGING buffer = buffer ) .
    
        CONDENSE buffer .
    
        CONCATENATE htm_string buffer INTO htm_string .
    
      ENDMETHOD.                    "append
    *----------------------------------------------------------------------*
      METHOD: edit_value .
    
        DATA: inttype TYPE inttype .
    
        DESCRIBE FIELD fragment TYPE inttype .
    
        DATA: edited TYPE so_text255 .
    
        WRITE fragment TO edited LEFT-JUSTIFIED .
    
        IF buffer EQ cl_htm=>cr_lf .
          RETURN .
        ENDIF .
    
        CASE inttype .
          WHEN 'I' OR 'P' .
            IF fragment LT 0 .
              WRITE fragment TO edited+1 NO-SIGN LEFT-JUSTIFIED .
              WRITE '-' TO edited+0(1) .
              buffer = edited .
            ENDIF .
          WHEN OTHERS .
            buffer = fragment .
        ENDCASE .
    
      ENDMETHOD.                    "edit_minus_value
    *----------------------------------------------------------------------*
    ENDCLASS.                    "cl_htm IMPLEMENTATION
    *----------------------------------------------------------------------*
    *----------------------------------------------------------------------*
    CLASS cl_str DEFINITION .
    
      PUBLIC SECTION .
    
        CLASS-METHODS: to_string
                       IMPORTING input TYPE any
                       RETURNING value(output) TYPE string .
    
    ENDCLASS .                    "cl_string DEFINITION
    *----------------------------------------------------------------------*
    *----------------------------------------------------------------------*
    CLASS cl_str IMPLEMENTATION.
    
      METHOD: to_string .
    
        DATA: buffer TYPE char64 .
        DATA: string TYPE string .
    
        WRITE input TO buffer LEFT-JUSTIFIED.
    
        REPLACE ALL OCCURRENCES OF ',' IN buffer WITH '' .
    
        output = buffer .
    
      ENDMETHOD .                    "to_string
    
    ENDCLASS .                    "cl_str IMPLEMENTATION
    *----------------------------------------------------------------------*
    *----------------------------------------------------------------------*
    SELECTION-SCREEN BEGIN OF BLOCK block02 WITH FRAME .
    
    PARAMETERS: p_fname  TYPE ssfscreen-fname DEFAULT 'SF_EXAMPLE_01' .
    
    SELECTION-SCREEN SKIP .
    
    PARAMETERS: p_sndr_1 TYPE adsmtp-smtp_addr .
    
    SELECTION-SCREEN SKIP .
    
    PARAMETERS: p_rcpn_1 TYPE adsmtp-smtp_addr .
    
    SELECTION-SCREEN SKIP .
    
    PARAMETERS: p_sbjct TYPE so_obj_des .
    
    SELECTION-SCREEN SKIP .
    
    SELECT-OPTIONS:  s_carrid   FOR sflight-carrid .
    SELECT-OPTIONS:  s_connid   FOR sflight-connid .
    SELECT-OPTIONS:  s_fldate   FOR sflight-fldate .
    
    
    SELECTION-SCREEN SKIP .
    
    PARAMETERS: p_padest TYPE tsp03-padest OBLIGATORY .
    
    SELECTION-SCREEN SKIP .
    
    PARAMETERS: p_debug  TYPE debug_flg .
    SELECTION-SCREEN END OF BLOCK block02 .
    *----------------------------------------------------------------------*
    
    INITIALIZATION .
      PERFORM at_initialization .
    
    AT SELECTION-SCREEN OUTPUT .
      PERFORM at_selection_screen_output .
    
    AT SELECTION-SCREEN .
      PERFORM at_selection_screen_input .
    
    START-OF-SELECTION .
      PERFORM at_start_of_selection .
    
    *----------------------------------------------------------------------*
    FORM at_initialization .
    
      DATA: st_address TYPE bapiaddr3 .
    
      DATA: it_return   TYPE bapirettab .
      DATA: st_defaults TYPE bapidefaul .
    
      CALL FUNCTION 'BAPI_USER_GET_DETAIL'
        EXPORTING
          username = sy-uname
        IMPORTING
          address  = st_address
          defaults = st_defaults
        TABLES
          return   = it_return.
    
      p_sndr_1 = st_address-e_mail .
      p_rcpn_1 = st_address-e_mail .
    
      p_padest = st_defaults-spld .
    
      CONCATENATE 'Hi there-' sy-datum '-' sy-uzeit '(EX)' INTO p_sbjct .
    
      DATA: it_seltexts TYPE TABLE OF rsseltexts .
      DATA: st_seltexts LIKE LINE OF it_seltexts .
    
      st_seltexts-name = 'P_SNDR_1' .
      st_seltexts-kind = 'P' .
      st_seltexts-text = 'Sender mail '  .
      APPEND st_seltexts TO it_seltexts .
    
      st_seltexts-name = 'P_RCPN_1' .
      st_seltexts-kind = 'P' .
      st_seltexts-text = 'Recipient mail 1 '  .
      APPEND st_seltexts TO it_seltexts .
    
      CALL FUNCTION 'SELECTION_TEXTS_MODIFY'
        EXPORTING
          program                     = sy-cprog
        TABLES
          seltexts                    = it_seltexts
        EXCEPTIONS
          program_not_found           = 1
          program_cannot_be_generated = 2
          OTHERS                      = 3.
    
    ENDFORM .                    "at_initialization
    *----------------------------------------------------------------------*
    FORM at_selection_screen_output .
    ENDFORM .                    "at_selection_screen_output
    *----------------------------------------------------------------------*
    FORM at_selection_screen_input .
    ENDFORM .                    "at_selection_screen_input
    *----------------------------------------------------------------------*
    FORM at_start_of_selection .
    
      PERFORM mail_1_main .
    
    ENDFORM .                    "at_start_of_selection
    *----------------------------------------------------------------------*
    FORM mail_1_main .
    
      DATA: ob_gbt_multirelated_service TYPE REF TO cl_gbt_multirelated_service.
    
      CREATE OBJECT ob_gbt_multirelated_service .
    
      PERFORM mail_1_prep_1
        CHANGING
          ob_gbt_multirelated_service .
    
      PERFORM mail_1_prep_2
        CHANGING
          ob_gbt_multirelated_service .
    
      PERFORM mail_1_prep_3
      CHANGING
        ob_gbt_multirelated_service .
    
      DATA: ob_document_bcs TYPE REF TO cl_document_bcs.
    
      ob_document_bcs = cl_document_bcs=>create_from_multirelated(
        i_subject = p_sbjct
        i_multirel_service = ob_gbt_multirelated_service ).
    
      PERFORM mail_1_prep_4
        CHANGING
          ob_document_bcs .
    
      PERFORM mail_1_prep_5
        CHANGING
          ob_document_bcs .
    
      DATA: ob_bcs TYPE        REF TO cl_bcs.
      DATA: ob_sapuser_bcs     TYPE REF TO cl_sapuser_bcs.
      DATA: ob_cam_address_bcs TYPE REF TO cl_cam_address_bcs .
    
      ob_bcs = cl_bcs=>create_persistent( ).
    
      CALL METHOD ob_bcs->set_document( ob_document_bcs ).
    
      ob_cam_address_bcs = cl_cam_address_bcs=>create_internet_address( p_sndr_1 ).
    
      CALL METHOD ob_bcs->set_sender
        EXPORTING
          i_sender = ob_cam_address_bcs.
    
      DATA: smtp_addr TYPE adsmtp-smtp_addr .
    
      ob_cam_address_bcs = cl_cam_address_bcs=>create_internet_address( p_rcpn_1 ).
    
      CALL METHOD ob_bcs->add_recipient
        EXPORTING
          i_recipient = ob_cam_address_bcs.
    
      DATA: result TYPE abap_bool .
    
      CALL METHOD ob_bcs->send
        EXPORTING
          i_with_error_screen = abap_true
        RECEIVING
          result              = result.
    
      COMMIT WORK .
    
    ENDFORM .                    "mail_1_main
    *----------------------------------------------------------------------*
    FORM mail_1_prep_1
      CHANGING
        ob_gbt_multirelated_service TYPE REF TO cl_gbt_multirelated_service .
    
      DATA: content TYPE xstring.
    
      PERFORM mail_1_image_1
        CHANGING
          content .
    
      DATA: ob_htm TYPE REF TO cl_htm .
    
      CREATE OBJECT ob_htm .
    
      CALL METHOD ob_htm->append
      EXPORTING
        fragment = :
          '<P>'  ,
          'Hi there' ,
          '</P>' .
    
    * Works in outlook.
    
      CALL METHOD ob_htm->append
        EXPORTING
          fragment = :
            '<img src="cid:' , image_name_01 , '" alt="' , image_name_01 , '" align="middle" />'.
    
      CALL METHOD ob_htm->append
        EXPORTING
          fragment = '<br><br>'.
    
      CALL METHOD ob_htm->append
        EXPORTING
          fragment = :
            '<img src="cid:' , image_name_02 , '" alt="' , image_name_02 , '" align="middle" />'.
    
      CALL METHOD ob_htm->append
        EXPORTING
          fragment = '<br><br>'.
    
    * Does not work in outlook
    
    *  DATA: encoded TYPE string .
    *
    *  CALL METHOD cl_http_utility=>if_http_utility~encode_x_base64
    *    EXPORTING
    *      unencoded = content
    *    RECEIVING
    *      encoded   = encoded.
    
    *  CALL METHOD ob_htm->append
    *    EXPORTING
    *      fragment = :
    *        '<img src="data:image/PNG;base64,' , encoded  ,
    *        ' "alt="Happy birthday" align="middle" width="304" height="228" />'.
    
      DATA: it_soli TYPE soli_tab .
    
      CALL METHOD cl_bcs_convert=>string_to_soli
        EXPORTING
          iv_string = ob_htm->htm_string
        RECEIVING
          et_soli   = it_soli.
    
      CALL METHOD ob_gbt_multirelated_service->set_main_html
        EXPORTING
          content     = it_soli
          filename    = 'main_html.htm'
          description = 'main_html.htm'.  "Title
    
    *  CALL METHOD cl_document_bcs=>create_document
    *    EXPORTING
    *      i_type    = 'HTM'
    *      i_subject = p_sbjct
    *      i_text    = it_soli
    **     i_hex     = it_solix
    *    RECEIVING
    *      result    = ob_document_bcs.
    
    ENDFORM .                    "mail_1_prep_1
    *----------------------------------------------------------------------*
    FORM mail_1_prep_2
      CHANGING
        ob_gbt_multirelated_service  TYPE REF TO cl_gbt_multirelated_service .
    
    * From http://scn.sap.com/docs/DOC-42618
    
      DATA: content TYPE xstring.
    
      PERFORM mail_1_image_1
        CHANGING
          content .
    
      DATA: it_solix TYPE solix_tab .
    
      CALL METHOD cl_bcs_convert=>xstring_to_solix
        EXPORTING
          iv_xstring = content
        RECEIVING
          et_solix   = it_solix.
    
      DATA: description TYPE so_obj_des .
      DATA: obj_len     TYPE so_obj_len .
    
      obj_len = XSTRLEN( content ).
    
      CALL METHOD ob_gbt_multirelated_service->add_binary_part
        EXPORTING
          content      = it_solix
          filename     = image_name_01
          extension    = 'JPG'
          description  = description
          content_type = 'image/jpg'
          length       = obj_len
          content_id   = image_name_01.
    
    ENDFORM .                    "mail_1_prep_2
    *----------------------------------------------------------------------*
    FORM mail_1_prep_3
      CHANGING
        ob_gbt_multirelated_service  TYPE REF TO cl_gbt_multirelated_service .
    
      DATA: xstring TYPE xstring.
    
      PERFORM do_igs_chart
        CHANGING
          xstring .
    
      DATA: it_solix TYPE solix_tab .
    
      CALL METHOD cl_bcs_convert=>xstring_to_solix
        EXPORTING
          iv_xstring = xstring
        RECEIVING
          et_solix   = it_solix.
    
      DATA: description TYPE so_obj_des .
      DATA: obj_len     TYPE so_obj_len .
    
      obj_len = XSTRLEN( xstring ).
    
      CALL METHOD ob_gbt_multirelated_service->add_binary_part
        EXPORTING
          content      = it_solix
          filename     = image_name_02
          extension    = 'PNG'
          description  = description
          content_type = 'image/PNG'
          length       = obj_len
          content_id   = image_name_02.
    
    ENDFORM .                    "mail_1_prep_3
    *----------------------------------------------------------------------*
    FORM mail_1_prep_4
      CHANGING
        ob_document_bcs TYPE REF TO cl_document_bcs .
    
      DATA: xstring TYPE xstring.
    
      PERFORM do_igs_chart
        CHANGING
          xstring .
    
      DATA: it_solix TYPE solix_tab .
    
      CALL METHOD cl_bcs_convert=>xstring_to_solix
        EXPORTING
          iv_xstring = xstring
        RECEIVING
          et_solix   = it_solix.
    
      DATA: attachment_subject TYPE so_obj_des .
    
      MESSAGE s000(oo) WITH 'attachment chart' space INTO attachment_subject .
    
      TRY.
          CALL METHOD ob_document_bcs->add_attachment
            EXPORTING
              i_attachment_type    = 'PNG'
              i_attachment_subject = attachment_subject
              i_att_content_hex    = it_solix.
        CATCH cx_document_bcs .
      ENDTRY.
    
    ENDFORM .                    "mail_1_prep_4
    *----------------------------------------------------------------------*
    FORM mail_1_prep_5
      CHANGING
        ob_document_bcs TYPE REF TO cl_document_bcs .
    
      DATA: customer    TYPE  scustom .
      DATA: bookings    TYPE  ty_bookings .
      DATA: connections TYPE  ty_connections   .
    
      DATA: formname TYPE tdsfname .
      DATA: fm_name	 TYPE rs38l_fnam .
    
      formname = p_fname .
    
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = p_fname
        IMPORTING
          fm_name            = fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
    
      IF sy-subrc NE 0 .
        RETURN .
      ENDIF .
    
      DATA: st_control_parameters TYPE ssfctrlop .
      DATA: st_output_options     TYPE ssfcompop .
      DATA: st_job_output_info    TYPE ssfcrescl .
    
      st_output_options-tddest        = p_padest  .
    
      st_control_parameters-device    = 'PRINTER' .
    
    *  st_control_parameters-no_dialog = abap_true .
      st_control_parameters-getotf    = abap_true .
    
      CALL FUNCTION fm_name
        EXPORTING
          control_parameters = st_control_parameters
          output_options     = st_output_options
          customer           = customer
          bookings           = bookings
          connections        = connections
        IMPORTING
          job_output_info    = st_job_output_info
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
    
      IF sy-subrc EQ 4 .
        RETURN .
      ENDIF .
    
      IF sy-subrc NE 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    
      DATA: bin_file TYPE xstring .
      DATA: it_lines_dummy TYPE tline_tab .
      DATA: bin_filesize TYPE i .
    
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
        IMPORTING
          bin_file              = bin_file
          bin_filesize          = bin_filesize
        TABLES
          otf                   = st_job_output_info-otfdata
          lines                 = it_lines_dummy
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4
          OTHERS                = 5.
    
      DATA: it_solix TYPE solix_tab .
    
      CALL METHOD cl_bcs_convert=>xstring_to_solix
        EXPORTING
          iv_xstring = bin_file
        RECEIVING
          et_solix   = it_solix.
    
      DATA: attachment_subject TYPE so_obj_des .
    
      MESSAGE s000(oo) WITH 'attachment PDF hex' space INTO attachment_subject .
    
      TRY.
          CALL METHOD ob_document_bcs->add_attachment
            EXPORTING
              i_attachment_type    = 'pdf'
              i_attachment_subject = attachment_subject
              i_att_content_hex    = it_solix.
        CATCH cx_document_bcs .
      ENDTRY.
    
    ENDFORM .                    "mail_1_prep_5
    *----------------------------------------------------------------------*
    
    *----------------------------------------------------------------------*
    FORM mail_1_image_1
      CHANGING
        content TYPE xstring.
    
      DATA: ob_mr_api TYPE REF TO if_mr_api .
    
      ob_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).
    
      DATA: i_url TYPE string VALUE '/SAP/PUBLIC/AES/SAP Sailing.jpg' .
    
      CALL METHOD ob_mr_api->get
        EXPORTING
          i_url              = i_url
        IMPORTING
    *     e_is_folder        = is_folder
          e_content          = content
    *     e_loio             = l_loio
        EXCEPTIONS
          parameter_missing  = 1
          error_occured      = 2
          not_found          = 3
          permission_failure = 4
          OTHERS             = 5 .
    
    ENDFORM .                    "mail_1_image_1
    *----------------------------------------------------------------------*
    FORM get_suma_1
      CHANGING
        it_suma_1 TYPE tp_suma_1_tab .
    
      CLEAR: it_suma_1[] .
    
      DATA: it_sflight TYPE flighttab .
    
      SELECT * INTO TABLE it_sflight
      FROM sflight
      WHERE
        carrid IN s_carrid AND
        connid IN s_connid AND
        fldate IN s_fldate .
    
      FIELD-SYMBOLS: <st_sflight> LIKE LINE OF it_sflight .
    
    
    
      DATA: st_suma_1 LIKE LINE OF it_suma_1 .
    
      LOOP AT it_sflight ASSIGNING <st_sflight> .
    
        CLEAR st_suma_1 .
    
        st_suma_1-sflight = <st_sflight> .
    
        CLEAR: st_suma_1-sflight-fldate,
               st_suma_1-sflight-connid,
               st_suma_1-sflight-planetype ,
               st_suma_1-sflight-currency .
    
        COLLECT st_suma_1 INTO it_suma_1 .
    
      ENDLOOP .
    
    ENDFORM .                                                   "get_suma_1
    *----------------------------------------------------------------------*
    FORM do_igs_chart
      CHANGING
        xstring TYPE xstring.
    
      DATA: ob_igs_chart_engine TYPE REF TO cl_igs_chart_engine .
      DATA: ob_ixml             TYPE REF TO if_ixml .
    
      CREATE OBJECT ob_igs_chart_engine
        EXPORTING
          destination = 'IGS_RFC_DEST'.
    
      ob_ixml = cl_ixml=>create( ).
    
      PERFORM do_igs_chart_1
        CHANGING
          ob_igs_chart_engine
          ob_ixml .
    
      CALL METHOD ob_igs_chart_engine->execute .
    
      DATA: it_image_mime TYPE w3mimetabtype .
      DATA: image_size TYPE w3param-cont_len  ,
            image_type TYPE w3param-cont_type .
    
      CALL METHOD ob_igs_chart_engine->get_image
        IMPORTING
          image      = it_image_mime
          image_size = image_size
          image_type = image_type.
    
      FIELD-SYMBOLS: <st_image_mime> LIKE LINE OF it_image_mime .
    
      LOOP AT it_image_mime ASSIGNING <st_image_mime>.
        CONCATENATE xstring <st_image_mime>-line INTO xstring IN BYTE MODE.
      ENDLOOP.
    
    ENDFORM .                    "do_IGS_chart
    *----------------------------------------------------------------------*
    FORM do_igs_chart_1
      CHANGING
        ob_igs_chart_engine TYPE REF TO cl_igs_chart_engine
        ob_ixml TYPE REF TO if_ixml .
    
      DATA: it_suma_1 TYPE tp_suma_1_tab .
    
      PERFORM get_suma_1
        CHANGING
          it_suma_1 .
    
      PERFORM do_igs_chart_1_data_1
        USING
          it_suma_1
        CHANGING
          ob_igs_chart_engine
          ob_ixml .
    
      PERFORM do_igs_chart_1_cust_1
        CHANGING
          ob_igs_chart_engine
          ob_ixml .
    
    ENDFORM .                    "do_gui_chart_1
    *----------------------------------------------------------------------*
    FORM do_igs_chart_1_data_1
       USING
         it_suma_1 TYPE tp_suma_1_tab
       CHANGING
         ob_igs_chart_engine TYPE REF TO cl_igs_chart_engine
         ob_ixml             TYPE REF TO if_ixml .
    
      DATA: ob_ixml_document    TYPE REF TO if_ixml_document ,
              ob_ixml_encoding    TYPE REF TO if_ixml_encoding .
    
      DATA: ob_simplechartdata  TYPE REF TO if_ixml_element ,
            ob_categories       TYPE REF TO if_ixml_element ,
            ob_category         TYPE REF TO if_ixml_element ,
            ob_series           TYPE REF TO if_ixml_element ,
            ob_point            TYPE REF TO if_ixml_element ,
            ob_value            TYPE REF TO if_ixml_element ,
            l_string            TYPE string .
    
      ob_ixml_document = ob_ixml->create_document( ).
    
      ob_ixml_encoding = ob_ixml->create_encoding(
            byte_order    = if_ixml_encoding=>co_little_endian
            character_set = 'utf-8' ) .
    
      ob_ixml_document->set_encoding( ob_ixml_encoding ).
    
      ob_simplechartdata = ob_ixml_document->create_simple_element(
                name = 'ChartData' parent = ob_ixml_document ).
    
      ob_categories = ob_ixml_document->create_simple_element(
                name = 'Categories' parent = ob_simplechartdata ) .
    
      FIELD-SYMBOLS: <st_suma_1> LIKE LINE OF it_suma_1 .
    
      ob_series = ob_ixml_document->create_simple_element(
               name = 'Series' parent = ob_simplechartdata ).
      ob_series->set_attribute( name = 'label' value = 'Occupied seats in economy class' ).
      ob_series->set_attribute( name = 'customizing' value = c_series_01 ).
    
      DATA: a_string TYPE string .
    
      LOOP AT it_suma_1 ASSIGNING <st_suma_1> .
    
        ob_category = ob_ixml_document->create_simple_element(
                  name = 'Category' parent = ob_categories ).
    
        a_string = cl_str=>to_string( <st_suma_1>-sflight-carrid ) .
        ob_category->if_ixml_node~set_value( a_string ) .
    
        ob_point = ob_ixml_document->create_simple_element(
                  name = 'Point' parent = ob_series ).
    
        a_string = cl_str=>to_string( <st_suma_1>-sflight-seatsocc ) .
    
        CONCATENATE 'Seats = ' a_string INTO a_string RESPECTING BLANKS .
    
        ob_point->set_attribute( name = 'label' value = a_string ) .
    
        ob_value = ob_ixml_document->create_simple_element(
                  name = 'Value' parent = ob_point ).
    
        ob_value->set_attribute( name = 'Type' value = 'y' ) .
    
        a_string = cl_str=>to_string( <st_suma_1>-sflight-seatsocc ) .
        ob_value->if_ixml_node~set_value( a_string ).
    
      ENDLOOP .
    
      ob_igs_chart_engine->set_data( data_doc = ob_ixml_document ) .
    
    ENDFORM .                    "do_chart_1_data_2
    *----------------------------------------------------------------------*
    FORM do_igs_chart_1_cust_1
      CHANGING
        ob_igs_chart_engine TYPE REF TO cl_igs_chart_engine
        ob_ixml             TYPE REF TO if_ixml .
    
      DATA: ob_ixml_document    TYPE REF TO if_ixml_document ,
            ob_ixml_encoding    TYPE REF TO if_ixml_encoding .
    
      DATA: ob_sapchartcustomizing  TYPE REF TO if_ixml_element ,
            ob_globalsettings       TYPE REF TO if_ixml_element ,
            ob_defaults             TYPE REF TO if_ixml_element ,
            ob_charttype            TYPE REF TO if_ixml_element ,
            ob_elements             TYPE REF TO if_ixml_element ,
            ob_charttypes           TYPE REF TO if_ixml_element ,
            ob_columns              TYPE REF TO if_ixml_element ,
            ob_values               TYPE REF TO if_ixml_element ,
            ob_series               TYPE REF TO if_ixml_element ,
            ob_element              TYPE REF TO if_ixml_element ."Reused as leaf
    
      ob_ixml_document = ob_ixml->create_document( ).
    
      ob_ixml_encoding = ob_ixml->create_encoding(
            byte_order    = if_ixml_encoding=>co_little_endian
            character_set = 'utf-8' ) .
    
      ob_ixml_document->set_encoding( ob_ixml_encoding ) .
    
      ob_sapchartcustomizing = ob_ixml_document->create_simple_element(
               name = 'SAPChartCustomizing' parent = ob_ixml_document ) .
      ob_sapchartcustomizing->set_attribute( name = 'version' value = '2.0' ) .
    
      ob_globalsettings = ob_ixml_document->create_simple_element(
               name = 'GlobalSettings' parent = ob_sapchartcustomizing ) .
    
      ob_element = ob_ixml_document->create_simple_element(
                 name = 'FileType' parent = ob_globalsettings ) .
      ob_element->if_ixml_node~set_value( 'PNG' ) .
    
      ob_element = ob_ixml_document->create_simple_element(
                 name = 'Width' parent = ob_globalsettings ) .
      ob_element->if_ixml_node~set_value( '800' ) .
    
      ob_element = ob_ixml_document->create_simple_element(
                 name = 'Height' parent = ob_globalsettings ) .
      ob_element->if_ixml_node~set_value( '600' ) .
    
      ob_element = ob_ixml_document->create_simple_element(
              name = 'Dimension' parent = ob_globalsettings ) .
      ob_element->if_ixml_node~set_value( 'Three' ) .
    * ob_element->if_ixml_node~set_value( 'Two' ) .
    
      ob_element = ob_ixml_document->create_simple_element(
              name = 'ColorPalette' parent = ob_globalsettings ) .
      ob_element->if_ixml_node~set_value( 'Streamline' ) .
    
      ob_defaults = ob_ixml_document->create_simple_element(
               name = 'Defaults' parent = ob_globalsettings ) .
    
      ob_charttype = ob_ixml_document->create_simple_element(
               name = 'ChartType' parent = ob_defaults ) .
    * ob_charttype->if_ixml_node~set_value( 'Doughnut' ).
    * ob_charttype->if_ixml_node~set_value( 'Pie' ).
    * ob_charttype->if_ixml_node~set_value( 'Lines' ).
      ob_charttype->if_ixml_node~set_value( 'Columns' ) .
    
      ob_elements = ob_ixml_document->create_simple_element(
               name = 'Elements' parent = ob_sapchartcustomizing ) .
    
      ob_charttypes = ob_ixml_document->create_simple_element(
             name = 'ChartTypes' parent = ob_elements ) .
    
      ob_columns = ob_ixml_document->create_simple_element(
             name = 'Columns' parent = ob_charttypes ) .
    
      ob_element = ob_ixml_document->create_simple_element(
              name = 'VaryColorsByPoint' parent = ob_columns ) .
      ob_element->if_ixml_node~set_value( 'true' ) .
    
      """"
      ob_values = ob_ixml_document->create_simple_element(
               name = 'Values' parent = ob_sapchartcustomizing ) .
    
      ob_series = ob_ixml_document->create_simple_element(
              name = 'Series' parent = ob_values ) .
    
      ob_series->set_attribute( name = 'id' value = c_series_01 ) .
    
      ob_element = ob_ixml_document->create_simple_element(
             name = 'ShowLabel' parent = ob_series ) .
      ob_element->if_ixml_node~set_value( 'true' ) .
    
      ob_igs_chart_engine->set_customizing( custom_doc = ob_ixml_document ) .
    
    ENDFORM .                    "do_chart_1_cust_1

     

    (0) 

Leave a Reply