You are on page 1of 12

2D and 3D Reports using Graph Matrix Function Module

Applies to:
SAP ERP

Summary
SAP Business Graphics is a graphics program for generating two- and three-dimensional graphs. SAP support for 2D and 3D reports are very nice, but they are hardly used by programmers. There are many standard functions for graphical display especially for making MIS reports more friendly. Here the function modules GRAPH_MATRIX_2D and GRAPH_MATRIX_2D are used to generate 2D and 3D reports. Sample code is also provided.

Author:

Abyson Joseph Chavara

Company: Applexus Technologies (P) LTD Created on: 02 June 2011

Author Bio
Abyson Joseph Chavara is working as an SAP ABAP consultant at Applexus Technologies (P) LTD. He has around 3 year experience in ABAP programming and mainly focuses on report generation.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 1

2D and 3D Reports using Graph Matrix Function Module

Table of Contents
Introduction ......................................................................................................................................................... 3 Data input ........................................................................................................................................................ 3 Graphing Options ............................................................................................................................................ 3 The GRAPH_MATRIX_2D Function Module ...................................................................................................... 4 The GRAPH_MATRIX_2D Function Module sample program. .......................................................................... 5 The GRAPH_MATRIX_3D Function Module. ..................................................................................................... 6 The GRAPH_MATRIX_3D Function Module sample program........................................................................... 7 Switching Between Graphics Views. .................................................................................................................. 9 Selecting Parts of the Input Data for Display. ................................................................................................... 10 Formatting Graphs. ........................................................................................................................................... 11 Disclaimer and Liability Notice .......................................................................................................................... 12

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 2

2D and 3D Reports using Graph Matrix Function Module

Introduction
SAP Business Graphics is a graphics program for generating two- and three-dimensional graphs. The program offers you a variety of graphing options, data interfaces and various file manipulation commands. Data input You can input data to the program in either of the following ways: Data input by means of an ABAP program You create input data in an ABAP program. The input data must have a tabular format: o o o Simple list (for 2D graphs only) Table consisting of various rows and columns Various tables consisting of various rows and columns each

An ABAP function module calls up the SAP Business Graphics). The ABAP program sends the input data to the graphics program. Data input by means of an SAP screen capture You capture an SAP transaction window containing tabular data. Then you mark the data you want graphed. You can call up the SAP screen capture program from any SAP transaction window via menu (also from an R/2 transaction window of SAPs CUA Interface). The input data must have a tabular format: o o Simple list (for 2D graphs only) Table consisting of various rows and columns

You cannot capture input data contained in various SAP tables. Only an ABAP program can send such data to SAP Business Graphics. If the input data do not meet the format requirements, you can edit them on the captured screen. Graphing Options A number of display options are provided. You can: display two- or three-dimensional graphs display single graphs or group views choose graph types (bars, columns, etc.) set colors

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 3

2D and 3D Reports using Graph Matrix Function Module

The GRAPH_MATRIX_2D Function Module


The GRAPH_MATRIX_2D function module calls SAP Business Graphics and generates a two-dimensional view of your data. You can send a full table of values, and further parameters telling which part of the table to display. The following table contains a list of all possible parameters you can use with this function module. Name INBUF ** INFORM MAIL_ALLOW NCOL NROW PWDID ** STAT ** SUPER ** TIMER TITL VALT WDID WINID ** WINPOS WINSZX WINSZY X_OPT B_KEY B_TYP M_TYP ** MOD_COL MOD_ROW MOD_VAL RBUFF ** RWNID ** DATA OPTS TCOL Note: ** denotes a dialog parameter Of the above list, only the DATA, OPTS and TCOL parameters are required. Status Import Import Import Import Import Import Import Import Import Import Import Import Import Import Import Import Import Export Export Export Export Export Export Export Export Internal Table Internal Table Internal Table Initial Value SPACE SPACE SPACE SPACE SPACE SPACE SPACE SPACE (Do Not Use) SPACE SPACE SPACE SPACE SPACE '50' '50' (Do Not Use)

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 4

