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 pie chart



 
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: 1640

PostPosted: Mon Nov 05, 2007 3:49 pm    Post subject: Demo: GFW: a pie chart Reply with quote

Code:

report gfw_prog_pie.

* 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
*&---------------------------------------------------------------------*
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
*&---------------------------------------------------------------------*
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
*&---------------------------------------------------------------------*
form fill_dc changing value(retval) type symsgno.
  data: obj type gfwdcpres.

* fill dc with initial data
  if dc_manage is initial.
    retval = cl_gfw=>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 = co_gfw_prog_long_category1.
  obj-y_val = 20.
  obj-cu_refobj = co_gfw_prog_objid_1. " connection to cl_cu_point
  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.
  clear obj-cu_refobj.

  obj-objid = co_gfw_prog_objid_2.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = co_gfw_prog_long_category2.
  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_3.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = co_gfw_prog_long_category3.
  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
*&---------------------------------------------------------------------*
form set_customizing.
  class cl_cu_drawing_area definition load.
  class cl_cu_values       definition load.
  class cl_cu_point        definition load.

  data: groups type gfw_grpid_list,
        points type gfw_refobj_list,
        title type gfwcuvac value co_gfw_prog_title_pie, "#EC NOTEXT
        bundle_display type ref to cl_cu_display_context,
        bundle type ref to if_customizing.

* let the proxy create customizing-bundles
  append co_gfw_prog_objid_1 to points. " for explosion of first piece
  append co_gfw_prog_series1 to groups.

  call method gp_inst->create_customizing
    exporting instance_id     = 'PIE'
              grpids          = groups
              pointids        = points
              title           = title
    importing retval          = retval.

  if retval <cl_gfw>ok.
    call method cl_gfw=>show_msg exporting msgno = retval.
    exit.
  endif.


* get values and set chart type
  call method gp_inst->if_graphic_proxy~get_cu_bundle
    exporting port        = if_graphic_proxy=>co_port_chart
              bundle_type = cl_cu=>co_clsid_values
              key         = co_gfw_prog_series1
    importing bundle      = bundle.
  call method bundle->set
    exporting attr_id = cl_cu_values=>co_style
              value   = 27. " pie

* get point and set explosion
  call method gp_inst->if_graphic_proxy~get_cu_bundle
    exporting port        = if_graphic_proxy=>co_port_chart
              bundle_type = cl_cu=>co_clsid_point
              key         = co_gfw_prog_objid_1
    importing bundle      = bundle.
  call method bundle->set
    exporting attr_id = cl_cu_point=>co_explosion
              value   = 10.

* get drawing area and remove border line
  call method gp_inst->if_graphic_proxy~get_cu_bundle
    exporting port        = if_graphic_proxy=>co_port_chart
              bundle_type = cl_cu=>co_clsid_drawing_area
    importing bundle      = bundle.
  call method bundle->get
    exporting attr_id = cl_cu_drawing_area=>co_display_context
    importing value   = bundle_display.
  call method bundle_display->if_customizing~set
    exporting attr_id = cl_cu_display_context=>co_le_style
              value   = 1. " none
  call method bundle->set
    exporting attr_id = cl_cu_drawing_area=>co_display_context
              value   = bundle_display.

endform.                    " SET_CUSTOMIZING

****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
GFW_PROG_PIE
0100
620
40
%_HEADER
GFW_PROG_PIE 0100 0100 19 75192 35 0 0 19 75 0G E 20001113152509
%_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.