SAP support for graphics are pretty nice, but hardly used by programmers. This should be treated as an additional tool for making MIS reports more friendly. There are many functions provided by SAP for Graphical display. Lets have a look at a pretty simple but interesting code (with a pretty nice output) which could be used as your starter code for SAP Graphics.
The function used in this example is : GRAPH_MATRIX_3D.
This function module (GRAPH_MATRIX_3D) calls a 3-dimensional SAP business graphic.
Only three parameters have to be passed:
The first field of table DATA must be a C field of any length. The number values must then be passed in one or more numeric fields. These fields can have type P or F.
Table OPTS is used to pass all the options which can be changed interactively. Table OPTS must always be passed to the function module, but you can pass an empty table. In this case the default settings are used.
One of the parameters COL1 to COL6
Parameters COL1 to COL6 are used to pass column titles and they also define whether the corresponding table columns should be represented graphically. If a value which is not equal to SPACE is passed, then the corresponding column is represented.
Make sure that at least one of these parameters is passed. A maximum of 6 columns can be represented.
All other paramters are optional.
Here is a sample code:
DATA: BEGIN OF ITAB_MAIN OCCURS 0,
QUANTITY1 TYPE I,
QUANTITY2 TYPE I,
QUANTITY3 TYPE I,
QUANTITY4 TYPE I,
END OF ITAB_MAIN,
BEGIN OF ITAB_OPTIONS OCCURS 0,
END OF ITAB_OPTIONS.
ITAB_MAIN-DATANAME = ‘Gas’.
ITAB_MAIN-QUANTITY1 = 52.
ITAB_MAIN-QUANTITY2 = 66.
ITAB_MAIN-QUANTITY3 = 0.
ITAB_MAIN-QUANTITY4 = 93.
ITAB_MAIN-DATANAME = ‘Electricity’.
ITAB_MAIN-QUANTITY1 = 18.
ITAB_MAIN-QUANTITY2 = 22.
ITAB_MAIN-QUANTITY3 = 19.
ITAB_MAIN-QUANTITY4 = 92.
ITAB_MAIN-DATANAME = ‘Fuel’.
ITAB_MAIN-QUANTITY1 = 50.
ITAB_MAIN-QUANTITY2 = 65.
ITAB_MAIN-QUANTITY3 = 59.
ITAB_MAIN-QUANTITY4 = 99.
CALL FUNCTION ‘GRAPH_MATRIX_3D’
COL1 = ‘2001’
COL2 = ‘2002’
COL3 = ‘2003’
COL4 = ‘2004’
TITL = ‘Expenses – India(INR).’
DATA = ITAB_MAIN
OPTS = ITAB_OPTIONS
OTHERS = 1.