2D and 3D Reports using Graph Matrix Function Module

The GRAPH_MATRIX_2D Function Module sample program.


REPORT ZABY_3D_REPORT. DATA: BEGIN OF data OCCURS 1, text(36), feld1 TYPE p, END OF data, BEGIN OF opts OCCURS 1, c(80) TYPE c, END OF opts, BEGIN OF tyear OCCURS 1, c(20) TYPE c, END OF tyear. opts-c = 'P2TYPE = PI'. APPEND opts. data-text = 'X 10'. data-feld1 = '10'. APPEND data. data-text = 'Y 20'. data-feld1 = '20'. APPEND data. CALL FUNCTION 'GRAPH_MATRIX_2D' TABLES data = data opts = opts tcol = tyear EXCEPTIONS col_invalid = 1 opt_invalid = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. The output will be as follows.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 5

2D and 3D Reports using Graph Matrix Function Module

The GRAPH_MATRIX_3D Function Module.


The GRAPH_MATRIX_3D function module calls SAP Business Graphics with data for display in a threedimensional graph. You can send a full table of values, and further parameters telling which part of the table to display. The following table contains a list of all possible parameters you can use with this function module. Parameters used with GRAPH_MATRIX_3D Name COL1,COL2,...COL6 DIM1,DIM2 INBUF ** INFORM MAIL_ALLOW PWDID ** STAT ** SUPER ** TIMER TITL VALT WDID WINID ** WINPOS WINSZX WINSZY X_OPT B_KEY B_TYP M_TYP ** MOD_COL MOD_ROW MOD_VAL RBUFF ** RWNID ** DATA OPTS Note: ** denotes a dialog parameter Of the above list, only the DATA, OPTS and at least one of the COLn (COL1, COL2,..., COL6) parameters are required. Status Import Import Import Import Import Import Import Import Import Import Import Import Import Import Import Import Import Export Export Export Export Export Export Export Export Internal Table Internal Table Initial Value SPACE SPACE SPACE SPACE SPACE SPACE SPACE SPACE (Do Not Use) SPACE SPACE SPACE SPACE SPACE '50' '50' (Do Not Use)

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 6

2D and 3D Reports using Graph Matrix Function Module

The GRAPH_MATRIX_3D Function Module sample program.


REPORT
ZABY_3D_REPORT.

DATA: BEGIN OF ITAB_MAIN OCCURS 0,


DATANAME(15), QUANTITY1 TYPE QUANTITY2 TYPE QUANTITY3 TYPE QUANTITY4 TYPE

I, I, I, I,

END OF ITAB_MAIN, BEGIN OF ITAB_OPTIONS OCCURS 0,


OPTION(20),

END OF ITAB_OPTIONS.
ITAB_MAIN-DATANAME = 'Country1'. ITAB_MAIN-QUANTITY1 = 52. ITAB_MAIN-QUANTITY2 = 66. ITAB_MAIN-QUANTITY3 = 0. ITAB_MAIN-QUANTITY4 = 93. APPEND ITAB_MAIN. ITAB_MAIN-DATANAME = 'Country2'. ITAB_MAIN-QUANTITY1 = 18. ITAB_MAIN-QUANTITY2 = 22. ITAB_MAIN-QUANTITY3 = 19. ITAB_MAIN-QUANTITY4 = 92. APPEND ITAB_MAIN. ITAB_MAIN-DATANAME = 'Contry3'. ITAB_MAIN-QUANTITY1 = 50. ITAB_MAIN-QUANTITY2 = 65. ITAB_MAIN-QUANTITY3 = 59. ITAB_MAIN-QUANTITY4 = 99. APPEND ITAB_MAIN.

CALL FUNCTION 'GRAPH_MATRIX_3D' EXPORTING COL1 = '2007' COL2 = '2008' COL3 = '2009' COL4 = '2010' TITL = 'Economic growth of south Asian countries' TABLES DATA = ITAB_MAIN
OPTS = ITAB_OPTIONS

