Posted: Mon Nov 05, 2007 3:13 pm Post subject: Demo: GFW: A simple hierarchy graphic using SAP Tree
Code:
REPORT GFW_DEMO_HIER1 .
***********************************************************************
* 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_HIER.
CLASS CL_GUI_CFW DEFINITION LOAD.
CLASS CL_GFW_MUX DEFINITION LOAD.
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_HIER,
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_HIER,
cuobj_leave TYPE REF TO CL_CU_POINT,
ITEM_LIST TYPE GFW_ITEM_ATTRIB_LIST,
item_name type gfw_item_attrib
.
* 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_HIER IMPORTING EVENT.
ENDCLASS.
CLASS LCL_MAIN IMPLEMENTATION.
METHOD ON_CLOSED.
LEAVE PROGRAM.
ENDMETHOD.
ENDCLASS.
DATA: MAIN TYPE REF TO LCL_MAIN.
START-OF-SELECTION.
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 DC
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 occurred while creating
" the container
* create, initialize and activate graphic proxy
CREATE OBJECT GP_INST EXPORTING AUTO_LINK = GFW_TRUE.
CALL METHOD GP_INST->IF_GRAPHIC_PROXY~INIT
EXPORTING parent = CUSTOM_CONTAINER
DC = DC_INST
PROD_ID = CL_GUI_GP_HIER=>CO_PROD_SAPTREE
IMPORTING RETVAL = RETVAL.
IF RETVAL = CL_GFW=>OK.
* set DC attributes
refresh item_list. clear item_name.
item_name-no = 1.
item_name-name = 'NODE_TEXT0'.
insert item_name into table item_list.
CALL METHOD GP_INST->SET_DC_NAMES
EXPORTING
OBJ_ID = 'OBJID'
PRED = 'PRED'
OBJREF_ID = 'CU_REFOBJ'
ITEM_LIST = ITEM_LIST
IMPORTING RETVAL = RETVAL.
ENDIF. "// set dc attributes
IF RETVAL = CL_GFW=>OK.
* mark leaves to be not expandable
CREATE OBJECT CUOBJ_LEAVE
EXPORTING INSTANCE_ID = 'GFW_DEMO_HIER1'.
CALL METHOD CUOBJ_LEAVE->IF_CUSTOMIZING~SET
EXPORTING ATTR_ID = cl_cu_point=>CO_EXPANDABLE
VALUE = gfw_false.
CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
EXPORTING PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART
KEY = 'LEAVE' "#EC NOTEXT
BUNDLE = CUOBJ_LEAVE
IMPORTING RETVAL = RETVAL.
ENDIF.
IF RETVAL = CL_GFW=>OK.
CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ACTIVATE
IMPORTING RETVAL = RETVAL.
ENDIF.
IF RETVAL <CL_GFW>OK.
* don't cut&paste this call in end user applications!!!
* (user would be confused by technical message)
* raise application specific message instead, please
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.
* don't cut&paste this call in end user applications!!!
* (user would be confused by technical message)
* raise application specific message instead, please
CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
ENDIF.
ENDIF.
* **** activate mux (handling of external graphics and interactions)
CALL METHOD CL_GFW_MUX=>ACTIVATE IMPORTING RETVAL = RETVAL.
IF RETVAL <CL_GFW>OK.
* don't cut&paste this call in end user applications!!!
* (user would be confused by technical message)
* raise application specific message instead, please
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'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'DOCU'.
ID = 'RE'. LANGU = SY-LANGU. OBJECT = 'GFW_DEMO_HIER1'.
* display program documentation
CALL FUNCTION 'DOCU_CALL'
EXPORTING
DISPL = 'X' "//show mode
DISPL_MODE = '2' "//like F1 help
ID = ID
LANGU = LANGU
OBJECT = OBJECT.
ENDCASE.
ENDMODULE. " PAI_0100 INPUT
*&---------------------------------------------------------------------*
*& Form FILL_DC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <p2>E_GP_DCHANDLE.
EXIT.
ENDIF.
RETVAL = CL_GFW=>OK.
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.