REPORT YLITTREE .
DATA: OK_CODE TYPE SY-UCOMM,
SAVE_OK TYPE SY-UCOMM.
DATA: WA_CONTAINER TYPE SCRFNAME VALUE 'TREE',
WA_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
WA_TREE TYPE REF TO CL_GUI_SIMPLE_TREE.
DATA: NODE_TABLE LIKE TABLE OF MTREESNODE,
NODE1 TYPE MTREESNODE.
DATA WA_SPFLI TYPE TABLE OF SPFLI.
DATA: NODEKEY(200) VALUE 'NODE',NODETEXT(200) VALUE 'NONE'.
CLASS LCL_APPLICATION DEFINITION DEFERRED.
*---------------------------------------------------------------------*
* CLASS lcl_application DEFINITION
*---------------------------------------------------------------------*
CLASS LCL_APPLICATION DEFINITION.
PUBLIC SECTION.
METHODS HANDLE_NODE_DOUBLE_CLICK
FOR EVENT NODE_DOUBLE_CLICK
OF CL_GUI_SIMPLE_TREE
IMPORTING NODE_KEY.
ENDCLASS.
*---------------------------------------------------------------------*
* CLASS lcl_application IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS LCL_APPLICATION IMPLEMENTATION.
METHOD HANDLE_NODE_DOUBLE_CLICK.
* MESSAGE I208(00) WITH 'double'.
NODEKEY = NODE_KEY.
READ TABLE NODE_TABLE WITH KEY NODE_KEY = NODE_KEY INTO NODE1.
NODETEXT = NODE1-TEXT.
ENDMETHOD. "HANDLE_NODE_DOUBLE_CLICK
ENDCLASS. "lcl_application IMPLEMENTATION
DATA: G_APPLICATION TYPE REF TO LCL_APPLICATION.
START-OF-SELECTION.
CREATE OBJECT G_APPLICATION.
CALL SCREEN 300.
*&---------------------------------------------------------------------*
*& Module STATUS_0300 OUTPUT
*&---------------------------------------------------------------------*
MODULE STATUS_0300 OUTPUT.
SET PF-STATUS 'YLITTREE'.
CASE SY-UCOMM.
WHEN 'STAFFDETA'.
SUBMIT YLITTREE.
WHEN 'STAFFMANG'.
SUBMIT YLITSM.
WHEN 'BACK'.
SUBMIT YLITAS.
ENDCASE.
IF WA_CUSTOM_CONTAINER IS INITIAL.
PERFORM CREATE_TREE.
ENDIF.
ENDMODULE. " STATUS_0300 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE USER_COMMAND_0300 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0300 INPUT
*&---------------------------------------------------------------------*
*& Form CREATE_TREE
*&---------------------------------------------------------------------*
FORM CREATE_TREE .
DATA: EVENTS TYPE CNTL_SIMPLE_EVENTS,
EVENT1 TYPE CNTL_SIMPLE_EVENT.
CREATE OBJECT WA_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = WA_CONTAINER.
CREATE OBJECT WA_TREE
EXPORTING
* LIFETIME =
PARENT = WA_CUSTOM_CONTAINER
* SHELLSYLE =
NODE_SELECTION_MODE = CL_GUI_SIMPLE_TREE=>NODE_SEL_MODE_SINGLE
* HIDE_SELECTION =
* NAME =
* EXCEPTIONS
* LIFETIME_ERROR = 1
* CNTL_SYSTEM_ERROR = 2
* CREATE_ERROR = 3
* FAILED = 4
* ILLEGAL_NOCE_SELECTION_MODE = 5
* OTHERS = 6
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR NODE1.
NODE1-NODE_KEY = 'UN'.
CLEAR NODE1-RELATKEY.
CLEAR NODE1-RELATSHIP.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = 'X'.
CLEAR NODE1-N_IMAGE.
CLEAR NODE1-EXP_IMAGE.
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'DEPARTMENT'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'CCOMPUTER'.
NODE1-RELATKEY = 'UN'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = 'X'.
CLEAR NODE1-N_IMAGE.
CLEAR NODE1-EXP_IMAGE.
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'COMPUTER'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'CENGLISH'.
NODE1-RELATKEY = 'UN'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = 'X'.
CLEAR NODE1-N_IMAGE.
CLEAR NODE1-EXP_IMAGE.
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'ENGLISH'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'CACCOUNT'.
NODE1-RELATKEY = 'UN'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = 'X'.
CLEAR NODE1-N_IMAGE.
CLEAR NODE1-EXP_IMAGE.
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'ACCOUNT'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'KEY ADIRECTOR'.
NODE1-RELATKEY = 'CCOMPUTER'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = ''.
NODE1-N_IMAGE = .
NODE1-EXP_IMAGE = .
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'DIRECTOR'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'KEY ATEACHER'.
NODE1-RELATKEY = 'CCOMPUTER'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = ''.
NODE1-N_IMAGE = .
NODE1-EXP_IMAGE = .
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'TEACHER'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'KEY BDIRECTOR'.
NODE1-RELATKEY = 'CENGLISH'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = ''.
NODE1-N_IMAGE = .
NODE1-EXP_IMAGE = .
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'DIRECTOR'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'KEY BTEACHER'.
NODE1-RELATKEY = 'CENGLISH'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = ''.
NODE1-N_IMAGE = .
NODE1-EXP_IMAGE = .
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'TEACHER'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'KEY CDIRECTOR'.
NODE1-RELATKEY = 'CACCOUNT'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = ''.
NODE1-N_IMAGE = .
NODE1-EXP_IMAGE = .
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'DIRECTOR'.
APPEND NODE1 TO NODE_TABLE.
CLEAR NODE1.
NODE1-NODE_KEY = 'KEY CTEACHER'.
NODE1-RELATKEY = 'CACCOUNT'.
NODE1-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
NODE1-HIDDEN = ''.
NODE1-DISABLED = ''.
NODE1-ISFOLDER = ''.
NODE1-N_IMAGE = .
NODE1-EXP_IMAGE = .
CLEAR NODE1-EXPANDER.
NODE1-TEXT = 'TEACHER'.
APPEND NODE1 TO NODE_TABLE.
CALL METHOD WA_TREE->ADD_NODES
EXPORTING
TABLE_STRUCTURE_NAME = 'MTREESNODE'
NODE_TABLE = NODE_TABLE
* EXCEPTIONS
* ERROR_IN_NODE_TABLE = 1
* FAILED = 2
* DP_ERROF = 3
* TABLE_STRUCTURE_NAME_NOT_FOUND = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
EVENT1-EVENTID = CL_GUI_SIMPLE_TREE=>EVENTID_NODE_DOUBLE_CLICK.
EVENT1-APPL_EVENT = 'X'.
APPEND EVENT1 TO EVENTS.
CALL METHOD WA_TREE->SET_REGISTERED_EVENTS
EXPORTING
EVENTS = EVENTS
* EXCEPTIONS
* CNTL_ERROR = 1
* CNTL_SYSTEM_ERROR = 2
* ILLEGAL_EVENT_COMBINATION = 3
* OTHERS = 4
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SET HANDLER G_APPLICATION->HANDLE_NODE_DOUBLE_CLICK FOR WA_TREE.
ENDFORM. " CREATE_TREE
阅读(992) | 评论(0) | 转发(0) |