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...
</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
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...