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

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

Code:

REPORT GFW_PROG_COLUMNS_AND_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 graphic 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'
                    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.
      FIRSTCALL = 1.
    ENDIF.
  ENDIF.


* **** distribute changes (to all subscribed graphic 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.


  obj-objid = '100'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990412000000'. " format: YYYYMMDDHHMMSS
  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 = '101'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990413000000'. " format: YYYYMMDDHHMMSS
  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 = '102'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990414000000'. " format: YYYYMMDDHHMMSS
  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 = '103'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990415000000'. " format: YYYYMMDDHHMMSS
  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 = '104'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990416000000'. " format: YYYYMMDDHHMMSS
  obj-y_val = 35.
  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 = '105'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990417000000'. " format: YYYYMMDDHHMMSS
  obj-y_val = 0.
  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 = '106'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990418000000'. " format: YYYYMMDDHHMMSS
  obj-y_val = 0.
  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 = '107'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990419000000'. " format: YYYYMMDDHHMMSS
  obj-y_val = 35.
  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 = '108'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990420000000'. " format: YYYYMMDDHHMMSS
  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 = '109'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990421000000'. " format: YYYYMMDDHHMMSS
  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 = '110'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990422000000'. " format: YYYYMMDDHHMMSS
  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 = '111'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990423000000'. " format: YYYYMMDDHHMMSS
  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 = '112'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990424000000'. " format: YYYYMMDDHHMMSS
  obj-y_val = 0.
  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 = '113'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990425000000'. " format: YYYYMMDDHHMMSS
  obj-y_val = 0.
  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.

* GRP 1 OBJID 500
* this last point only defines the right border of the last
* histogram class (i.e. you can omit an y_val)
  obj-objid = '200'.
  obj-grpid = co_gfw_prog_series1.
  obj-x_val = '19990425235959'. " format: YYYYMMDDHHMMSS
  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_bl_style
              VALUE   = 1. " no line

* copy display context into drawing area
  CALL METHOD bundle_drawing->IF_CUSTOMIZING~SET
    exporting ATTR_ID = cl_cu_drawing_area=>co_display_context
              VALUE   = BUNDLE_DISPLAY.

* set title
  CALL METHOD BUNDLE_DRAWING->IF_CUSTOMIZING~SET
    EXPORTING ATTR_ID = CL_CU_DRAWING_AREA=>CO_TITLE
              VALUE   = co_gfw_prog_title_columns_ta
    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
              BUNDLE = BUNDLE_DRAWING
    IMPORTING RETVAL = RETVAL.




* values/general
  CREATE OBJECT BUNDLE_VALUES EXPORTING INSTANCE_ID = 'GFWCOLTA'.

* prepare display context for values
  CREATE OBJECT BUNDLE_DISPLAY EXPORTING INSTANCE_ID = 'dummy'.

* set color of data series
  CALL METHOD bundle_display->IF_CUSTOMIZING~SET
    EXPORTING ATTR_ID = cl_cu_display_context=>co_bg_clr_plt_id
              VALUE   = 5. " green

* copy display context into values
  CALL METHOD BUNDLE_VALUES->IF_CUSTOMIZING~SET
    exporting ATTR_ID = cl_cu_values=>co_curve_context
              VALUE   = BUNDLE_DISPLAY.

* prepare standard distribution context for values
  CREATE OBJECT BUNDLE_DISPLAY EXPORTING INSTANCE_ID = 'dummy'.

* set invisible
  CALL METHOD bundle_display->IF_CUSTOMIZING~SET
    EXPORTING ATTR_ID = cl_cu_display_context=>co_visibility
              VALUE   = gfw_false.

* copy display context into values
  CALL METHOD BUNDLE_VALUES->IF_CUSTOMIZING~SET
    exporting ATTR_ID = cl_cu_values=>co_std_distrib_context
              VALUE   = BUNDLE_DISPLAY.

* set chart type
  CALL METHOD BUNDLE_VALUES->IF_CUSTOMIZING~SET
    EXPORTING ATTR_ID = CL_CU_VALUES=>CO_STYLE
              VALUE   = 88. " HistogramByRect

* 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_VALUES
    IMPORTING RETVAL = RETVAL.




* primary x-axis
  CREATE OBJECT BUNDLE_AXIS_X EXPORTING INSTANCE_ID = 'GFWCO_X'.

* 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

* prepare display context for axis title
  CREATE OBJECT BUNDLE_DISPLAY EXPORTING INSTANCE_ID = 'dummy'.

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

* tell the proxy where to use the axis 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.




* primary y-axis
  CREATE OBJECT BUNDLE_AXIS_Y1 EXPORTING INSTANCE_ID = 'GFWCO_Y1'.

* set attributes of axis (title)
  call method bundle_axis_y1->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_title
              value   = co_gfw_prog_axis1.

* tell the proxy where to use the axis bundle
  CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
    EXPORTING PORT   = IF_GRAPHIC_PROXY=>CO_PORT_CHART_Y_PRIM_AXIS
              BUNDLE = BUNDLE_AXIS_Y1
    IMPORTING RETVAL = RETVAL.




* secondary y-axis
  CREATE OBJECT BUNDLE_AXIS_Y2 EXPORTING INSTANCE_ID = 'GFWCO_Y2'.

* set attributes of axis (title, range)
  call method bundle_axis_y2->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_title
              value   = co_gfw_prog_axis2.
  call method bundle_axis_y2->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_max_value_auto
              value   = gfw_false.
  call method bundle_axis_y2->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_max_value
              value   = 9.
  call method bundle_axis_y2->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_min_value_auto
              value   = gfw_false.
  call method bundle_axis_y2->if_customizing~set
    exporting attr_id = cl_cu_axis=>co_min_value
              value   = 2.



* prepare display context for axis title
  CREATE OBJECT BUNDLE_DISPLAY EXPORTING INSTANCE_ID = 'XXX'.

* enable visibility of axis title
  CALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SET
    EXPORTING ATTR_ID = CL_CU_DISPLAY_CONTEXT=>co_visibility
              VALUE = gfw_true.
* remove border around title
  CALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SET
    EXPORTING ATTR_ID = CL_CU_DISPLAY_CONTEXT=>co_bl_style
              VALUE = 1. " no line

* use this title context for primary and secondary axis title;
* copy display context into axis-instance
  CALL METHOD BUNDLE_AXIS_Y1->IF_CUSTOMIZING~SET
    exporting ATTR_ID = CL_CU_AXIS=>CO_TITLE_CONTEXT
              VALUE   = BUNDLE_DISPLAY.
  CALL METHOD BUNDLE_AXIS_Y2->IF_CUSTOMIZING~SET
    exporting ATTR_ID = CL_CU_AXIS=>CO_TITLE_CONTEXT
              VALUE   = BUNDLE_DISPLAY.

* tell the proxy where to use the axis bundle
  CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
    EXPORTING PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART_Y_SEC_AXIS
              BUNDLE = BUNDLE_AXIS_Y2
    IMPORTING RETVAL = RETVAL.




* secondary y-axis/scale 1
  CREATE OBJECT BUNDLE_SCALE1_Y EXPORTING INSTANCE_ID = 'GFWCO_Y1'.

* set attributes of scale (step size)
  call method bundle_scale1_y->if_customizing~set
    exporting attr_id = cl_cu_scale=>co_interval_auto
              value   = gfw_false.
  call method bundle_scale1_y->if_customizing~set
    exporting attr_id = cl_cu_scale=>co_step
              value   = 2.

* tell the proxy where to use the scale bundle
  CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
    EXPORTING PORT   = IF_GRAPHIC_PROXY=>CO_PORT_CHART_Y_SEC_AXIS
              BUNDLE = BUNDLE_SCALE1_y
    IMPORTING RETVAL = RETVAL.




* grid lines (of primary y-axis) are set to invisible
  CREATE OBJECT bundle_grid1 EXPORTING INSTANCE_ID = 'GFWCO_G1'.

* prepare display context for grid
  CREATE OBJECT BUNDLE_DISPLAY EXPORTING INSTANCE_ID = 'dummy'.

* primary grid lines should be invisible
  CALL METHOD bundle_display->IF_CUSTOMIZING~SET
    EXPORTING ATTR_ID = CL_CU_DISPLAY_CONTEXT=>co_visibility
              VALUE   = gfw_false.

* copy display context into grid (for major and minor lines)
  CALL METHOD bundle_grid1->IF_CUSTOMIZING~SET
    exporting ATTR_ID = cl_cu_grid=>co_major_context
              VALUE   = BUNDLE_DISPLAY.
  CALL METHOD bundle_grid1->IF_CUSTOMIZING~SET
    exporting ATTR_ID = cl_cu_grid=>co_minor_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_Y_PRIM_AXIS
              BUNDLE = bundle_grid1
    IMPORTING RETVAL = RETVAL.




* grid lines (of secondary y-axis) set to visible
  CREATE OBJECT bundle_grid2 EXPORTING INSTANCE_ID = 'GFWCO_G2'.

* prepare display context for grid
  CREATE OBJECT BUNDLE_DISPLAY EXPORTING INSTANCE_ID = 'dummy'.

* secondary major grid lines should be visible
  CALL METHOD bundle_display->IF_CUSTOMIZING~SET
    EXPORTING ATTR_ID = CL_CU_DISPLAY_CONTEXT=>co_visibility
              VALUE   = gfw_true.

* copy display context into grid
  CALL METHOD bundle_grid2->IF_CUSTOMIZING~SET
    exporting ATTR_ID = cl_cu_grid=>co_major_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_Y_SEC_AXIS
              BUNDLE = bundle_grid2
    IMPORTING RETVAL = RETVAL.


ENDFORM.                    " SET_CUSTOMIZING


****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
GFW_PROG_COLUMNS_AND_TIME_AXIS
0100
620
40
%_HEADER
GFW_PROG_COLUMNS_AND_TIME_AXIS 0100 0100 19 75192 35 0 0 21 83 0G E 20001113152509
%_DESCRIPTION

%_FIELDS
CONTAINER 75 00 30 00 30 00 1 2 0 0 0 19 U 1 1 102
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.