Вы находитесь на странице: 1из 33

ABAP Development: Using SAP Bar Chart

Graphics (Lesson-1)

Posted by Kishan Srikrishnarajah Nov 26, 2012


What is SAP Bar Chart Graphics?
The SAP Bar Chart Graphics displays bar charts over a given time period, and allows the user to manipulate
the bar charts. An ideal tool to develop a planning board.

Features of SAP Bar Chart Graphics:


1. Graph title appears in the window title bar.
2. Time line – You could have many types (by second, minute, hour, day, week, month, year)
of time lines.
3. Display areas – Supports up to a maximum of 8 bar charts in one graphic window. You can
resize the displays by dragging the dividing line between the bar charts. Each bar chart
consists of the following elements:
1. Time units line.
2. Tables section – Here you could have supporting information displayed in tabular form for
the graph display area objects.
3. Graph display area – The graph display area contains objects/nodes (event blocks)
depicting the duration of events. Each of the graph areas contain its own time units line.
The user can choose among a number of time units (minute, hour, day, week, etc.).
4. The standard pushbuttons in the pushbutton bar allow you to change the size of the graph display
and the tables section.
4. The calling ABAP program determines the elements to be contained in the graphics window. You could
define more menus with additional functions or leave out standard functions and symbols.
5. You could select, move, change, connect, insert, resize, copy and delete objects/nodes (event blocks).
6. The ability to print the bar chart graphics.

Generated by Jive on 2014-07-12+02:00


1
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

Two ways to call Bar Chart Graphics:


Call as a Window – Here the bar chart appears in a separate window.

Generated by Jive on 2014-07-12+02:00


2
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

Calling as a Control – Here the bar chart appears as a control.

Generated by Jive on 2014-07-12+02:00


3
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

The key function groups:


1. GRAP – Contains function modules necessary when calling bar chart as a window.
2. BARC – Contains function modules necessary to create, modify the bar chart.
3. CNBC – Contains function modules necessary to call bar chart as a control.

The key function modules used when calling a bar chart as a window:
1. GRAPH_SET_CUA_STATUS – Set graphics GUI status and allows creating application-specific
menu entries.
2. GRAPH_RECEIVE – Enables you to wait for user input.

The key function modules used when calling a bar chart as a control:
1. BARCHART_CREATE – Calls bar chart as a control

The common key function modules used in window/control:

Generated by Jive on 2014-07-12+02:00


4
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

1. BARC_SET_OPTIONS – This enables settings to be changed when the graphic is loaded or


reloaded.
2. BARC_SET_TIME_AXIS – Set start and end time of axis.
3. BARC_ADD_SECTION – To create a section of the time axis as well as dividing the time axis
into a maximum of eight parts. Every section has a different time unit (hour, day, week..)
4. BARC_ADD_RIBBON - Ribbons are time scales to be defined for every time axis per chart and section.
5. Setting a calendar to appear on the bar chart:
1. BARC_ADD_CALENDAR
2. BARC_ADD_TIME_OBJECT
3. BARC_ADD_TIME_PROFILE
4. BARC_SET_TIME_PROFILE_ATTRIB
5. BARC_SET_CALENDAR_ATTRIB
6. BARC_ADD_INTERVAL
7. BARC_SET_INTERVAL_ATTRIB
6. BARC_ADD_CHART – To create a chart. You could have 8 Charts in One Window.
7. BARC_SET_CHART_ATTRIB – To set chart attributes.
8. BARC_SET_COLUMN_WIDTH – Determine column width, Define columns for every table area
of a chart.
9. BARC_SET_ROW_HEIGHT – A line height can be specified for each line.
10.BARC_ADD_GRID – To create a time fence grid.
11.BARC_LOGIC – This module provides the semantics for editing the transfer tables, based on
user commands. The tables NODES, NVALS, BOXES, BVALS, POSITIONS and DELETIONS can
be returned to the graphics module in the dialog loop.
12.BARC_GRAPHIC_PBO – Starting bar chart at PBO time.
13.BARC_GRAPHIC_PAI – Analyze data returned by the graphic.
14.BARCHART_SET_FUNCTION_CODE – Deliver Function Code to Control.

