Posted: Mon Nov 05, 2007 3:29 pm Post subject: Demo: GFW: a hierarchy/business graphic (Drag&Drop)
Code:
REPORT GFW_DEMO_HIER3 .
***********************************************************************
* 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_).
***********************************************************************
*-----------------------------------------------------------------------
* IMPORTANT technical hint:
* In this example the "auto_link" feature of the hierarchy graphics
* proxy is not used. Therefore the data container ist filled with links
* in addition to nodes.
* It's easier to use auto_link (see method CONSTRUCTOR in
* cl_gui_gp_hier) and of course performance is must better (half the
* number of objects in data container).
* Nevertheless this example shows the more complex way to fill the
* data container for the hierarchy proxy.
*-----------------------------------------------------------------------
* 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,
DOCU_ID TYPE DOKHL-ID,
DOCU_LANGU TYPE DOKHL-LANGU,
DOCU_OBJECT TYPE DOKHL-OBJECT,
FIRSTCALL TYPE I,
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,
GP1 TYPE REF TO CL_GUI_GP_HIER,
GP2 TYPE REF TO CL_GUI_GP_HIER,
GP3 TYPE REF TO CL_GUI_GP_HIER,
GP4 TYPE REF TO CL_GUI_GP_HIER,
GP5 TYPE REF TO CL_GUI_GP_PRES,
GP5_ACTIVATED TYPE GFW_BOOLEAN VALUE GFW_FALSE,
EVTCODE_LIST TYPE CNTL_SIMPLE_EVENTS,
SIMPLE_EVENT type CNTL_SIMPLE_EVENT,
FILTER_LIST TYPE GFW_FILTER_LIST,
CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
SPLITTER TYPE REF TO CL_GUI_EASY_SPLITTER_CONTAINER,
NESTED TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
NESTED_AREA1 type ref to cl_gui_container,
NESTED_AREA2 type ref to cl_gui_container,
NESTED_AREA3 type ref to cl_gui_container,
NESTED_TWIN TYPE REF TO CL_GUI_EASY_SPLITTER_CONTAINER,
BUNDLE_DRAWING TYPE REF TO CL_CU_DRAWING_AREA,
BUNDLE_DISPLAY TYPE REF TO CL_CU_DISPLAY_CONTEXT,
bundle_data_sheet TYPE REF TO CL_CU_DATA_SHEET,
CU_ADMIN TYPE GFW_BOOLEAN VALUE GFW_FALSE,
ITEM_LIST TYPE GFW_ITEM_ATTRIB_LIST,
item_name type gfw_item_attrib,
drag_behavior_list type gfw_behavior_list,
drop_behavior_list type gfw_behavior_list,
cu_person type ref to cl_cu_point,
cu_department type ref to cl_cu_point
.
class lcl_appl_dragdrop_object definition.
public section.
data: object_list type gfw_proxy_obj_data_list.
endclass.
class lcl_appl_dragdrop_object implementation.
endclass.
* 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,
ON_DBLCLK FOR EVENT
IF_GRAPHIC_PROXY~GRAPHIC_MOUSE_DBLCLK_LEFT
OF CL_GUI_GP_HIER IMPORTING EVENT,
* event handler for drag&drop
ON_FLAVOR_REQUESTED FOR EVENT
obj_FLAVOR_REQUESTED OF if_evt_dragdrop
IMPORTING PROXY_OBJ_DATA drag_drop_object,
ON_DRAGGED FOR EVENT
obj_dragged OF if_evt_dragdrop
IMPORTING PROXY_OBJ_DATA_LIST drag_drop_object,
ON_DROPPED FOR EVENT
obj_dropped OF if_evt_dragdrop
IMPORTING PROXY_OBJ_DATA drag_drop_object,
ON_DROP_COMPLETED FOR EVENT
obj_DROP_COMPLETED OF if_evt_dragdrop
IMPORTING PROXY_OBJ_DATA_LIST drag_drop_object.
PRIVATE SECTION.
DATA: GFW_RETVAL TYPE SYMSGNO.
METHODS: RESET_FILTER
IMPORTING FROM TYPE I TO TYPE I,
SET_FILTER
IMPORTING NODE_FILTER TYPE I
LINK_FILTER TYPE I
OBJID TYPE GFWDCHIER-OBJID.
ENDCLASS.
CLASS LCL_MAIN IMPLEMENTATION.
METHOD ON_CLOSED.
GFW_RETVAL = CL_GFW=>OK.
* clear all objects
IF NOT GP1 IS INITIAL.
CALL METHOD GP1->IF_GRAPHIC_PROXY~FREE IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
IF NOT GP2 IS INITIAL.
CALL METHOD GP2->IF_GRAPHIC_PROXY~FREE IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
IF NOT GP3 IS INITIAL.
CALL METHOD GP3->IF_GRAPHIC_PROXY~FREE IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
IF NOT GP4 IS INITIAL.
CALL METHOD GP4->IF_GRAPHIC_PROXY~FREE IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
IF NOT GP5 IS INITIAL.
CALL METHOD GP5->IF_GRAPHIC_PROXY~FREE IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
IF GFW_RETVAL = CL_GFW=>OK.
CALL METHOD DC_MANAGE->FREE IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
IF GFW_RETVAL <CL_GFW>OK.
CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = GFW_RETVAL.
ELSE. "// optional
CLEAR GP1. CLEAR GP2. CLEAR GP3. CLEAR GP4. CLEAR GP5.
CLEAR DC_MANAGE. CLEAR DC_INST.
ENDIF.
LEAVE PROGRAM.
ENDMETHOD. "//on_closed
METHOD ON_DBLCLK.
DATA: EVT_PARAMETER TYPE GFW_EVTPARAM, OBJID TYPE GFWDCHIER-OBJID.
GFW_RETVAL = CL_GFW=>OK.
READ TABLE EVENT-EVTPARAM_LIST INTO EVT_PARAMETER
WITH KEY NAME = IF_GRAPHIC_PROXY=>CO_EVTPARAM_RC.
IF SY-SUBRC = 0 OR SY-SUBRC = 2.
* error occurred in event handling
GFW_RETVAL = EVT_PARAMETER-VALUE.
ELSE.
* get objid for DC
READ TABLE EVENT-EVTPARAM_LIST INTO EVT_PARAMETER
WITH KEY NAME = IF_GRAPHIC_PROXY=>CO_EVTPARAM_OBJID.
IF SY-SUBRC <> 0 AND SY-SUBRC <2>E_GP_GRAPH_OBJID.
ENDIF.
ENDIF.
IF GFW_RETVAL = CL_GFW=>OK.
* reset obj-filter from 2 to 1 and from 4 to 1
CALL METHOD RESET_FILTER EXPORTING FROM = 2 TO = 1.
CALL METHOD RESET_FILTER EXPORTING FROM = 4 TO = 1.
ENDIF.
IF GFW_RETVAL = CL_GFW=>OK.
* set obj filter from 1 to 2 for evt_parameter-value and its children
* set filter of nodes to 4 to display them in business graphic
OBJID = EVT_PARAMETER-VALUE.
CALL METHOD SET_FILTER EXPORTING NODE_FILTER = 4
LINK_FILTER = 2
OBJID = OBJID.
ENDIF.
IF GFW_RETVAL = CL_GFW=>OK AND NOT DC_MANAGE IS INITIAL.
* data changes are ok -> distribute them to all graphics
IF GP5_ACTIVATED = GFW_FALSE AND NOT GP5 IS INITIAL.
* display business graphic (now there is data to display)
* CALL METHOD gp5->if_graphic_proxy~activate
* IMPORTING retval = retval.
GP5_ACTIVATED = GFW_TRUE.
ENDIF.
method ON_FLAVOR_REQUESTED.
* nothing to do because there's only 1 flavor in this demo program
ENDMETHOD.
method ON_DRAGGED.
* IMPORTING PROXY_OBJ_DATA_LIST dragdrop_object,
*
* write proxy data to dragdrop_object (encapsulated in a class)
* (there's no special application data necessary to identify data object
* because it's a modus internal drag&drop and all participants are
* registered with the same data container in this demo program)
data: appl_data type ref to lcl_appl_dragdrop_object.
create object appl_data.
appl_data->object_list = proxy_obj_data_list.
drag_drop_object->object = appl_data.
endmethod. "//on_dragged
method ON_DROPPED.
* IMPORTING PROXY_OBJ_DATA dragdrop_object
DATA: proxy_object type ref to cl_gfw_object,
appl_data type ref to lcl_appl_dragdrop_object,
DEST_OBJID TYPE GFWDCHIER-OBJID,
SRC_OBJID TYPE GFWDCHIER-OBJID,
LINK_OBJID TYPE GFWDCHIER-OBJID,
MODE TYPE I,
VALUE_COUNTER TYPE I.
GFW_RETVAL = CL_GFW=>OK.
* GFW always serves
* PROXY_OBJ_DATA for the target/destination node
* dragdrop_object->object for the list of source nodes
proxy_object ?= proxy_obj_data.
DEST_OBJID = proxy_object->objid.
appl_data ?= drag_drop_object->object.
** move all src nodes (set filter of node itself and its link to parent)
loop at appl_data->object_list into proxy_object.
src_objid = proxy_object->objid.
* set obj filter to 3 for src_objid and its children
CALL METHOD DC_MANAGE->SET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = SRC_OBJID
ATTRIBUTE = 'FILTER'
FIELD_VALUE = 3
IMPORTING RETVAL = GFW_RETVAL.
* CALL METHOD set_filter EXPORTING node_filter = 3 objid = src_objid.
IF GFW_RETVAL = CL_GFW=>OK.
* set filter (and PRED) of parent link of src_obj to 3 (objid)
VALUE_COUNTER = 1.
CALL METHOD DC_MANAGE->GET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_ATTRIBUTE = 'SUCC' "#EC NOTEXT
KEY_VALUE = SRC_OBJID
ATTRIBUTE = 'OBJID' "#EC NOTEXT
IMPORTING MODE = MODE
FIELD_VALUE = LINK_OBJID
RETVAL = GFW_RETVAL
CHANGING VALUE_COUNTER = VALUE_COUNTER.
IF GFW_RETVAL <CL_GFW>I_DC_SET_OF_VAL AND
GFW_RETVAL <CL_GFW>OK.
GFW_RETVAL = CL_GFW=>OK.
EXIT. "// no link found (src_obj = root) => ready
ELSE.
* set filter of link itself
CALL METHOD DC_MANAGE->SET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = LINK_OBJID
ATTRIBUTE = 'FILTER'
FIELD_VALUE = 3
IMPORTING RETVAL = GFW_RETVAL.
IF GFW_RETVAL = CL_GFW=>OK.
CALL METHOD DC_MANAGE->SET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = LINK_OBJID
ATTRIBUTE = 'PRED'
FIELD_VALUE = DEST_OBJID
IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
ENDIF.
ENDIF.
endloop.
IF GFW_RETVAL = CL_GFW=>OK AND NOT DC_MANAGE IS INITIAL.
* data changes are ok -> distribute them to all graphics
CALL METHOD DC_MANAGE->DISTRIBUTE_CHANGES
IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
IF GFW_RETVAL <CL_GFW>OK.
CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = GFW_RETVAL.
ENDIF.
endmethod. "//on_Dropped
method ON_DROP_COMPLETED.
* IMPORTING PROXY_OBJ_DATA_LIST dragdrop_object
* nothing to do because everything has been done in method ON_DROPPED.
endmethod.
METHOD RESET_FILTER.
* IMPORTING from TYPE i to TYPE i
DATA: MODE TYPE I, OBJID TYPE GFWDCHIER-OBJID, VALUE_COUNTER TYPE I,
SET_RETVAL TYPE SYMSGNO.
IF DC_MANAGE IS INITIAL.
GFW_RETVAL = CL_GFW=>ERR.
EXIT.
ENDIF.
GFW_RETVAL = CL_GFW=>OK. VALUE_COUNTER = 1.
DO. "//scan data container
CALL METHOD DC_MANAGE->GET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_ATTRIBUTE = 'FILTER'
KEY_VALUE = FROM
ATTRIBUTE = 'OBJID'
IMPORTING MODE = MODE
FIELD_VALUE = OBJID
RETVAL = GFW_RETVAL
CHANGING VALUE_COUNTER = VALUE_COUNTER.
IF GFW_RETVAL = CL_GFW=>I_DC_SET_OF_VAL OR GFW_RETVAL = CL_GFW=>OK.
CALL METHOD DC_MANAGE->SET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = OBJID
ATTRIBUTE = 'FILTER'
FIELD_VALUE = TO
IMPORTING RETVAL = SET_RETVAL. "//ignore ret
ENDIF.
IF GFW_RETVAL = CL_GFW=>I_DC_SET_OF_VAL.
* don't change value_counter (the old 1st object has been changed
* so the old second object is now the 1st object found)
CONTINUE.
ELSE.
"// error occurred or ready (not found or set)
EXIT.
ENDIF.
ENDDO.
GFW_RETVAL = CL_GFW=>OK.
ENDMETHOD. "//reset_filter
METHOD SET_FILTER.
* IMPORTING to TYPE i objid TYPE gfwdchier-objid
DATA: MODE TYPE I, NEXT_OBJID TYPE GFWDCHIER-OBJID,
LINK_OBJID TYPE GFWDCHIER-OBJID,
VALUE_COUNTER TYPE I, TMP_COUNTER TYPE I,
TMP_LINK_FILTER TYPE I,
NODE_DATA TYPE GFWDCHIER-DATA.
IF DC_MANAGE IS INITIAL.
GFW_RETVAL = CL_GFW=>ERR.
EXIT.
ENDIF.
GFW_RETVAL = CL_GFW=>OK.
* set filter of given node (objid)
VALUE_COUNTER = 1.
* set node filter of link_filter if data is initial
* (do not display node in business graphic)
CALL METHOD DC_MANAGE->GET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_ATTRIBUTE = 'OBJID'
KEY_VALUE = OBJID
ATTRIBUTE = 'DATA'
IMPORTING MODE = MODE
FIELD_VALUE = NODE_DATA
RETVAL = GFW_RETVAL
CHANGING VALUE_COUNTER = VALUE_COUNTER.
IF ( GFW_RETVAL = CL_GFW=>I_DC_SET_OF_VAL OR GFW_RETVAL = CL_GFW=>OK )
AND NODE_DATA IS INITIAL.
CALL METHOD DC_MANAGE->SET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = OBJID
ATTRIBUTE = 'FILTER'
FIELD_VALUE = LINK_FILTER
IMPORTING RETVAL = GFW_RETVAL.
ELSE.
RETVAL = CL_GFW=>OK.
CALL METHOD DC_MANAGE->SET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = OBJID
ATTRIBUTE = 'FILTER'
FIELD_VALUE = NODE_FILTER
IMPORTING RETVAL = GFW_RETVAL.
ENDIF.
IF GFW_RETVAL <CL_GFW>OK.
EXIT.
ENDIF.
* look for objects (links) where pred = given node
VALUE_COUNTER = 1.
DO.
CALL METHOD DC_MANAGE->GET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_ATTRIBUTE = 'PRED'
KEY_VALUE = OBJID
ATTRIBUTE = 'OBJID'
IMPORTING MODE = MODE
FIELD_VALUE = LINK_OBJID
RETVAL = GFW_RETVAL
CHANGING VALUE_COUNTER = VALUE_COUNTER.
IF GFW_RETVAL <CL_GFW>I_DC_SET_OF_VAL AND
GFW_RETVAL <CL_GFW>OK.
GFW_RETVAL = CL_GFW=>OK.
EXIT. "// no links found => ready
ELSE.
* set filter of link itself
CALL METHOD DC_MANAGE->SET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_VALUE = LINK_OBJID
ATTRIBUTE = 'FILTER'
FIELD_VALUE = LINK_FILTER
IMPORTING RETVAL = GFW_RETVAL.
IF GFW_RETVAL <CL_GFW>OK.
EXIT.
ENDIF.
* set filter of succ-node of link
TMP_COUNTER = 1.
CALL METHOD DC_MANAGE->GET_VALUE
EXPORTING ID = MY_ID_AT_DC
KEY_ATTRIBUTE = 'OBJID'
KEY_VALUE = LINK_OBJID
ATTRIBUTE = 'SUCC'
IMPORTING MODE = MODE
FIELD_VALUE = NEXT_OBJID
RETVAL = GFW_RETVAL
CHANGING VALUE_COUNTER = TMP_COUNTER.
IF GFW_RETVAL <CL_GFW>OK.
GFW_RETVAL = CL_GFW=>OK.
EXIT. "//ready (it's an error (link without succ) but ignore it)
ENDIF.
CALL METHOD SET_FILTER EXPORTING NODE_FILTER = NODE_FILTER
LINK_FILTER = LINK_FILTER
OBJID = NEXT_OBJID.
IF GFW_RETVAL <CL_GFW>OK.
EXIT. "//error -> return
ENDIF.
ENDIF. "//else. set filter of link itself
VALUE_COUNTER = VALUE_COUNTER + 1.
ENDDO.
ENDMETHOD. "//set_filter
ENDCLASS. "//lcl_main
DATA: MAIN TYPE REF TO LCL_MAIN.
START-OF-SELECTION.
CREATE OBJECT MAIN.
DATA: PROD_GP1 TYPE TGPN-PRODUKT VALUE CL_GUI_GP_HIER=>CO_PROD_SAPTREE,
PROD_GP2 TYPE TGPN-PRODUKT VALUE CL_GUI_GP_HIER=>CO_PROD_SAPTREE,
PROD_GP3 TYPE TGPN-PRODUKT VALUE CL_GUI_GP_HIER=>CO_PROD_SAPTREE,
PROD_GP4 TYPE TGPN-PRODUKT VALUE CL_GUI_GP_HIER=>CO_PROD_SAPOCX,
prod_gp5 TYPE tgpn-produkt VALUE cl_gui_gp_pres=>co_prod_chart.
* PROD_GP5 TYPE TGPN-PRODUKT VALUE CL_GUI_GP_PRES=>CO_PROD_SAPOCX.
refresh item_list. clear item_name.
item_name-no = 1.
item_name-name = 'NODE_TEXT0'.
insert item_name into table item_list.
* 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'.
* create container in which to place 1st splitter
* (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 splitter with 2 rows for other splitter and bottom graphic
CREATE OBJECT splitter
EXPORTING
PARENT = CUSTOM_CONTAINER
orientation = 0.
" there will be a RABAX here if any error occurred while creating
" the container
call method splitter->SET_SASH_POSITION
EXPORTING SASH_POSITION = 60.
* 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. "// dc_manage init ok
PERFORM FILL_DC CHANGING RETVAL.
perform fill_behavior_list.
IF RETVAL = CL_GFW=>OK. "// gp1
* create, initialize and activate graphics proxy 1
CREATE OBJECT GP1.
REFRESH FILTER_LIST.
INSERT 1 INTO TABLE FILTER_LIST.
INSERT 2 INTO TABLE FILTER_LIST.
INSERT 4 INTO TABLE FILTER_LIST.
REFRESH EVTCODE_LIST.
clear simple_event.
simple_event-appl_event = 'X'.
simple_event-EVENTID =
IF_GRAPHIC_PROXY=>CO_EVT_MOUSE_DBLCLK_LEFT.
APPEND simple_event TO EVTCODE_LIST.
CALL METHOD GP1->IF_GRAPHIC_PROXY~INIT
EXPORTING PARENT = NESTED_AREA1
DC = DC_INST
PROD_ID = PROD_GP1
* force_prod = gfw_true
EVTCODE_LIST = EVTCODE_LIST
FILTER_LIST = FILTER_LIST
IMPORTING RETVAL = RETVAL.
IF RETVAL = CL_GFW=>OK.
* set DC attributes
CALL METHOD GP1->SET_DC_NAMES
EXPORTING
OBJ_ID = 'OBJID'
FILTER = 'FILTER'
OBJTYPE = 'OBJTYPE'
PRED = 'PRED'
SUCC = 'SUCC'
OBJREF_ID = 'CU_REFOBJ'
STATUS = 'STATUS_OBJ'
ITEM_LIST = ITEM_LIST
IMPORTING RETVAL = RETVAL.
ENDIF. "// set dc attributes
if retval = cl_gfw=>ok.
call method gp1->IF_GRAPHIC_PROXY~set_behavior_list
exporting behavior_list = drag_behavior_list
importing retval = retval.
set handler MAIN->on_dragged for gp1.
set handler MAIN->on_drop_completed for gp1.
endif.
if retval = cl_gfw=>ok and not cu_person is initial.
call method GP1->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = CO_GFW_PROG_PERSON
BUNDLE = cu_person
importing retval = retval.
endif.
if retval = cl_gfw=>ok and not cu_department is initial.
call method GP1->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = CO_GFW_PROG_DEPT
BUNDLE = cu_department
importing retval = retval.
endif.
IF RETVAL = CL_GFW=>OK AND NOT BUNDLE_DRAWING IS INITIAL.
CALL METHOD GP1->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
EXPORTING PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART
BUNDLE = BUNDLE_DRAWING
IMPORTING RETVAL = RETVAL.
ENDIF.
IF RETVAL = CL_GFW=>OK.
CALL METHOD GP1->IF_GRAPHIC_PROXY~ACTIVATE
IMPORTING RETVAL = RETVAL.
ENDIF.
ENDIF. "//create/init gp1
IF RETVAL = CL_GFW=>OK. "// gp2
* create, initialize and activate graphics proxy 2
CREATE OBJECT GP2.
REFRESH FILTER_LIST.
INSERT 2 INTO TABLE FILTER_LIST.
INSERT 4 INTO TABLE FILTER_LIST.
REFRESH EVTCODE_LIST.
CALL METHOD GP2->IF_GRAPHIC_PROXY~INIT
EXPORTING parent = nested_twin->TOP_LEFT_CONTAINER
DC = DC_INST
PROD_ID = PROD_GP2
* force_prod = gfw_true
EVTCODE_LIST = EVTCODE_LIST
FILTER_LIST = FILTER_LIST
IMPORTING RETVAL = RETVAL.
IF RETVAL = CL_GFW=>OK.
* set DC attributes
CALL METHOD GP2->SET_DC_NAMES
EXPORTING
OBJ_ID = 'OBJID'
FILTER = 'FILTER'
OBJTYPE = 'OBJTYPE'
PRED = 'PRED'
SUCC = 'SUCC'
OBJREF_ID = 'CU_REFOBJ'
STATUS = 'STATUS_OBJ'
ITEM_LIST = ITEM_LIST
IMPORTING RETVAL = RETVAL.
ENDIF. "// set dc attributes
if retval = cl_gfw=>ok.
call method gp2->IF_GRAPHIC_PROXY~set_behavior_list
exporting behavior_list = drag_behavior_list
importing retval = retval.
set handler MAIN->on_dragged for gp2.
set handler MAIN->on_drop_completed for gp2.
endif.
if retval = cl_gfw=>ok and not cu_person is initial.
call method GP2->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = CO_GFW_PROG_PERSON
BUNDLE = cu_person
importing retval = retval.
endif.
if retval = cl_gfw=>ok and not cu_department is initial.
call method GP2->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = CO_GFW_PROG_DEPT
BUNDLE = cu_department
importing retval = retval.
endif.
IF RETVAL = CL_GFW=>OK AND NOT BUNDLE_DRAWING IS INITIAL.
CALL METHOD GP2->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
EXPORTING PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART
BUNDLE = BUNDLE_DRAWING
IMPORTING RETVAL = RETVAL.
ENDIF.
IF RETVAL = CL_GFW=>OK.
CALL METHOD GP2->IF_GRAPHIC_PROXY~ACTIVATE
IMPORTING RETVAL = RETVAL.
ENDIF.
ENDIF. "//create/init gp1
IF RETVAL = CL_GFW=>OK. "// gp3
* create, initialize and activate graphics proxy 3
CREATE OBJECT GP3.
REFRESH FILTER_LIST.
INSERT 3 INTO TABLE FILTER_LIST.
REFRESH EVTCODE_LIST.
clear simple_event.
simple_event-appl_event = 'X'.
simple_event-EVENTID = IF_GRAPHIC_PROXY=>CO_EVT_DROPPED.
APPEND simple_event TO EVTCODE_LIST.
CALL METHOD GP3->IF_GRAPHIC_PROXY~INIT
EXPORTING PARENT = NESTED_AREA3
DC = DC_INST
PROD_ID = PROD_GP3
* force_prod = gfw_true
EVTCODE_LIST = EVTCODE_LIST
FILTER_LIST = FILTER_LIST
IMPORTING RETVAL = RETVAL.
IF RETVAL = CL_GFW=>OK.
* set DC attributes
CALL METHOD GP3->SET_DC_NAMES
EXPORTING
OBJ_ID = 'OBJID'
FILTER = 'FILTER'
OBJTYPE = 'OBJTYPE'
PRED = 'PRED'
SUCC = 'SUCC'
OBJREF_ID = 'CU_REFOBJ'
STATUS = 'STATUS_OBJ'
ITEM_LIST = ITEM_LIST
IMPORTING RETVAL = RETVAL.
ENDIF. "// set dc attributes
if retval = cl_gfw=>ok.
call method gp3->IF_GRAPHIC_PROXY~set_behavior_list
exporting behavior_list = drop_behavior_list
importing retval = retval.
set handler MAIN->on_dropped for gp3.
set handler MAIN->on_flavor_requested for gp3.
endif.
if retval = cl_gfw=>ok and not cu_person is initial.
call method GP3->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = CO_GFW_PROG_PERSON
BUNDLE = cu_person
importing retval = retval.
endif.
if retval = cl_gfw=>ok and not cu_department is initial.
call method GP3->if_graphic_proxy~add_cu_bundle
exporting port = if_graphic_proxy=>co_port_chart
key = CO_GFW_PROG_DEPT
BUNDLE = cu_department
importing retval = retval.
endif.
IF RETVAL = CL_GFW=>OK AND NOT BUNDLE_DRAWING IS INITIAL.
CALL METHOD GP3->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
EXPORTING PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART
BUNDLE = BUNDLE_DRAWING
IMPORTING RETVAL = RETVAL.
ENDIF.
IF RETVAL = CL_GFW=>OK.
CALL METHOD GP3->IF_GRAPHIC_PROXY~ACTIVATE
IMPORTING RETVAL = RETVAL.
ENDIF.
ENDIF. "//create/init gp3
IF RETVAL = CL_GFW=>OK. "// gp4
* create, initialize and activate graphics proxy 4
CREATE OBJECT GP4.
REFRESH FILTER_LIST.
INSERT 1 INTO TABLE FILTER_LIST.
INSERT 2 INTO TABLE FILTER_LIST.
INSERT 3 INTO TABLE FILTER_LIST.
INSERT 4 INTO TABLE FILTER_LIST.
REFRESH EVTCODE_LIST.
CALL METHOD GP4->IF_GRAPHIC_PROXY~INIT
EXPORTING PARENT = splitter->BOTTOM_RIGHT_CONTAINER
DC = DC_INST
PROD_ID = PROD_GP4
* force_prod = gfw_true
EVTCODE_LIST = EVTCODE_LIST
* FILTER_LIST = FILTER_LIST
IMPORTING RETVAL = RETVAL.
IF RETVAL = CL_GFW=>OK.
* set DC attributes
CALL METHOD GP4->SET_DC_NAMES
EXPORTING
OBJ_ID = 'OBJID'
FILTER = 'FILTER'
OBJTYPE = 'OBJTYPE'
PRED = 'PRED'
SUCC = 'SUCC'
OBJREF_ID = 'CU_REFOBJ'
ITEM_LIST = ITEM_LIST
IMPORTING RETVAL = RETVAL.
ENDIF. "// set dc attributes
IF RETVAL = CL_GFW=>OK AND NOT BUNDLE_DRAWING IS INITIAL.
CALL METHOD GP4->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
EXPORTING PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART
BUNDLE = BUNDLE_DRAWING
IMPORTING RETVAL = RETVAL.
ENDIF.
IF RETVAL = CL_GFW=>OK.
CALL METHOD GP4->IF_GRAPHIC_PROXY~ACTIVATE
IMPORTING RETVAL = RETVAL.
ENDIF.
ENDIF. "//create/init gp4
IF RETVAL = CL_GFW=>OK. "// gp5
* create, initialize and activate graphics proxy 5
CREATE OBJECT GP5.
REFRESH FILTER_LIST.
INSERT 4 INTO TABLE FILTER_LIST.
REFRESH EVTCODE_LIST.
clear simple_event.
simple_event-appl_event = 'X'.
simple_event-EVENTID = IF_GRAPHIC_PROXY=>CO_EVT_CUSTOM_CHANGED.
APPEND simple_event TO EVTCODE_LIST.
CALL METHOD GP5->IF_GRAPHIC_PROXY~INIT
EXPORTING PARENT = nested_twin->BOTTOM_RIGHT_CONTAINER
DC = DC_INST
PROD_ID = PROD_GP5
* force_prod = gfw_true
EVTCODE_LIST = EVTCODE_LIST
FILTER_LIST = FILTER_LIST
IMPORTING RETVAL = RETVAL.
IF RETVAL = CL_GFW=>E_GP_INIT_PLACE.
RETVAL = CL_GFW=>OK.
ENDIF.
IF RETVAL <CL_GFW>OK. CLEAR GP5. ENDIF.
IF RETVAL = CL_GFW=>OK.
* set DC attributes
CALL METHOD GP5->SET_DC_NAMES
EXPORTING
OBJ_ID = 'OBJID'
DIM1 = 'OBJID'
DIM2 = 'DATA'
IMPORTING RETVAL = RETVAL.
ENDIF. "// set dc attributes
IF RETVAL = CL_GFW=>OK AND NOT BUNDLE_DRAWING IS INITIAL.
CALL METHOD GP5->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
EXPORTING PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART
BUNDLE = BUNDLE_DRAWING
IMPORTING RETVAL = RETVAL.
ENDIF.
IF RETVAL = CL_GFW=>OK AND NOT bundle_data_sheet IS INITIAL.
CALL METHOD GP5->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
EXPORTING PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART
BUNDLE = bundle_data_sheet
IMPORTING RETVAL = RETVAL.
ENDIF.
IF RETVAL = CL_GFW=>OK.
CALL METHOD GP5->IF_GRAPHIC_PROXY~ACTIVATE
IMPORTING RETVAL = RETVAL.
GP5_ACTIVATED = GFW_TRUE.
ENDIF.
ENDIF. "//create/init gp5
IF RETVAL <CL_GFW>OK.
CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
ENDIF.
ENDIF. "//dc_manage init ok
FIRSTCALL = 1.
ENDIF.
* set gui event handlers
SET HANDLER MAIN->ON_CLOSED FOR GP1.
SET HANDLER MAIN->ON_CLOSED FOR GP2.
SET HANDLER MAIN->ON_CLOSED FOR GP3.
SET HANDLER MAIN->ON_CLOSED FOR GP4.
SET HANDLER MAIN->ON_DBLCLK FOR GP1.
* just for testing network
SET HANDLER MAIN->ON_DBLCLK FOR GP4.
* **** 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 interactions)
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'. LEAVE PROGRAM.
WHEN 'EXIT'. LEAVE PROGRAM.
WHEN 'DOCU'.
DOCU_ID = 'RE'. DOCU_LANGU = SY-LANGU.
DOCU_OBJECT = 'GFW_DEMO_HIER3'.
* display program documentation
CALL FUNCTION 'DOCU_CALL'
EXPORTING
DISPL = 'X' "//show mode
DISPL_MODE = '2' "//prepare like F1-help
ID = DOCU_ID
LANGU = DOCU_LANGU
OBJECT = DOCU_OBJECT.
* WHEN 'SAVECU'.
* IF NOT BUNDLE_DIAGRAM IS INITIAL.
* CALL METHOD BUNDLE_DIAGRAM->IF_CUSTOMIZING~SAVE
* IMPORTING RETVAL = RETVAL.
* IF RETVAL <CL_GFW>OK.
* CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
* ENDIF.
* ENDIF.
* IF NOT BUNDLE_DRAWING IS INITIAL.
* CALL METHOD BUNDLE_DRAWING->IF_CUSTOMIZING~SAVE
* IMPORTING RETVAL = RETVAL.
* IF RETVAL <CL_GFW>OK.
* CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
* ENDIF.
* ENDIF.
* "end when 'SAVE_CU'
ENDCASE.
*&---------------------------------------------------------------------*
*& Form FILL_DC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <p2>E_GP_DCHANDLE.
EXIT.
ENDIF.
RETVAL = CL_GFW=>OK.
* expand department folder
create object status.
status->if_gfw_status_hier~expanded = gfw_true.
* !! sort nodes: first filter 3 then 1 because of moving things with
* drag and drop:
* tree control is not able to insert a node with parent relation if
* the parent node does not (yet) exist
* NODES
CLEAR OBJ.
OBJ-OBJTYPE = 'n'. "#EC NOTEXT
OBJ-PRED = SPACE.
OBJ-SUCC = SPACE.
OBJ-PCLUSTER = SPACE.
OBJ-DATA = 0.
* allow interactive change of background color in business graphic
IF BUNDLE_DRAWING IS INITIAL.
CREATE OBJECT BUNDLE_DRAWING EXPORTING INSTANCE_ID = 'GFWHIER3'
ADMIN = CU_ADMIN.
CALL METHOD BUNDLE_DRAWING->IF_CUSTOMIZING~LOAD.
* **** prepare display context for da->dc
* get existing context from bundle_drawing
CALL METHOD BUNDLE_DRAWING->IF_CUSTOMIZING~GET
EXPORTING ATTR_ID =
CL_CU_DRAWING_AREA=>CO_DISPLAY_CONTEXT
IMPORTING VALUE = BUNDLE_DISPLAY.
RETVAL = RETVAL.
IF RETVAL <CL_GFW>OK OR BUNDLE_DISPLAY IS INITIAL.
CREATE OBJECT BUNDLE_DISPLAY EXPORTING INSTANCE_ID = 'XXX'
ADMIN = CU_ADMIN.
ENDIF.
* add display context to bundle_drawing
CALL METHOD BUNDLE_DRAWING->IF_CUSTOMIZING~SET
EXPORTING ATTR_ID =
CL_CU_DRAWING_AREA=>CO_DISPLAY_CONTEXT
VALUE = BUNDLE_DISPLAY.
ENDIF. "// bundle_drawing IS INITIAL.
* set some objects to invisible
create object BUNDLE_DISPLAY EXPORTING INSTANCE_ID = 'XXX'.
CALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SET
EXPORTING ATTR_ID = CL_CU_DISPLAY_CONTEXT=>CO_VISIBILITY
VALUE = GFW_FALSE.
* ** do not display data sheet
create object bundle_data_sheet
EXPORTING INSTANCE_ID = 'GFWHIER3'.
CALL METHOD bundle_data_sheet->IF_CUSTOMIZING~SET
EXPORTING ATTR_ID = cl_cu_data_sheet=>CO_DISPLAY_CONTEXT
VALUE = BUNDLE_DISPLAY.
" do not allow interactive changes to data sheet
CALL METHOD bundle_data_sheet->IF_CUSTOMIZING~SET_MASTER.
* ** do not display title (frame)
CALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SET_MASTER.
CALL METHOD BUNDLE_DRAWING->IF_CUSTOMIZING~SET
EXPORTING ATTR_ID =
CL_CU_DRAWING_AREA=>CO_TITLE_CONTEXT
VALUE = BUNDLE_DISPLAY.
ENDFORM. " PREPARE_CUSTOMIZING
*&---------------------------------------------------------------------*
*& Form fill_behavior_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <p2>copy. "move.
insert single_behavior into table drop_behavior_list.
*GUI Texts
*----------------------------------------------------------
* 100 --> Example of Structure Graphics and Business Graphics with GFW
* 100 --> Example of Structure Graphics and Business Graphics with GFW
****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
GFW_DEMO_HIER3
0100
620
40
%_HEADER
GFW_DEMO_HIER3 0100 0100 21 83192 35 0 0 21 83 0G E 20001113152507
%_DESCRIPTION
Main Screen
%_FIELDS
CONTAINER 82 00 30 00 30 00 1 2 0 0 0 20 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.
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.