ABAP Program to create Splitter control and Graphs

ABAP Program to create Splitter control and Graphs
*&----------------------------------------------------------------------
*& Report Z_SPLIT_GRAPH
*& Author: Swarna.S.(Tata Consultancy Services)
*&----------------------------------------------------------------------
*& AS : Sample code for creating a splitter screen and graph.
*& The screen is divided into two by splitter control and can be resized
*& Two graphs are drawn on the two splitter containers.
*& The sample code also describes creating graphs in ABAP.
*&----------------------------------------------------------------------
REPORT z_split_graph .

*type pool declarations for graphical frame work
TYPE-POOLS: GFW.

*OK code declaration
DATA: OK_CODE TYPE SY-UCOMM.

*structure declaration for graph 1 values
types : begin of ty_grvalwa1.

include structure gprval.

types : end of ty_grvalwa1.

*structure declaration for graph 1 column names
types : begin of ty_col1_texts.

include structure gprtxt.

types : end of ty_col1_texts.

*data declarations for graph 1
data : grval1 TYPE standard TABLE OF ty_grvalwa1,
grvalwa1 type ty_grvalwa1,
COL1_TEXTS TYPE standard TABLE OF ty_col1_texts,
col1_wa type ty_col1_texts.
*structure declaration for graph 2 values

types : begin of ty_grvalwa2.
include structure gprval.
types : end of ty_grvalwa2.

*structure declaration for graph 2 column names
types : begin of ty_col2_texts.

include structure gprtxt.

types : end of ty_col2_texts.

*data declarations for graph2

data : grval2 TYPE standard TABLE OF ty_grvalwa2,
grvalwa2 type ty_grvalwa2,
COL2_TEXTS TYPE standard TABLE OF ty_col2_texts,
col2_wa type ty_col2_texts.

*data declarations for containers,splitters,and custom container

data :CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
CONT1 type ref to cl_gui_container,
CONT2 type ref to cl_gui_container.

*Initialisation event
INITIALIZATION.

*start of selection event
START-OF-SELECTION.

*Call screen for the container for output
CALL SCREEN 600.

*PBO module for the output display
*&---------------------------------------------------------------------*
*& Module PBO_0600 OUTPUT
*&---------------------------------------------------------------------*

MODULE PBO_0600 OUTPUT.
*Setting the GUI status for the splitter screen(EXIT button)
SET PF-STATUS 'SPLITGRAPH'.

*Setting the title for the splitter control
SET titlebar 'SPLITGRAPH'.

*Creating custom container
CREATE OBJECT CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER'.

*creating the splitter control
CREATE OBJECT splitter
EXPORTING
PARENT = CUSTOM_CONTAINER
ROWS = 1
COLUMNS = 2
ALIGN = 15.

*calling the container method of the splitter class
*for the first graphic
CALL METHOD SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = CONT1.

*calling the container method of the splitter class
*for the second graphic
CALL METHOD SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 2
RECEIVING
CONTAINER = CONT2.

*Graphic 1 display

REFRESH : grval1,Col1_texts.
grvalwa1-rowtxt = 'Rice'.
grvalwa1-val1 = 1100.
grvalwa1-VAL2 = 4500.
APPEND grvalwa1 to grval1.

grvalwa1-ROWTXT = 'Coffee'.
grvalwa1-VAL1 = 2000.
grvalwa1-VAL2 = 6000.
APPEND grvalwa1 to grval1.

grvalwa1-ROWTXT = 'Tea'.
grvalwa1-VAL1 = 3500.
grvalwa1-VAL2 = 7000.
APPEND grvalwa1 to grval1.

grvalwa1-ROWTXT = 'Cereals'.
grvalwa1-VAL1 = 6000.
grvalwa1-val2 = 7000.
APPEND grvalwa1 to grval1.

col1_wa-coltxt = '2005'.
APPEND col1_wa to COL1_TEXTS.

COL1_wa-COLTXT = '2006'.
APPEND col1_wa to COL1_TEXTS.

*Function module to display graph (Graph 1)
CALL FUNCTION 'GFW_PRES_SHOW_MULT'
EXPORTING
PARENT = CONT1
PRESENTATION_TYPE = GFW_PRESTYPE_LINES
SHOW = GFW_FALSE
TABLES
VALUES = grval1
COLUMN_TEXTS = COL1_TEXTS
EXCEPTIONS
ERROR_OCCURRED = 1.

*Graphic 2 display

REFRESH : grval2,col2_texts.
grvalwa2-ROWTXT = 'Wheat'.
grvalwa2-VAL1 = 3000.
grvalwa2-VAL2 = 5500.
APPEND grvalwa2 to grval2.

grvalwa2-ROWTXT = 'Corn'.
grvalwa2-VAL1 = 2700.
grvalwa2-VAL2 = 8000.
APPEND grvalwa2 to grval2.
grvalwa2-ROWTXT = 'Maize'.
grvalwa2-VAL1 = 3250.
grvalwa2-VAL2 = 5000.
APPEND grvalwa2 to grval2.

grvalwa2-ROWTXT = 'Barley'.
grvalwa2-VAL1 = 6500.
grvalwa2-VAL2 = 9000.
APPEND grvalwa2 to grval2.

COL2_wa-COLTXT = '2005'.
APPEND col2_wa to COL2_TEXTS.

COL2_wa-COLTXT = '2006'.
APPEND col2_wa to COL2_TEXTS.

*Function module to display Graph 2
CALL FUNCTION 'GFW_PRES_SHOW_MULT'
EXPORTING
PARENT = CONT2
PRESENTATION_TYPE = GFW_PRESTYPE_LINES
SHOW = GFW_TRUE
TABLES
VALUES = grval2
COLUMN_TEXTS = COL2_TEXTS
EXCEPTIONS
ERROR_OCCURRED = 1.

ENDMODULE. " PBO_0600 OUTPUT

*PAI module : Based on user input,action is performed

*EXIT called to leave program when user clicks it

*&---------------------------------------------------------------------*

*& Module PAI_0600 INPUT

*&---------------------------------------------------------------------*

MODULE PAI_0600 INPUT.
OK_CODE = SY-UCOMM.

IF OK_CODE EQ 'EXIT'.
LEAVE PROGRAM.
ENDIF.

ENDMODULE. " PAI_0600 INPUT

Leave a Reply

Your email address will not be published. Required fields are marked *