A simple Bar Chart example:


///////////////////////////////////////////////////////////////////////////////////////////////////////
REPORT zbarchartsimple.

INCLUDE sgrccnst.

INCLUDE lbarccon.
INCLUDE barcdata.

DATA: chart LIKE bcchart-id,

section LIKE bcsection-id,

val LIKE bcvals-val.

PARAMETER: gruppe LIKE tbcgt-prf_gruppe DEFAULT 'DEMO',

name LIKE tbcgt-prf_name DEFAULT '000000000001',

index LIKE tbcgt-prf_index DEFAULT '1'.

Generated by Jive on 2014-07-12+02:00


5
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

* Assign Graphic profile

graph_profile-prf_gruppe = gruppe.

graph_profile-prf_name = name.

graph_profile-prf_index = index.

* Start and end of the timeline

CALL FUNCTION 'BARC_SET_TIME_AXIS'

EXPORTING
start = '01.01.2012;'

end = '31.12.2012;'.

* Add 1st Chart

CALL FUNCTION 'BARC_ADD_CHART'

IMPORTING

id = chart.

* Width of the column in the tables

CALL FUNCTION 'BARC_SET_COLUMN_WIDTH'

EXPORTING

chart_id = chart

width = 4000.

* Heading for the table

boxes-id = 1.

boxes-type = bc_const-row_box.

boxes-chart_id = chart.

boxes-form_type = 'B1'.

boxes-color_type = 'B0'.

APPEND boxes.

box_vals-id = boxes-id.

Generated by Jive on 2014-07-12+02:00


6
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

box_vals-fl = '0'.

box_vals-val = 'Table Header'.

APPEND box_vals.

positions-obj_id = boxes-id.

positions-obj_type = bc_const-box_object.
positions-chart_id = chart.

positions-row_number = 0.

APPEND positions.

WRITE boxes-id TO val.

CALL FUNCTION 'BARC_SET_CHART_ATTRIB'

EXPORTING

fl = bc_const-chart_title_box

id = chart

val = val.

* Add a Section of time axis

CALL FUNCTION 'BARC_ADD_SECTION'

EXPORTING

size = 100
start = '01.01.2012;'

unit = '5'

IMPORTING

id = section.

* Add a Ribbon to a Section

CALL FUNCTION 'BARC_ADD_RIBBON'

EXPORTING

chart_id = chart

color_type = 'R1'

Generated by Jive on 2014-07-12+02:00


7
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

section_id = section

unit = '5'.

CALL FUNCTION 'BARC_ADD_RIBBON'

EXPORTING

chart_id = chart
color_type = 'R2'

section_id = section

unit = '3'.

* Create Rows for the Table

PERFORM set_boxes TABLES boxes

box_vals

positions

USING chart.

* Set Nodes in Graph area

PERFORM set_nodes TABLES nodes

node_vals

positions

USING chart.

stat = sgrc_const-stat_1. "Open Window, Transfer Data, Wait for Input

DO.

* Start Bar Chart

CALL FUNCTION 'BARC_GRAPHIC_PBO'

EXPORTING

confirm = space

profile = graph_profile

stat = stat

TABLES

Generated by Jive on 2014-07-12+02:00


8
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

boxes = boxes

box_vals = box_vals

deletions = deletions

links = links

link_vals = link_vals

nodes = nodes
node_vals = node_vals

positions = positions.

* Wait for user input

CALL FUNCTION 'GRAPH_RECEIVE'

IMPORTING

mcode = m_typ

EXCEPTIONS

inv_communication = 1

no_batch = 2.

IF NOT sy-subrc IS INITIAL.

EXIT.

ENDIF.

CASE m_typ.
WHEN sgrc_const-m_typ_d.

EXIT.

WHEN sgrc_const-m_typ_i.

* Evaluation of data from the graph

CALL FUNCTION 'BARC_GRAPHIC_PAI'

IMPORTING

graph_cmd = graph_cmd

