Posted: Mon Nov 05, 2007 3:51 pm Post subject: Demo: GFW: a scatter chart with time axis
Code:
report gfw_prog_time_axis .
* data container
include gfw_dc_pres.
* text constants
include gfw_prog_text.
data: ok_code type sy-ucomm, firstcall type i,
custom_container type ref to cl_gui_custom_container,
dc_inst type ref to lcl_dc_pres,
dc_manage type ref to if_dc_management,
my_id_at_dc type i, retval type symsgno,
gp_inst type ref to cl_gui_gp_pres.
start-of-selection.
* USAGE allowed in SAP internal test reports, only
include applg_auto_test_init.
call screen 100.
* USAGE allowed in SAP internal test reports, only
include applg_auto_test_form.
*&---------------------------------------------------------------------*
*& Module PBO_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module pbo_0100 output.
set pf-status '100'.
retval = cl_gfw=>ok.
if firstcall is initial.
* create, initialize and fill data container
create object dc_inst.
dc_manage = dc_inst.
call method dc_manage->init importing id = my_id_at_dc
retval = retval.
if retval <cl_gfw>ok.
call method cl_gfw=>show_msg exporting msgno = retval.
clear dc_inst.
clear dc_manage.
else.
perform fill_dc changing retval.
if retval <cl_gfw>ok.
call method cl_gfw=>show_msg exporting msgno = retval.
else.
* create a container on the dynpro
create object custom_container exporting
container_name = 'CONTAINER'.
* create, initialize and activate graphics proxy
create object gp_inst.
call method gp_inst->if_graphic_proxy~init
exporting parent = custom_container
dc = dc_inst
prod_id = cl_gui_gp_pres=>co_prod_chart
force_prod = gfw_true
importing retval = retval.
if retval = cl_gfw=>ok.
* set dc attributes
call method gp_inst->set_dc_names
exporting
obj_id = 'OBJID'
dim1 = 'X_VAL'
dim2 = 'Y_VAL'
grp_id = 'GRPID'
objref_id = 'CU_REFOBJ'
importing retval = retval.
endif. "// set dc attributes
* set customizing objects
if retval = cl_gfw=>ok.
perform set_customizing.
endif.
if retval = cl_gfw=>ok.
call method gp_inst->if_graphic_proxy~activate
importing retval = retval.
endif.
if retval <cl_gfw>ok.
call method cl_gfw=>show_msg exporting msgno = retval.
endif.
endif. "//fill_dc ok
firstcall = 1.
endif. "//create and init dc ok
endif.
* **** distribute changes (to all subscribed graphics proxies)
if not dc_manage is initial.
call method dc_manage->distribute_changes
importing retval = retval.
if retval <cl_gfw>ok.
call method cl_gfw=>show_msg exporting msgno = retval.
endif.
endif.
* USAGE allowed in SAP internal test reports, only
perform auto_test_pbo using 'EXIT'.
endmodule. " PBO_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module PAI_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module pai_0100 input.
ok_code = sy-ucomm.
* activate event analysis of object-oriented Control Framework
call method cl_gui_cfw=>dispatch.
* handle other events
case ok_code.
when 'BACK'.
call method gp_inst->if_graphic_proxy~free
importing retval = retval.
leave program.
when 'EXIT'.
call method gp_inst->if_graphic_proxy~free
importing retval = retval.
leave program.
endcase.
endmodule. " PAI_0100 INPUT
*&---------------------------------------------------------------------*
*& Form FILL_DC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <p2>e_gp_dchandle.
exit.
endif.
retval = cl_gfw=>ok.
*&---------------------------------------------------------------------*
*& Form SET_CUSTOMIZING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <p2>if_customizing~set
exporting attr_id = cl_cu_display_context=>co_bg_clr_plt_id
value = 18. " grey
* disable lines
call method bundle_display->if_customizing~set
exporting attr_id = cl_cu_display_context=>co_bl_style
value = 1. " no line
* tell the proxy where to use the bundle
call method gp_inst->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_diagram
bundle = bundle_display
importing retval = retval.
* drawing area (used to set chart title)
create object bundle_drawing exporting instance_id = 'GFWTA'.
* set title
call method bundle_drawing->if_customizing~set
exporting attr_id = cl_cu_drawing_area=>co_title
value = co_gfw_prog_title_time_axis.
* tell the proxy where to use the bundle
call method gp_inst->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
bundle = bundle_drawing
importing retval = retval.
* set color of line and markers
call method bundle_display->if_customizing~set
exporting attr_id = cl_cu_display_context=>co_bl_clr_plt_id
value = 7. " red
call method bundle_display->if_customizing~set
exporting attr_id = cl_cu_display_context=>co_mr_bg_clr_plt_id
value = 7. " red
* copy display context into values
call method bundle_values1->if_customizing~set
exporting attr_id = cl_cu_values=>co_curve_context
value = bundle_display.
* set chart type
call method bundle_values1->if_customizing~set
exporting attr_id = cl_cu_values=>co_style
value = 34. " xy scatter
* tell the proxy where to use the bundle
call method gp_inst->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = co_gfw_prog_series1
bundle = bundle_values1
importing retval = retval.
* set color of line and markers
call method bundle_display->if_customizing~set
exporting attr_id = cl_cu_display_context=>co_bl_clr_plt_id
value = 3. " blue
call method bundle_display->if_customizing~set
exporting attr_id = cl_cu_display_context=>co_mr_bg_clr_plt_id
value = 3. " blue
* copy display context into values
call method bundle_values2->if_customizing~set
exporting attr_id = cl_cu_values=>co_curve_context
value = bundle_display.
* set chart type
call method bundle_values2->if_customizing~set
exporting attr_id = cl_cu_values=>co_style
value = 34. " xy scatter
* tell the proxy where to use the bundle
call method gp_inst->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = co_gfw_prog_series2
bundle = bundle_values2
importing retval = retval.
* point (used to create a gap in series 1)
create object bundle_point exporting instance_id = 'GFWTA'.
* prepare display context for point
create object bundle_display exporting instance_id = 'dummy'.
* disable line segment
call method bundle_display->if_customizing~set
exporting attr_id = cl_cu_display_context=>co_bl_style
value = 1. " no line
* set color of marker
call method bundle_display->if_customizing~set
exporting attr_id = cl_cu_display_context=>co_mr_bg_clr_plt_id
value = 7. " red
* copy display context into values
call method bundle_point->if_customizing~set
exporting attr_id = cl_cu_point=>co_display_context
value = bundle_display.
* tell the proxy where to use the bundle
call method gp_inst->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = co_gfw_prog_objid_4
bundle = bundle_point
importing retval = retval.
* tell the proxy where to use the bundle
call method gp_inst->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart_x_prim_axis
bundle = bundle_axis_x
importing retval = retval.
* The following scale bundles can be used to customize all time bar
* settings (e.g. start date, day width etc.)
* The first scale bundle the gp gets (via add_cu_bundle) is used
* for all settings of the minor scale.
* The second scale bundle the gp gets is used for all settings of
* the major scale.
* If you set only one scale bundle the gp uses it for both scales,
* minor and major.
****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
GFW_PROG_TIME_AXIS
0100
620
40
%_HEADER
GFW_PROG_TIME_AXIS 0100 0100 19 75192 35 0 0 19 75 0G E 20001113152510
%_DESCRIPTION
%_FIELDS
CONTAINER 75 00 30 00 30 00 1 2 0 0 0 19 U 1 1 101
CHAR 20 80 10 00 00 00 255 1 O 0 0 0 0 0 0 ____________________
%_FLOWLOGIC
PROCESS BEFORE OUTPUT.
MODULE PBO_0100.
*
PROCESS AFTER INPUT.
MODULE PAI_0100.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.