SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Demo: GFW: a scatter chart with time axis



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming -> Graphics
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Mon Nov 05, 2007 3:51 pm    Post subject: Demo: GFW: a scatter chart with time axis Reply with quote

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.

* insert first group (corresponding customizing class: cl_cu_values)
  obj-objid = co_gfw_prog_objid_1.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19980101100000'. "#EC NOTEXT
  obj-y_val = 10.
  call method dc_inst->set_obj_values
    exporting id     = my_id_at_dc
              obj    = obj
    importing retval = retval.
  if retval <cl_gfw>ok. exit. endif.

  obj-objid = co_gfw_prog_objid_2.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19980115100000'. "#EC NOTEXT
  obj-y_val = 30.
  call method dc_inst->set_obj_values
    exporting id     = my_id_at_dc
              obj    = obj
    importing retval = retval.
  if retval <cl_gfw>ok. exit. endif.

  obj-objid = co_gfw_prog_objid_3.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19980305100000'. "#EC NOTEXT
  obj-y_val = 50.
  call method dc_inst->set_obj_values
    exporting id     = my_id_at_dc
              obj    = obj
    importing retval = retval.
  if retval <cl_gfw>ok. exit. endif.

  obj-objid = co_gfw_prog_objid_4.
  obj-cu_refobj = co_gfw_prog_objid_4. " connection to a cl_cu_point
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19980320100000'. "#EC NOTEXT
  obj-y_val = 20.
  call method dc_inst->set_obj_values
    exporting id     = my_id_at_dc
              obj    = obj
    importing retval = retval.
  if retval <cl_gfw>ok. exit. endif.

  obj-objid = co_gfw_prog_objid_5.
  clear obj-cu_refobj.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19980501100000'. "#EC NOTEXT
  obj-y_val = 40.
  call method dc_inst->set_obj_values
    exporting id     = my_id_at_dc
              obj    = obj
    importing retval = retval.
  if retval <cl_gfw>ok. exit. endif.



* insert second group (corresponding customizing class: cl_cu_values)
  obj-objid = co_gfw_prog_objid_6.
  obj-grpid = co_gfw_prog_series2.
  obj-x_val = '19980105100000'. "#EC NOTEXT
  obj-y_val = 15.
  call method dc_inst->set_obj_values
    exporting id     = my_id_at_dc
              obj    = obj
    importing retval = retval.
  if retval <cl_gfw>ok. exit. endif.

  obj-objid = co_gfw_prog_objid_7.
  obj-grpid = co_gfw_prog_series2.
  obj-x_val = '19980315100000'. "#EC NOTEXT
  obj-y_val = 25.
  call method dc_inst->set_obj_values
    exporting id     = my_id_at_dc
              obj    = obj
    importing retval = retval.
  if retval <cl_gfw>ok. exit. endif.

  obj-objid = co_gfw_prog_objid_8.
  obj-grpid = co_gfw_prog_series2.
  obj-x_val = '19980401100000'. "#EC NOTEXT
  obj-y_val = 40.
  call method dc_inst->set_obj_values
    exporting id     = my_id_at_dc
              obj    = obj
    importing retval = retval.
  if retval <cl_gfw>ok. exit. endif.
endform.                    " FILL_DC

*&---------------------------------------------------------------------*
*&      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.



* values (group 1)
  create object bundle_values1 exporting instance_id = 'GFWTA1'.

* prepare display context for values
  create object bundle_display exporting instance_id = 'dummy'.

* 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.



* values (group 2)
  create object bundle_values2 exporting instance_id = 'GFWTA2'.

* prepare display context for values
  create object bundle_display exporting instance_id = 'dummy'.

* 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.



* primary x-axis
  create object bundle_axis_x exporting instance_id = 'GFWTA_X'.

* prepare display context for axis title
  create object bundle_display exporting instance_id = 'dummy'.

* disable axis title
  call method bundle_display->if_customizing~set
    exporting attr_id = cl_cu_display_context=>co_visibility
              value   = gfw_false.

* copy display context into axis
  call method bundle_axis_x->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_title_context
              value   = bundle_display.

* set date/time axis
  call method bundle_axis_x->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_scale_style
              value   = 3. " date/time axis

* enable scrollbar
  call method bundle_axis_x->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_day_width_auto
              value   = gfw_false.
  call method bundle_axis_x->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_day_width
              value   = 300.

* 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.

** x-axis minor scale
*  CREATE OBJECT BUNDLE_SCALE1_X EXPORTING INSTANCE_ID = 'GFWTA_X1'.
*  CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
*    EXPORTING PORT   = IF_GRAPHIC_PROXY=>CO_PORT_CHART_X_PRIM_AXIS
*              BUNDLE = BUNDLE_SCALE1_X
*    IMPORTING RETVAL = RETVAL.
*
** x-axis major scale
*  CREATE OBJECT BUNDLE_SCALE2_X EXPORTING INSTANCE_ID = 'GFWTA_X2'.
*  CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
*    EXPORTING PORT   = IF_GRAPHIC_PROXY=>CO_PORT_CHART_X_PRIM_AXIS
*              BUNDLE = BUNDLE_SCALE2_X
*    IMPORTING RETVAL = RETVAL.

endform.                    " SET_CUSTOMIZING

****************************************************************
* 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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming -> Graphics All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.