TABLES

boxes = boxes

box_vals = box_vals

Generated by Jive on 2014-07-12+02:00


9
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

deletions = deletions

nodes = nodes

node_vals = node_vals

positions = positions

links = links

link_vals = link_vals
EXCEPTIONS

inv_winid = 1.

abap_cmd = graph_cmd.

stat = sgrc_const-stat_4. "Wait for input

ENDCASE.

ENDDO.

FORM make_box TABLES boxes STRUCTURE bcboxes

box_vals STRUCTURE bcvals

positions STRUCTURE bcposition

USING chart LIKE bcchart-id

id TYPE i

format

color

text
row TYPE i.

boxes-id = id.

boxes-type = bc_const-row_box.

boxes-chart_id = chart.

boxes-form_type = format.

boxes-color_type = color.

APPEND boxes.

box_vals-id = boxes-id.

Generated by Jive on 2014-07-12+02:00


10
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

box_vals-fl = '0'.

box_vals-val = text.

APPEND box_vals.

positions-obj_id = boxes-id.

positions-obj_type = bc_const-box_object.
positions-chart_id = boxes-chart_id.

positions-row_number = row.

APPEND positions.

ENDFORM.

FORM set_boxes TABLES boxes STRUCTURE bcboxes

box_vals STRUCTURE bcvals

positions STRUCTURE bcposition

USING chart LIKE bcchart-id.

PERFORM make_box TABLES boxes box_vals positions

USING chart 2 'B1' 'B1' 'Row - 1' 1.

PERFORM make_box TABLES boxes box_vals positions

USING chart 3 'B1' 'B1' 'Row - 2' 2.

PERFORM make_box TABLES boxes box_vals positions

USING chart 4 'B1' 'B1' 'Row - 3' 3.

PERFORM make_box TABLES boxes box_vals positions

USING chart 5 'B1' 'B1' 'Row - 4' 4.

PERFORM make_box TABLES boxes box_vals positions

USING chart 6 'B1' 'B1' 'Row - 5' 5.

Generated by Jive on 2014-07-12+02:00


11
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

ENDFORM.

FORM set_nodes TABLES nodes STRUCTURE bcnodes

node_vals STRUCTURE bcnvals

positions STRUCTURE bcposition

USING chart LIKE bcchart-id.

nodes-id = 1.

nodes-chart_id = chart.
APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.

node_vals-fl = '1'.

node_vals-val = '12.01.2012;'.

APPEND node_vals.

node_vals-fl = '2'.

node_vals-val = '27.06.2012;'.

APPEND node_vals.

node_vals-fl = bc_const-add_layer.
node_vals-val = '00'.

APPEND node_vals.

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.

positions-row_number = 1.

APPEND positions.

*----------------------------------------------------------------------*

Generated by Jive on 2014-07-12+02:00


12
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

nodes-id = 2.

nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.
node_vals-fl = '1'.

node_vals-val = '02.02.2012;'.

APPEND node_vals.

node_vals-fl = '2'.

node_vals-val = '25.07.2012;'.

APPEND node_vals.

node_vals-fl = bc_const-add_layer.

node_vals-val = '01'.

APPEND node_vals.

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.

positions-row_number = 2.
APPEND positions.

*----------------------------------------------------------------------*

nodes-id = 3.

nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.

node_vals-fl = '1'.

Generated by Jive on 2014-07-12+02:00


13
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

node_vals-val = '01.04.2012;'.

APPEND node_vals.

node_vals-fl = '2'.

node_vals-val = '25.09.2012;'.

APPEND node_vals.

node_vals-fl = bc_const-add_layer.

node_vals-val = '02'.
APPEND node_vals.

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.

positions-row_number = 3.

APPEND positions.

*----------------------------------------------------------------------*

nodes-id = 4.

nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.

node_vals-fl = '1'.

node_vals-val = '11.02.2012;'.

APPEND node_vals.

node_vals-fl = '2'.

node_vals-val = '11.07.2012;'.

APPEND node_vals.

Generated by Jive on 2014-07-12+02:00


