Charts and Graphs in SAP ABAP!

In SAP most of the time we develop reports showing some analysis of data in mainly ALVs or List display. But the same data can be shown in Charts and Graphs.
SAP has provided with some plotting functions to represent data in Graphs and Charts.

There are Function modules for plotting graphs in 2D, 3D and even 4D!!!
The FMs are:

  • GRAPH_2D
  • GRAPH_3D
  • GRAPH_MATRIX
  • GRAPH_MATRIX_2D
  • GRAPH_MATRIX_3D
  • GRAPH_MATRIX_4D
The 3D matrix graph is more like a cube concept in Data warehousing where we can analyze data onto 3 different dimensions. The implementation of a 3D graph is in program below. I leave the implementation for 4D graphs to you. Do let me know how you implemented it?
Please see the report in ABAP which displays 3D Graphs of sales in 3 regions.

*&---------------------------------------------------------------------*
*& Report  ZMJTEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  zmjtest.*******************************************************************************
*                   S T R U C T U R E      D E C L A R A T I O N S            *
*******************************************************************************
TYPES:
 
BEGIN OF ty_data,
      reg_code
(10TYPE c,
      val1         
TYPE i,
      val2         
TYPE i,
      val3         
TYPE i,
 
END OF ty_data,

 
BEGIN OF ty_options,
      options
(30TYPE c,
 
END OF ty_options.
*******************************************************************************
*                   D A T A     D E C L A R A T I O N S                       *
*******************************************************************************
DATA: t_data TYPE STANDARD TABLE OF ty_data,
      r_data 
TYPE ty_data.DATA : t_opt TYPE STANDARD TABLE OF ty_options,
       r_opt 
TYPE ty_options.
*******************************************************************************
*                   S T A R T      O F     S E L E C T I O N                  *
*******************************************************************************
START-OF-SELECTION.

  
REFRESH : t_opt, t_data.
  
CLEAR   : r_data, r_opt.* Populate the Data into the Core Data Tables (t_data)
  r_data
-reg_code  'Asia Pacific'.
  r_data
-val1      55.
  r_data
-val2      65.
  r_data
-val3      75.
  
APPEND r_data TO t_data.

  
CLEAR r_data.
  r_data
-reg_code  'Australia'.
  r_data
-val1      75.
  r_data
-val2      75.
  r_data
-val3      90.
  
APPEND r_data TO t_data.

  
CLEAR r_data.
  r_data
-reg_code  'North America'.
  r_data
-val1      88.
  r_data
-val2      71.
  r_data
-val3      96.
  
APPEND r_data TO t_data.
*********************************************************************************
*                   O P T I O N S     T A B L E                                 *
* This parameter contains a table of display options. Setting the OPTS parameter*
* allows the ABAP program to determine the appearance of the generated graph.   *
* Setting options in this table only determines the initial appearance of the   *
* display. The online user is still free to reset these options once the display*
* appears on the monitor screen.                                                *
*                                                                               *
* Each element in the OPTS table is a string with the format:                   *
* OptionKey = Value                                                             *
*********************************************************************************
  r_opt
-options 'P3TYPE = PY'.                                "PY Pyramids
  
APPEND r_opt TO t_opt.

  r_opt
-options 'P2TYPE = VB'.                                "VB Vertical Bars
  
APPEND r_opt TO t_opt.

  r_opt
-options 'TISIZE = 3'.                                 "Main Title Size
  
APPEND r_opt TO t_opt.
* The function module GRAPH_MATRIX_3D calls a 3-dimensional SAP business graphic.

  
CALL FUNCTION 'GRAPH_MATRIX_3D'
    
EXPORTING
      col1      
'FY - Q1'
      col2      
'FY - Q2'
      col3      
'FY - Q3'
      dim1      
'In Percentage%'
      set_focus 
'X'
      titl      
'Region Wise Performances'
    
TABLES
      
data      t_data
      opts      
t_opt
    
EXCEPTIONS
      
OTHERS    1.
Output of the above report.