Preview only show first 10 pages with watermark. For full document please download

Graphics In Abap

Description: Many times a graphical chart output is required by the clients since a graph is much more appealing to the user and enables a better analysis of data. Some achieve this by exporting it to Excel and...

   EMBED


Share

Transcript

Many times a graphical chart output is required by the clients since a graph is much more appealing to the user and enables a better analysis of data. Some achieve this by exporting it to Excel and using the graph feature of Microsoft Excel. It is however quite simple to provide the functionality for building graphical charts in your ABAP report itself. Including this feature in your ABAP report is an absolutely productive task since it could take your program to a much more professional level with relatively very little effort required from your side. There are mainly two function modules that are being used to achieve this. Ø GFW_PRES_SHOW Ø GRAPH_MATRIX_3D There is also a class called CL_GFW whose methods are dedicated to drawing graphs. However, most of the basic graph requirements can be achieved using the above function modules. GFW_PRES_SHOW Suppose you want to draw a line chart showing the revenue from a department over a few years. These are the values for drawing the chart. Year Revenue 2009 5000 2010 8000 2011 3000 2012 10000 The output that you require would be : To achieve this in ABAP Pre-requisite : Create a custom screen say 100 and insert a custom control in it. Give it the name say ‘CONTAINER’ The graph can be easily drawn using the function GFW_PRES_SHOW. CALL FUNCTION 'GFW_PRES_SHOW' EXPORTING * CONTAINER = * TOP = * LEFT = * HEIGHT = * WIDTH = PRESENTATION_TYPE = * HEADER = * ORIENTATION = 1 * PARENT = * X_AXIS_TITLE = * Y_AXIS_TITLE = * FORMAT = * IMPORTING * RETVAL = * CONTENT_TYPE = * CONTENT_LENGTH = TABLES VALUES = COLUMN_TEXTS = * ROW_LABELS = * COLUMN_LABELS = * CONTENT = * EXCEPTIONS * ERROR_OCCURRED = 1 * OTHERS = 2 . The parameter presentation type determines the type of graph that needs to be drawn using the table. Given below are the values of the parameter presentation type corresponding to the different kinds of graphs. Line charts - gfw_prestype_lines Area Chart - gfw_prestype_area Horizontal bar chart - gfw_prestype_horizontal_bars Vertical bar chart - gfw_prestype_vertical_bars Pie chart - gfw_prestype_pie_chart Time axis chart. - gfw_prestype_time_axis The important concept that needs to be understood while using this function module is the logic behind populating the input tables of the function module. Once you understand that, you can easily draw any kind of chart according to the requirement. The two tables parameters values and column_texts are our messengers here. If we consider the above example, column_texts contains the points along the x-axis. That is 2009, 2010, 2011. The structure of the table column_texts is GPRTXT which contains just a single field COLTXT. Append all the x-axis points into this table. DATA : X_TEXTS TYPE TABLE OF GPRTXT WITH HEADER LINE. X_TEXTS-COLTXT = '2009'. APPEND X_TEXTS. X_TEXTS-COLTXT = '2010'. APPEND X_TEXTS. X_TEXTS-COLTXT = '2011'. APPEND X_TEXTS. X_TEXTS-COLTXT = '2012'. APPEND X_TEXTS. The y-axis values corresponding to all x-axis co-ordinates is appended together as a single row in the table VALUES. Values is a table of structure GPRVAL, which contains the field name for that grap