14
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

node_vals-fl = bc_const-add_layer.

node_vals-val = '00'.

APPEND node_vals.

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.
positions-chart_id = nodes-chart_id.

positions-row_number = 4.

APPEND positions.

*----------------------------------------------------------------------*

nodes-id = 5.

nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.

node_vals-fl = '1'.

node_vals-val = '01.05.2012;'.

APPEND node_vals.

node_vals-fl = '2'.
node_vals-val = '11.12.2012;'.

APPEND node_vals.

node_vals-fl = bc_const-add_layer.

node_vals-val = '01'.

APPEND node_vals.

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.

Generated by Jive on 2014-07-12+02:00


15
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

positions-row_number = 5.

APPEND positions.

ENDFORM.
///////////////////////////////////////////////////////////////////////////////////////////////////////

Calling a Bar Chart as a control example:

///////////////////////////////////////////////////////////////////////////////////////////////////////
REPORT zbarchartcontrol.

INCLUDE sgrccnst.

INCLUDE lbarccon.

INCLUDE barcdata.

INCLUDE <ctldef>.

DATA: all_boxes LIKE bcboxes OCCURS 0 WITH HEADER LINE,

all_box_vals LIKE bcvals OCCURS 0 WITH HEADER LINE,

all_links LIKE bclinks OCCURS 0 WITH HEADER LINE,

all_link_vals LIKE bcnvals OCCURS 0 WITH HEADER LINE,

all_nodes LIKE bcnodes OCCURS 0 WITH HEADER LINE,

all_node_vals LIKE bcnvals OCCURS 0 WITH HEADER LINE,

all_positions LIKE bcposition OCCURS 0 WITH HEADER LINE.

DATA: chart LIKE bcchart-id,

section LIKE bcsection-id,

val LIKE bcvals-val,

barc_ocx TYPE cntl_handle,

this_repid LIKE sy-repid,

this_dynnr LIKE sy-dynnr,

ok_code TYPE syucomm,

save_ok_code LIKE ok_code,

graph_cmd_info LIKE bccmdinfo,

gr_sel_field LIKE net_graph-sel_field,

Generated by Jive on 2014-07-12+02:00


16
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

layer_kind LIKE tbcl-layer_type,

settings LIKE barc_set,

symboltype LIKE tbcl-symboltype.

PARAMETER: gruppe LIKE tbcgt-prf_gruppe DEFAULT 'DEMO',

name LIKE tbcgt-prf_name DEFAULT '000000000001',


index LIKE tbcgt-prf_index DEFAULT '1'.

this_dynnr = '100'.
this_repid = sy-repid.

CALL FUNCTION 'BARCHART_CREATE'

EXPORTING

owner_repid = this_repid

dynnr = this_dynnr

CHANGING

handle = barc_ocx.

* Assign Graphic profile

graph_profile-prf_gruppe = gruppe.

graph_profile-prf_name = name.

graph_profile-prf_index = index.

* Start and end of the timeline

CALL FUNCTION 'BARC_SET_TIME_AXIS'

EXPORTING

start = '01.01.2012;'

end = '31.12.2012;'.

* Add 1st Chart

CALL FUNCTION 'BARC_ADD_CHART'

IMPORTING

Generated by Jive on 2014-07-12+02:00


17
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

id = chart.

* Width of the column in the tables

CALL FUNCTION 'BARC_SET_COLUMN_WIDTH'

EXPORTING

chart_id = chart
width = 4000.

* Heading for the table


boxes-id = 1.

boxes-type = bc_const-row_box.

boxes-chart_id = chart.

boxes-form_type = 'B1'.

boxes-color_type = 'B0'.

APPEND boxes.

box_vals-id = boxes-id.

box_vals-fl = '0'.

box_vals-val = 'Table Header'.

APPEND box_vals.

positions-obj_id = boxes-id.
positions-obj_type = bc_const-box_object.

positions-chart_id = chart.

positions-row_number = 0.

APPEND positions.

WRITE boxes-id TO val.

CALL FUNCTION 'BARC_SET_CHART_ATTRIB'

