Graphs play a very vital role and have got great impact on business decisions. Senior Management, Clients, Customers all such stake-holders want to see information through Graphs to understand things easily. In SAP we have easy tool facility in ALV screens, but …… It has been observed that threads related to ALV Graphs are rarely seen here.
At the end of this document, members will be familiar with the basics about the ALV Graphs, as well as about various features available. I am sure certain cross-section of members will be benefited by this post through which they will be learning how to interpret the ALV data into various types of Graphs.
The features discussed in this document are largely applicable to ALVs of custom programs developed through SAP Queries or ABAP codes using fm ‘REUSE_ALV_GRID_DISPLAY‘. Things mentioned in this document are not applicable to ALV Graphs through Standard programs.
Here we start…..
How we get a Graph in ALV?
We know that Graphs need numeric fields for Y-Axis. So the ALVs not containing a single numeric field are not Graph-relevant. Also the field for which you want to plot a Graph, looks like a Numeric, but if its data type is Character, then too it is not possible to plot a Graph for this field. In other-words we can say that, the ALV Layout where there is no icon in the Application Toolbar, we will not be able to draw Graphs.
Ok…Let’s come back to the Graph possibilities. We are in the following ALV screen. Here these are 2 fields for X-Axis namely FinYr and Equipment Description. We have 4 numeric fields for Y-Axis i.e., MTBR, MTTR, TotBDns and Avlb%.
Now select the first 2 columns (for X-Axis) and 3rd column for Y axis (Means we are drawing graph for MTBR values) as shown in the picture below….
What we see in this picture is, system default scale presents only 5 bars in X-axis, for the rest we need to use horizontal Scroll (seen in the picture).
Here we start our exploration of ALV Graphs
1. To have all the Graph bars in one view (in other-words to remove horizontal scroll)
Place the Mouse pointer anywhere on the X-axis line and Right click, to get this menu.
Click on Format Axis… to get a pop-up screen. Go to the tab Scale.
Change the value shown above to as many as you want. In our case the bars are 8. So we change this value to 8. Now the graph has got rid of horizontal scroll showing a;; the Graph bars, like this.
2. The Y-Axis
We see the bar with maximum value is touching the top of the Graph area, by default setting, where we want create some room above this. This is nothing but we need to set the Y-Axis value. Our present maximum value of Y-Axis is 2400. We want to change this to say 3000.
In a similar way we did for X-axis, keep the mouse pointer anywhere on the Y-Axis line, and right click. Go to Scale tab. and …….
change the Maximum value to 3000. See the graph now.
3. Display values on the Bars:
Right click anywhere in the Plot Area to get this menu.
4. Change the Type of Graph (Say to a PIE chart)
Refer to menu picture in Point3 above. Click on chart Type and in the pop-up Select Pies.
Select the pie pattern you like, We here selected the 1st one. Now see how our Graph looks like.
We got the Pies chart but the values disappeared. Follow the procedure explained in point3 to have Values of the Pies.
A number of Chart Type are available in this section of the Menu.
5. Titles to the Graph
Now Let’s Give a Title to our Graph and Configure it. Go to the Title tab of the menu in Point3, Give the Title you want. Say ‘MTBR Values FinYr-wise in Hrs’..
You can Drag & Drop this title to anywhere in the Chart Area. Also you can configure the Font, Font Size, Color etc by Right clicking on the edges of this Title box and choosing Format Chart Title.
In a similar way you can have Titles for your Axes from the same tab (Title tab).
6. Similar Graphs can be drawn for the rest of the value fields viz., MTTR, TotBDn and Avlb% by selecting these fields as the 3rd field for Graph (First two fields being FinYr and Equipment Description for X-Axis)..
7. Multiple Value Graphs:
Many times we have a requirement for multiple parameters for Y-Axis. This suits when we have an ALV report something like:
MTBR (Hrs) Financial Year wise:
In this case: The X-Axis will have FinYr, like the present case. The Y-Axis can have all the Equipment fields. In this case there will be 3 bars with different colors above each FinYr on X-Axis. This is a very suitable case for Multi-bar Graph because of the uniformity in UOMs for all 3 bars i.e., Hrs.
No two ALV fields in our current ALV are having same UOMs for demonstrating this case, we choose two fields MTBR and Avlb%. for this demo. I’ve selected first two columns(FinYr and Equipment Description), and MTBR and Avlb% (total 4 columns) . Now upon Clicking on the Graph icon, system presented the following Graph…
Now let’s discuss about the UOM (Unit Of Measure) on the Y-Axis. When this was a graph for MTBR alone the Y-Axis unit of Hrs is OK. But when we have plotted the Avlb% also, the Maximum value of which is 100, all these bars fell within the first grid line, which is 500 high.
8. Secondary Axis:
The above is the right situation to discuss about the Secondary Axis. i.e., we will have the vertical line on the right side converted as Axis for the 2nd bar (Avlb%). For this Right click on Plot Area ….
Select Secondary Axis.
Now your Graph looks better like this. (The Secondary Axis selected automatically has 0 – 100 Range)
To have values on the Secondary Axis, select as under in the Axes tab of Chart Options.
9. Changing the Colors of Bars, Pies etc.
For this Choose this option:
10. There are other features in the Plot Area / Chart Options Menu as shown below.
Some useful features are
– In the Grid-lines Tab you can remove or set Grid lines for both Axes.
– In the Legend tab you can have the Color Legend Settings.
You may explore what is there in other 2 tabs Data Table and Options. With this we have explored almost everything in ALV Graphs.
11. Now How to Save Graphs which we configured with so much effort.:
Without closing the Graph-window in the ALV layout, click on the Save Layout button on the Application toolbar
and Save the Layout. Now your graph is saved. Any time you select this layout, the graph will be appearing, Similarly, when you save any Selection screen variant with this Layout, upon Executing the report you will be directly presented the Graph. Please read ALV Graphs : An Accidental Discovery for details.
Graphs on Sub-Totals
While replying to a member’s query, I’d recalled another feature that should be added to this document., i.e., Graphs on sub totals
Suppose I try to draw a graph between Equipment and Breakdown duration for IW28 ALV by giving list of Equipments and range of Malfunction Start Date. In this case the output is likely to have several line items for a single equipment. The Graph (X-Axis) will be crowded with of Equipments repeating themselves several times. From such graph we would not get any information for analysis. Here comes the Sub-Total Graphs. For follow these steps. (Have Equipment and Breakdown Duration fields as 1st 2 columns for simplicity)
1. Sort the ALV by Equipment field
3. Now Select the Equipment column and click on this Sub-total icon. A report like this would appear.
This is giving Equipment wise Total Breakdown duration. Now let’s draw graph for Equipment-wise Breakdown duration. For this, click on the icon at Red-Arrow shown in above picture. This collapses the details and only Sub-total are visible now. as under.
Now select the Equipment Column and click on the Graph icon to get the desired Graph. I have taken IW28 case for ease of demonstration of this section (Sub-total graphs). As I said in the beginning, Graphs through standard reports are not that explorable as discussed in this document. For this very reason, I developed ZIW28 through Infoset query, where all these graph features are available.
Hope this document too helps members across the spaces in SCN.
Jogeswara Rao K