Skip to Content

Now for the charts


In the first part I thought about what and how to measure and now I propose how to show the results.

When I first created some performance test reports I always used “WRITE: …” to print the results, then copy&paste to excel and finally created a chart. I thought that graphics in ABAP are a real bad thing and at first I was correct: using the GFW is a real moloch [[babylon translation tool: “a tyrannical power to be propitiated by human subservience or sacrifice”]]. I asked some colleagues and they came up with the idea of using the chart engine. Very nice! Additionally we also want to have the data available as excel-similar table: ALV. Both on one screen and of course the chart and ALV are separated so we can move the separator – a splitter container is needed.


Chart engine


This thing is delivered with 6.40 and is very simple to use – just create an XML with the chart data and some style info and voila.

For an overview go to help.sap.com and search in the SAP NetWeaver area for “chart engine” or go to “BC-FES-GRA/Chart Engine”.</p>

Set up


1. create a report and add a screen with OK-code and a custom container. Remember to set the custom container to resizing.

2. create the DATA entries for the screen elements:

    • lo_cc TYPE REF TO cl_gui_custom_container — for the parent custom container
    • lo_splitter TYPE REF TO cl_gui_splitter_container — the container which will give us two areas to be resized, one for the ALV and one for the chart engine
    • lo_cc1 TYPE REF TO cl_gui_container — one of the containers created by the splitter
    • lo_cc2 TYPE REF TO cl_gui_container — the other one
    • lo_alv TYPE REF TO cl_gui_alv_grid — the ALV grid
    • lo_chart TYPE REF TO cl_gui_chart_engine — the chart engine

3. fill the PBO with the creation coding for the elements (the parent custom control is named “CC”)

IF lo_cc IS NOT BOUND.

    CREATE OBJECT lo_cc

      EXPORTING

        container_name = 'CC'.

    CREATE OBJECT lo_splitter

      EXPORTING

        parent = lo_cc

        rows = 2

        columns = 1.

  lo_cc1 = lo_splitter->get_container( row = 1 column = 1 ).

  lo_cc2 = lo_splitter->get_container( row = 2 column = 1 ).

  CREATE OBJECT lo_alv

    EXPORTING

      i_parent = lo_cc2.

  CREATE OBJECT lo_chart

    EXPORTING

      parent = lo_cc1.

ENDIF.

3. fill the PAI with code to end the report. (IF SY-UCOMM = ‘EXIT’. LEAVE TO SCREEN 0. ENDIF. or something like that).

You now can run this report and it shows something! (If you did not forget to call the screen…) And perhaps you might add some code for exceptions/sy-subrc…
image
</p>

Chart engine data


Now for the format of the data and how to show data:

The chart engine uses an XML interface instead of the normal ABAP way with tables/structures. The XML you have to create can simply be created with CONCATENATE or the XML framework. For the measurement report I use the simple way and just CONCATENATE.

There are two XMLs we create: one with format data like “show lines” or “show 3D” and one XML with the results of the measurements.


Chart engine format XML


Chart engine data XML


image

You now only have to change the “Category” so it contains the x-axis ticks and the “Point/Value” to the y-ticks. That’s all.
In the results of the measurement report I will replace the x-ticks to have the number of internal table lines and the y-ticks to have the time consumed – but this we will do next time…

To report this post you need to login first.

8 Comments

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

  1. Sharad Agrawal
    Thank you Harry. This is nice weblog. I would like to bring just one thing. If you want to draw Graphs using conventional ABAP ( with out OO), you can use function modules GRAPH_2D or GRAPH_3D
    (0) 
  2. Kai Gutenkunst
    And don’t forget to download the SAP Chart Designer for creating the customizing XML interactively. Just go to Downloads in SDN – Developer or Administrator Tool – Web AS – SAP Chart Designer
    Regards, Kai
    (0) 
  3. Albert Israel
    Thanks, Harry for the wonderful blog.   I used GFW to do graphs in the old system and it was a pain.   This is so elegant, and quick.  

    Thanks, Kai for the tip.

    Albert

    (0) 
  4. Erik Thiessen

    obviously this is an old thread, but if you could, please inform me on how to change visibility of the charts. i realize this is xml and you can add customizing to your abap program, but which parameters, for example, do you have to setup for showing values on the bar graphs? and, this is only the start of questions i have. i have downloaded the graph designer and have the xml code, but adding this to abap seems very cumbersome. any help would be appreciated.

    (0) 
    1. Harry Dietz Post author

      Hi!

      Nowadays I would of course go for WebDynpro ABAP. Choose an ALV table and simply switch to charts – this should work out of the box. I would not stick with SAPGUI.

      Kind regards

      Harry

      (0) 

Leave a Reply