EXPORTING

fl = bc_const-chart_title_box

Generated by Jive on 2014-07-12+02:00


18
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

id = chart

val = val.

* Add a Section of time axis

CALL FUNCTION 'BARC_ADD_SECTION'

EXPORTING
size = 100

start = '01.01.2012;'

unit = '5'
IMPORTING

id = section.

* Add a Ribbon to a Section

CALL FUNCTION 'BARC_ADD_RIBBON'

EXPORTING

chart_id = chart

color_type = 'R1'

section_id = section

unit = '5'.

CALL FUNCTION 'BARC_ADD_RIBBON'

EXPORTING
chart_id = chart

color_type = 'R2'

section_id = section

unit = '3'.

* Create Rows for the Table

PERFORM set_boxes TABLES boxes

box_vals

positions

USING chart.

Generated by Jive on 2014-07-12+02:00


19
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

* Set Nodes in Graph area

PERFORM set_nodes TABLES nodes

node_vals

positions

USING chart.

CALL FUNCTION 'BARC_LOGIC'

TABLES
all_boxes = all_boxes

all_box_vals = all_box_vals

all_links = all_links

all_link_vals = all_link_vals

all_nodes = all_nodes

all_node_vals = all_node_vals

all_positions = all_positions

boxes = boxes

box_vals = box_vals

deletions = deletions

links = links

link_vals = link_vals

nodes = nodes
node_vals = node_vals

positions = positions.

stat = sgrc_const-stat_1. "Open Window, Transfer Data, Wait for Input

CALL SCREEN 100.

FORM make_box TABLES boxes STRUCTURE bcboxes

box_vals STRUCTURE bcvals

positions STRUCTURE bcposition

Generated by Jive on 2014-07-12+02:00


20
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

USING chart LIKE bcchart-id

id TYPE i

format

color

text

row TYPE i.

boxes-id = id.

boxes-type = bc_const-row_box.
boxes-chart_id = chart.

boxes-form_type = format.

boxes-color_type = color.

APPEND boxes.

box_vals-id = boxes-id.

box_vals-fl = '0'.

box_vals-val = text.

APPEND box_vals.

positions-obj_id = boxes-id.

positions-obj_type = bc_const-box_object.

positions-chart_id = boxes-chart_id.
positions-row_number = row.

APPEND positions.

ENDFORM.

FORM set_boxes TABLES boxes STRUCTURE bcboxes

box_vals STRUCTURE bcvals

positions STRUCTURE bcposition

USING chart LIKE bcchart-id.

Generated by Jive on 2014-07-12+02:00


21
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

PERFORM make_box TABLES boxes box_vals positions

USING chart 2 'B1' 'B1' 'Row - 1' 1.

PERFORM make_box TABLES boxes box_vals positions

USING chart 3 'B1' 'B1' 'Row - 2' 2.

PERFORM make_box TABLES boxes box_vals positions

USING chart 4 'B1' 'B1' 'Row - 3' 3.

PERFORM make_box TABLES boxes box_vals positions

USING chart 5 'B1' 'B1' 'Row - 4' 4.

PERFORM make_box TABLES boxes box_vals positions

USING chart 6 'B1' 'B1' 'Row - 5' 5.

ENDFORM.

FORM set_nodes TABLES nodes STRUCTURE bcnodes

node_vals STRUCTURE bcnvals

positions STRUCTURE bcposition

USING chart LIKE bcchart-id.

nodes-id = 1.

nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.

node_vals-fl = '1'.

node_vals-val = '12.01.2012;'.

APPEND node_vals.

Generated by Jive on 2014-07-12+02:00


22
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

node_vals-fl = '2'.

node_vals-val = '27.06.2012;'.

APPEND node_vals.

node_vals-fl = bc_const-add_layer.

node_vals-val = '00'.
APPEND node_vals.

positions-obj_id = nodes-id.
positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.

positions-row_number = 1.

APPEND positions.

*----------------------------------------------------------------------*

nodes-id = 2.

nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.

