Wednesday, January 16, 2008

Program to Generate Graphs

*&---------------------------------------------------------------------*
*& Report Z_GRAPHS
*&---------------------------------------------------------------------*
*& This program demonstrates how easy it is to generate 3D or 2D graphs,
*& simply by populating the statistical data into an internal table and
*& passing it to a Function Module.
*&
*& The Example has no imput parameters, but they can be added based on
*& the requirement
*&---------------------------------------------------------------------*
*& URL: http://allaboutsap.blogspot.com
*&---------------------------------------------------------------------*

REPORT Z_GRAPHS.

*----------------------------------------------------------------------*
*INTERNAL TABLES AND STRUCTURES
*----------------------------------------------------------------------*
*** Internal table to hold Statistical data
DATA:
BEGIN OF IT_DATA OCCURS 0,
DATANAME(15),
QUANTITY1 TYPE I,
QUANTITY2 TYPE I,
QUANTITY3 TYPE I,
END OF IT_DATA.

*** Internal table to hold Options
DATA:
BEGIN OF IT_OPTIONS OCCURS 0,
OPTION(20),
END OF IT_OPTIONS.

*----------------------------------------------------------------------*
* Populating statistics data
IT_DATA-DATANAME = 'India'.
IT_DATA-QUANTITY1 = 55.
IT_DATA-QUANTITY2 = 62.
IT_DATA-QUANTITY3 = 59.
APPEND IT_DATA.

IT_DATA-DATANAME = 'UK'.
IT_DATA-QUANTITY1 = 35.
IT_DATA-QUANTITY2 = 80.
IT_DATA-QUANTITY3 = 44.
APPEND IT_DATA.

IT_DATA-DATANAME = 'USA'.
IT_DATA-QUANTITY1 = 18.
IT_DATA-QUANTITY2 = 80.
IT_DATA-QUANTITY3 = 19.
APPEND IT_DATA.

* Call FM to generate graph for the stats
CALL FUNCTION 'GRAPH_MATRIX_3D'
EXPORTING
COL1 = 'IT Professionals'
COL2 = 'Doctors'
COL3 = 'Engineers'
TITL = 'Professional Statistics'
TABLES
DATA = IT_DATA
OPTS = IT_OPTIONS
EXCEPTIONS
OTHERS = 1.

No comments: