Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Create Gantt-Chart by using class CL_GUI_CHART_ENGINE

o_seifer
Explorer
0 Kudos

Hello,

my goal is to create a Gantt-Chart by using CL_GUI_CHART_ENGINE .

I´ve copied report GRAPHICS_GUI_CE_DEMO and tried to modify its XML data in order to get a Gant-Chart

but I failed. I´ve also used SAP Chart-Designer to get an executable customizing for the chart engine

but this way was unsuccesful too. Every time the chart shows no data...

Is there anyone who has an example (code, docu, xml) to create a Gantt-Chart?

Thank you.

Kind regards,

Oliver

Edited by: Oliver Seifer on Mar 24, 2011 2:16 PM

1 ACCEPTED SOLUTION

former_member182670
Contributor
0 Kudos

Hi,

Please try this sample code. You'll need a customizing from ChartDesigner to launch it.

I have hardcoded sample data but you can take it further from here.

Please use following settings in the wizard

Step 1

Gantt

Step 2

Series Count 2

Category Count 1

Step 3

Defaults

Step 4

Defaults

Step 5

Defaults

Step 6

Defaults

Step 7

Save as...


DATA lt_cust_text TYPE w3htmltabtype.
  DATA lt_data_text TYPE w3htmltabtype.
  DATA wa_data_text TYPE w3html.

  IF g_ce_container IS INITIAL.
    CREATE OBJECT g_ce_container
      EXPORTING
        container_name = 'CONTAINER'.

    CREATE OBJECT g_ce_viewer
      EXPORTING
        parent = g_ce_container.

  ENDIF.

  cl_gui_frontend_services=>gui_upload(
    EXPORTING
      filename                = 'path to your customising\gant.xml'
    CHANGING
      data_tab                =     lt_cust_text
    EXCEPTIONS
      OTHERS                  = 19 ).

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  g_ce_viewer->set_customizing( data_table = lt_cust_text ).


  APPEND '<?xml version="1.0" encoding="utf-8"?>' TO lt_data_text.
  APPEND '<ChartData> ' TO lt_data_text.
  APPEND '<Categories><Category>Category 1</Category></Categories>' TO lt_data_text.
  APPEND '<Series customizing="Series1">' TO lt_data_text.
  APPEND '<Point>' TO lt_data_text.
  APPEND '<Value type="time">20000301</Value>' TO lt_data_text.
  APPEND '<Value type="time">20000305</Value>' TO lt_data_text.
  APPEND '<Value type="time">20000310</Value>' TO lt_data_text.
  APPEND '<Value type="time">20000401</Value>' TO lt_data_text.
  APPEND '</Point>' TO lt_data_text.
  APPEND '</Series>' TO lt_data_text.
  APPEND '<Series customizing="Series2">' TO lt_data_text.
  APPEND '<Point>' TO lt_data_text.
  APPEND '<Value type="time">20000302</Value>' TO lt_data_text.
  APPEND '<Value type="time">20000319</Value>' TO lt_data_text.
  APPEND '</Point>' TO lt_data_text.
  APPEND '</Series>' TO lt_data_text.
  APPEND '</ChartData>' TO lt_data_text.

  g_ce_viewer->set_data( data_table = lt_data_text ).
  g_ce_viewer->render( ).

2 REPLIES 2

former_member182670
Contributor
0 Kudos

Hi,

Please try this sample code. You'll need a customizing from ChartDesigner to launch it.

I have hardcoded sample data but you can take it further from here.

Please use following settings in the wizard

Step 1

Gantt

Step 2

Series Count 2

Category Count 1

Step 3

Defaults

Step 4

Defaults

Step 5

Defaults

Step 6

Defaults

Step 7

Save as...


DATA lt_cust_text TYPE w3htmltabtype.
  DATA lt_data_text TYPE w3htmltabtype.
  DATA wa_data_text TYPE w3html.

  IF g_ce_container IS INITIAL.
    CREATE OBJECT g_ce_container
      EXPORTING
        container_name = 'CONTAINER'.

    CREATE OBJECT g_ce_viewer
      EXPORTING
        parent = g_ce_container.

  ENDIF.

  cl_gui_frontend_services=>gui_upload(
    EXPORTING
      filename                = 'path to your customising\gant.xml'
    CHANGING
      data_tab                =     lt_cust_text
    EXCEPTIONS
      OTHERS                  = 19 ).

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  g_ce_viewer->set_customizing( data_table = lt_cust_text ).


  APPEND '<?xml version="1.0" encoding="utf-8"?>' TO lt_data_text.
  APPEND '<ChartData> ' TO lt_data_text.
  APPEND '<Categories><Category>Category 1</Category></Categories>' TO lt_data_text.
  APPEND '<Series customizing="Series1">' TO lt_data_text.
  APPEND '<Point>' TO lt_data_text.
  APPEND '<Value type="time">20000301</Value>' TO lt_data_text.
  APPEND '<Value type="time">20000305</Value>' TO lt_data_text.
  APPEND '<Value type="time">20000310</Value>' TO lt_data_text.
  APPEND '<Value type="time">20000401</Value>' TO lt_data_text.
  APPEND '</Point>' TO lt_data_text.
  APPEND '</Series>' TO lt_data_text.
  APPEND '<Series customizing="Series2">' TO lt_data_text.
  APPEND '<Point>' TO lt_data_text.
  APPEND '<Value type="time">20000302</Value>' TO lt_data_text.
  APPEND '<Value type="time">20000319</Value>' TO lt_data_text.
  APPEND '</Point>' TO lt_data_text.
  APPEND '</Series>' TO lt_data_text.
  APPEND '</ChartData>' TO lt_data_text.

  g_ce_viewer->set_data( data_table = lt_data_text ).
  g_ce_viewer->render( ).

o_seifer
Explorer
0 Kudos

Hi Tomek,

thank you!!! It works.

Now I have to focus on the customizing of the chart.

Kind regards,

Oliver