node_vals-fl = '1'.
node_vals-val = '02.02.2012;'.

APPEND node_vals.

node_vals-fl = '2'.

node_vals-val = '25.07.2012;'.

APPEND node_vals.

node_vals-fl = bc_const-add_layer.

node_vals-val = '01'.

APPEND node_vals.

Generated by Jive on 2014-07-12+02:00


23
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.

positions-row_number = 2.

APPEND positions.

*----------------------------------------------------------------------*

nodes-id = 3.
nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.

node_vals-fl = '1'.

node_vals-val = '01.04.2012;'.

APPEND node_vals.

node_vals-fl = '2'.

node_vals-val = '25.09.2012;'.

APPEND node_vals.

node_vals-fl = bc_const-add_layer.

node_vals-val = '02'.

APPEND node_vals.

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.

positions-row_number = 3.

APPEND positions.

Generated by Jive on 2014-07-12+02:00


24
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

*----------------------------------------------------------------------*

nodes-id = 4.

nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.
node_vals-chart_id = nodes-chart_id.

node_vals-fl = '1'.

node_vals-val = '11.02.2012;'.
APPEND node_vals.

node_vals-fl = '2'.

node_vals-val = '11.07.2012;'.

APPEND node_vals.

node_vals-fl = bc_const-add_layer.

node_vals-val = '00'.

APPEND node_vals.

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.
positions-row_number = 4.

APPEND positions.

*----------------------------------------------------------------------*

nodes-id = 5.

nodes-chart_id = chart.

APPEND nodes.

node_vals-id = nodes-id.

node_vals-chart_id = nodes-chart_id.

Generated by Jive on 2014-07-12+02:00


25
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

node_vals-fl = '1'.

node_vals-val = '01.05.2012;'.

APPEND node_vals.

node_vals-fl = '2'.

node_vals-val = '11.12.2012;'.
APPEND node_vals.

node_vals-fl = bc_const-add_layer.
node_vals-val = '01'.

APPEND node_vals.

positions-obj_id = nodes-id.

positions-obj_type = bc_const-node_object.

positions-chart_id = nodes-chart_id.

positions-row_number = 5.

APPEND positions.

ENDFORM.

MODULE graphic_pbo OUTPUT.

CALL FUNCTION 'BARC_GRAPHIC_PBO'

EXPORTING

abap_cmd = abap_cmd

confirm = 'X'

profile = graph_profile

stat = stat

status_text = status_text

control_handle = barc_ocx

TABLES

boxes = boxes

Generated by Jive on 2014-07-12+02:00


26
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

box_vals = box_vals

deletions = deletions

links = links

link_vals = link_vals

nodes = nodes

node_vals = node_vals
positions = positions

EXCEPTIONS

err_in_profile = 1
inv_profile =2

inv_winid = 3.

ENDMODULE.

MODULE status_0100 OUTPUT.

SET PF-STATUS 'GRAFIK'.

SET TITLEBAR '100'.

ENDMODULE.

MODULE user_command_0100 INPUT.

DATA: retval TYPE i.

save_ok_code = ok_code.

CLEAR ok_code.

CASE save_ok_code.

WHEN 'EXIT'.

PERFORM end_100.

WHEN 'QUIT'.

PERFORM end_100.

WHEN 'BACK'.

Generated by Jive on 2014-07-12+02:00


27
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

PERFORM end_100.

WHEN OTHERS.

IF save_ok_code(4) = sgrc_const-event

OR save_ok_code(4) = sgrc_const-shell_event.

* Event Double Click

PERFORM user_command.
ELSE. "function Code

* Otherwise function code passed to graphics

CALL FUNCTION 'BARCHART_SET_FUNCTION_CODE'


EXPORTING

handle = barc_ocx

function_code = save_ok_code

IMPORTING

return = retval.

IF retval = 0.

* If data changes associated with function code

PERFORM user_command.

IF abap_cmd = bc_const-get_selection

OR abap_cmd = bc_const-get_overlap

OR abap_cmd = bc_const-get_settings
OR abap_cmd = bc_const-get_color.

