Posted: Mon Nov 05, 2007 3:39 pm Post subject: Demo: Business Graphics with GFW
Code:
REPORT GFW_DEMO_PRES1 .
***********************************************************************
* This is a program to demonstrate the functionality of the
* Graphical Framework (GFW).
* This is not a programming example. If you want to learn how to
* use the GFW in your own programs please take a closer look at our
* programming examples (with prefix GFW_PROG_).
***********************************************************************
* texts for example programs of GFW
INCLUDE GFW_PROG_TEXT.
* data container (DC)
INCLUDE GFW_DC_PRES.
DATA: OK_CODE TYPE SY-UCOMM,
ID TYPE DOKHL-ID,
LANGU TYPE DOKHL-LANGU,
OBJECT TYPE DOKHL-OBJECT,
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,
EVTCODE_LIST TYPE CNTL_SIMPLE_EVENTS,
SIMPLE_EVENT type CNTL_SIMPLE_EVENT.
* main class needed to catch gui events
CLASS LCL_MAIN DEFINITION.
PUBLIC SECTION.
METHODS: ON_CLOSED FOR EVENT IF_GRAPHIC_PROXY~GRAPHIC_CLOSED
OF CL_GUI_GP_PRES IMPORTING EVENT.
ENDCLASS.
CLASS LCL_MAIN IMPLEMENTATION.
METHOD ON_CLOSED.
CALL METHOD GP_INST->IF_GRAPHIC_PROXY~FREE
IMPORTING RETVAL = RETVAL.
LEAVE PROGRAM.
ENDMETHOD.
ENDCLASS.
DATA: MAIN TYPE REF TO LCL_MAIN.
START-OF-SELECTION.
* fill table of event codes for graphics proxy (optional)
* use application event (PAI/PBO processing to reach distribute_changes)
* for value changes:
simple_event-appl_event = 'X'.
simple_event-EVENTID = IF_GRAPHIC_PROXY=>CO_EVT_VALUE_CHANGED.
APPEND simple_event TO EVTCODE_LIST.
* use system event (no PAI processing) for customizing changes:
*simple_event-appl_event = space.
simple_event-EVENTID = IF_GRAPHIC_PROXY=>CO_EVT_CUSTOM_CHANGED.
APPEND simple_event TO EVTCODE_LIST.
CREATE OBJECT MAIN.
SET HANDLER MAIN->ON_CLOSED FOR ALL INSTANCES.
* 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 container in which to place graphic
* (place it in the custom control named CONTAINER
* defined using screenpainter in dynpro 100)
CREATE OBJECT CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER'. "use uppercase letters!
" there will be a RABAX here if any error occured while creating
" the 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
* prod_id = cl_gui_gp_pres=>co_prod_sapocx
* prod_id = cl_gui_gp_pres=>co_prod_sap
EVTCODE_LIST = EVTCODE_LIST
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'
TEXT = 'TEXT'
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.
* **** activate mux (handling of external graphics and synchronizations)
CALL METHOD CL_GFW_MUX=>ACTIVATE IMPORTING RETVAL = RETVAL.
IF RETVAL <CL_GFW>OK.
CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
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.
WHEN 'DOCU'.
ID = 'RE'. LANGU = SY-LANGU. OBJECT = 'GFW_DEMO_PRES1'.
* display program documentation
CALL FUNCTION 'DOCU_CALL'
EXPORTING
DISPL = 'X' "//show mode
DISPL_MODE = '2' "//like F1 help
ID = ID
LANGU = LANGU
OBJECT = OBJECT.
WHEN 'SAVECU'.
CALL METHOD GP_INST->IF_GRAPHIC_PROXY~SAVE_CUSTOMIZING
IMPORTING RETVAL = RETVAL.
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 = '100'.
obj-grpid = co_gfw_prog_series1.
obj-x_val = co_gfw_prog_category1.
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.
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.