EXCEPTIONS OTHERS = 1.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 7

2D and 3D Reports using Graph Matrix Function Module

The output will be as follows

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 8

2D and 3D Reports using Graph Matrix Function Module

Switching Between Graphics Views.


SAP Business Graphics provides you with four possible views, formatted windows, for displaying the data. You can move around between these views using the Goto menu. You are placed in one of these views as soon as you enter SAP Business Graphics. The starting view depends on the input data you use. For data in a single table with rows and columns, you are placed by default in the Selection view. This view contains three parts: A 3D graph in the upper left A 2D graph 2D graph in the lower right A set of Selection Bars in the lower left, below the 3D graph. Selecting Parts of the Input Data for Display later in this section explains how to use these bars.

To switch from the Selection View to another view, (for example the 3D view), proceed as follows: Select 3D view by clicking on the pushbutton or choose Goto 3D view. 1. The Selection view goes away, and is replaced by the 3D view. This view contains a single 3D graph 2. Try the above steps to call up the 2D view and Groups view, to see what these views look like.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 9

2D and 3D Reports using Graph Matrix Function Module

Selecting Parts of the Input Data for Display.


If you are in the Selection view, you can use the selection bars to decide what part of the 3D graph you want to display in the 2D graph. The selection bars are the bars of text located below the 3D graph portion of the Selection view. The text in these bars lists either the names of rows or the names of columns in the 3D graph. The topmost bar gives the title for the rows (or columns) as a set. Compare the text in the selection bars with the labels in the 3D graph portion of the view. 1. Experiment with the selection bars: click on the various bars and observe the effects: The bar you click on is highlighted and new data is displayed in the 2D graph portion of the view. a. When you click on the topmost bar, all the values in the 3D graph are displayed in the 2D graph. b. When you click on one of the lower bars, you are selecting a particular row (or column) of the 3D graph for display in the 2D graph. The values for that row (or column) appear in the 2D graph. 2. If the selection bars contain the names of rows, try reading the column-names into the selection bars. (Or do the opposite, if the columns are already there). The floor of the 3D graph has side panels. To read the column-names into the selection bars, click anywhere on the side panel on the right side of the 3D graph floor. (To read in the rows, click anywhere on the left-hand side panel.)

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 10

2D and 3D Reports using Graph Matrix Function Module

Formatting Graphs.
SAP Business Graphics provides you with four options menus for formatting the graphs. These four options menus are available through the Options main menu (in the menu bar) and they all work in the same way. As an example, follow the steps below to try out the 3D Options menu. To begin, return to the Selection view, if you are not already there. 1. Click on Options in the menu bar and further select 3D Options. 2. Re-position the Selection view and the menu (by clicking on each window's title bar and dragging) so you can see both at the same time. 3. In the 3D Options menu, the current graph type (the default) is Towers. Select the graph type Pyramids. (If there is no immediate change in the 3D graph, click on the Apply button below). The objects in the 3D graph change to pyramids, while the 2D graph remains the same. 4. Click on the various 3D Colors entries to observe how the coloring pattern changes in the 3D graph. Try out several combinations of options to observe the effects. Bear in mind that not all options can be used with all graph types. The section Formatting Graphs provides more details on individual options menus. Setting Options and Indicators To set a menu option, click on the option. If no change is visible in the relevant graph (the 2D or 3D graph to which the option applies), click on the Apply button as well. The results of your changes appear in the graph. Menu indicators work slightly differently. If they have up- and down-arrows attached, you can click on the arrows to add or subtract one to the indicator's value. You can also just type new values in. Click on the box where the indicator's current value is displayed, delete the value and type in a new one. If you type a value that is too large or too small, the indicator's maximum or minimum value is automatically used.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 11

2D and 3D Reports using Graph Matrix Function Module

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document..

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com 12

You might also like