CALL FUNCTION 'BARC_GRAPHIC_PBO'

EXPORTING

abap_cmd = abap_cmd

stat = stat

control_handle = barc_ocx.

PERFORM user_command.

Generated by Jive on 2014-07-12+02:00


28
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

ENDIF.

ELSE.

stat = sgrc_const-stat_4. "Wait for input

ENDIF.

ENDIF.

ENDCASE.

ENDMODULE.

FORM end_100.

CALL FUNCTION 'BARC_GRAPHIC_PAI'

EXPORTING

control_handle = barc_ocx

at_control_destroy = sgrc_const-yes.

CALL FUNCTION 'CONTROL_DESTROY'


CHANGING

h_control = barc_ocx

EXCEPTIONS

OTHERS = 1.

SET SCREEN 0.

LEAVE SCREEN.

ENDFORM.

Generated by Jive on 2014-07-12+02:00


29
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

FORM user_command.

* Evaluation of the data from the graphic

CALL FUNCTION 'BARC_GRAPHIC_PAI'

EXPORTING

control_handle = barc_ocx
IMPORTING

graph_cmd = graph_cmd

graph_cmd_info = graph_cmd_info
gr_sel_field = gr_sel_field

layer_type = layer_kind

settings = settings

symboltype = symboltype

TABLES

boxes = boxes

box_vals = box_vals

deletions = deletions

links = links

link_vals = link_vals

nodes = nodes

node_vals = node_vals

positions = positions
EXCEPTIONS

inv_winid = 1.

CLEAR: abap_cmd,

status_text.

stat = sgrc_const-stat_4. "Wait for input

* Evaluation of user commands

CASE graph_cmd.

Generated by Jive on 2014-07-12+02:00


30
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

WHEN bc_const-ask_for_delete.

abap_cmd = graph_cmd.

WHEN bc_const-ask_for_scaleleft.

abap_cmd = graph_cmd.

WHEN bc_const-ask_for_scaleright.

abap_cmd = graph_cmd.

WHEN bc_const-ask_for_back.

abap_cmd = graph_cmd.

WHEN bc_const-ask_for_quit.

abap_cmd = graph_cmd.

WHEN bc_const-ask_for_exit.

abap_cmd = graph_cmd.

ENDCASE.

CALL FUNCTION 'BARC_LOGIC'


EXPORTING

graph_cmd = graph_cmd

TABLES

all_boxes = all_boxes

all_box_vals = all_box_vals

all_links = all_links

all_link_vals = all_link_vals

all_nodes = all_nodes

all_node_vals = all_node_vals

all_positions = all_positions

Generated by Jive on 2014-07-12+02:00


31
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

boxes = boxes

box_vals = box_vals

deletions = deletions

links = links

link_vals = link_vals

nodes = nodes
node_vals = node_vals

positions = positions.

ENDFORM.
///////////////////////////////////////////////////////////////////////////////////////////////////////

Lesson -2 will teach you all about Bar Chart Profile & making an interactive planning board.

1. Graph title appears in the window title bar

1963 Views Tags: abap, graphics, graphical, production_planning, planning_board, bar_chart,


graphic_function_module

Manish Meshram
Nov 10, 2013 8:30 AM
Can you share where is 2nd lesson link on portal.

Regards
Manis

Manish Kumar in response to Manish Meshram on page 32


Nov 9, 2013 3:41 PM
Manish, your comment is in response to Nilesh, but it looks like question is meant for blog author.
You could have directly commented on blog instead of replying to existing comment.

Looking at Author's content list, it is clear that lesson 2 does not exist.

Manish Meshram in response to nilesh shrivastava on page 32


Nov 9, 2013 2:53 PM
Can you share where is 2nd lesson link on portal.

Regards
Manish

nilesh shrivastava
Dec 2, 2012 5:17 AM

Generated by Jive on 2014-07-12+02:00


32
ABAP Development: Using SAP Bar Chart Graphics (Lesson-1)

sir where to add these codes.

Generated by Jive on 2014-07-12+02:00


33

Вам также может понравиться