Posted: Mon Nov 05, 2007 3:53 pm Post subject: Demo: GFW tutorial: a simple business graphic
Code:
REPORT GFW_PROG_TUTORIAL .
* ------------------------------------------------------------
* This program is the solution to the GFW tutorial.
* Please see KEN documentation (BC-FES-GRA "SAP Graphics")
* for details.
* ------------------------------------------------------------
* provide direct access to global classes
CLASS CL_GUI_CFW DEFINITION LOAD.
CLASS CL_GFW_MUX DEFINITION LOAD.
* data container (lcl_dc_pres)
INCLUDE GFW_DC_PRES.
DATA: RETVAL TYPE SYMSGNO,
OK_CODE TYPE SY-UCOMM.
DATA: DC_INST TYPE REF TO LCL_DC_PRES, "// dc instance
DC_MANAGE TYPE REF TO IF_DC_MANAGEMENT, "// dc interface handle
MY_ID_AT_DC TYPE I. "// dc id
DATA: CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
"//object to place graphic
GP_INST TYPE REF TO CL_GUI_GP_PRES. "// gp instance
* application code
CLASS LCL_THIS_APPLICATION DEFINITION.
PUBLIC SECTION.
METHODS: FILL_DC
IMPORTING DC_MANAGE TYPE REF TO IF_DC_MANAGEMENT
EXPORTING RETVAL TYPE SYMSGNO.
ENDCLASS.
DATA THIS_APPLICATION TYPE REF TO LCL_THIS_APPLICATION.
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'.
SET TITLEBAR '100'.
* check whether application instance exists
IF THIS_APPLICATION IS INITIAL.
CREATE OBJECT THIS_APPLICATION.
ENDIF.
RETVAL = CL_GFW=>OK.
IF DC_MANAGE IS INITIAL.
* create and initialize data container
CREATE OBJECT DC_INST.
IF SY-SUBRC <0>IF_GRAPHIC_PROXY~INIT
EXPORTING DC = DC_INST
PARENT = CUSTOM_CONTAINER
prod_id = cl_gui_gp_pres=>co_prod_chart
IMPORTING RETVAL = RETVAL.
IF RETVAL = CL_GFW=>OK.
* set DC names
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 names
IF RETVAL <CL_GFW>OK.
CALL METHOD GP_INST->IF_GRAPHIC_PROXY~FREE.
"//ignore return value(keep 1st)
CLEAR GP_INST.
ELSE.
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. "//create, initialize and activate graphic proxy
* **** 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 synchronization)
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 'EXIT'. LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " PAI_0100 INPUT
* ----------------------------------------------------------------------
* APPLICATION CLASS implementation
* ----------------------------------------------------------------------
CLASS LCL_THIS_APPLICATION IMPLEMENTATION.
METHOD FILL_DC.
DATA obj type gfwdcpres.
RETVAL = CL_GFW=>OK.
* fill DC with initial data
IF DC_MANAGE IS INITIAL.
RETVAL = CL_GFW=>E_GP_DCHANDLE.
EXIT.
ENDIF.
* there are two ways of filling a DC
* a) using the interface method SET_VALUE
* b) using (class-specific) method of DC: SET_OBJ_VALUES
* use a) to insert first object
CALL METHOD DC_MANAGE->SET_VALUE EXPORTING ID = MY_ID_AT_DC
ATTRIBUTE = 'OBJID'
FIELD_VALUE = '100'
IMPORTING RETVAL = RETVAL.
IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
CALL METHOD DC_MANAGE->SET_VALUE EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = '100'
ATTRIBUTE = 'GRPID'
FIELD_VALUE = '1'
IMPORTING RETVAL = RETVAL.
IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
* skip filter
CALL METHOD DC_MANAGE->SET_VALUE EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = '100'
ATTRIBUTE = 'X_VAL'
FIELD_VALUE = '1998'
IMPORTING RETVAL = RETVAL.
IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
CALL METHOD DC_MANAGE->SET_VALUE EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = '100'
ATTRIBUTE = 'Y_VAL'
FIELD_VALUE = 50
IMPORTING RETVAL = RETVAL.
IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
* skip z_val
CALL METHOD DC_MANAGE->SET_VALUE EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = '100'
ATTRIBUTE = 'TEXT'
FIELD_VALUE = 'SET_VALUE'
IMPORTING RETVAL = RETVAL.
IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
* skip other attributes
* insert 2nd object using b)
clear obj.
obj-OBJID = '200'.
obj-grpid = '1'.
obj-x_val = '1999'.
obj-y_val = 100.
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 3rd object using b)
clear obj.
obj-OBJID = '300'.
obj-grpid = '1'.
obj-x_val = '2000'.
obj-y_val = 70.
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.
ENDMETHOD. "//fill_dc
ENDCLASS.
*GUI Texts
*----------------------------------------------------------
* 100 --> Sample Graphical Framework Program
* 100 --> Sample Graphical Framework Program
****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
GFW_PROG_TUTORIAL
0100
620
40
%_HEADER
GFW_PROG_TUTORIAL 0100 0100 18 69192 35 0 0 15 65 0G E 20001113152510
%_DESCRIPTION
Main Screen
%_FIELDS
TXT1 CHAR 30 00 00 00 30 00 1 2 0 0 0 0 0 0 Here is a business graphic:
TXT2 CHAR 13 00 00 00 30 00 2 2 0 0 0
GRAPHIC 37 00 00 00 30 00 2 16 0 0 0
TXT3 CHAR 13 00 00 00 30 00 2 54 0 0 0
TXT4 CHAR 22 00 00 00 30 00 15 16 0 0 0
CHAR 20 80 10 00 00 00 255 1 O 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.