Skip to Content
0
Former Member
Dec 21, 2006 at 02:29 AM

Refresh Tree ALV Container

101 Views

Hi Experts..I'm having problems to refresh a TREE ALV Container. I have 2 screens...the first that contain the TREE ALV and when I select once option I can go to a Table Control (Screen 300) and update information from the TREE but I can't control the data.

*&----


*

*& Module STATUS_0200 OUTPUT

*&----


*

module STATUS_0200 output.

set pf-status 'ST_0200'.

if G_TREE is initial.

perform CREATE_AND_INIT_TREE.

endif.

endmodule. " STATUS_0200 OUTPUT

*&----


*

*& Form CREATE_AND_INIT_TREE

*&----


*

form CREATE_AND_INIT_TREE.

data: NODE_TABLE type TREEV_NTAB,

ITEM_TABLE type ITEM_TABLE_TYPE,

EVENT type CNTL_SIMPLE_EVENT,

EVENTS type CNTL_SIMPLE_EVENTS,

HIERARCHY_HEADER type TREEV_HHDR.

  • create a container for the tree control

create object G_CUSTOM_CONTAINER

exporting

" the container is linked to the custom control with the

" name 'TREE_CONTAINER' on the dynpro

CONTAINER_NAME = 'TREE_CONTAINER'

exceptions

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

  • setup the hierarchy header

HIERARCHY_HEADER-HEADING = 'Jerarquía'. "#EC NOTEXT

" heading

HIERARCHY_HEADER-WIDTH = 30. " width: 30 characters

  • create a tree control

  • After construction, the control contains one column in the

  • hierarchy area. The name of this column

  • is defined via the constructor parameter HIERACHY_COLUMN_NAME.

create object G_TREE

exporting

PARENT = G_CUSTOM_CONTAINER

NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE

ITEM_SELECTION = 'X'

HIERARCHY_COLUMN_NAME = 'Column1'

HIERARCHY_HEADER = HIERARCHY_HEADER

exceptions

CNTL_SYSTEM_ERROR = 1

CREATE_ERROR = 2

FAILED = 3

ILLEGAL_NODE_SELECTION_MODE = 4

ILLEGAL_COLUMN_NAME = 5

LIFETIME_ERROR = 6.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

  • define the events which will be passed to the backend

" node double click

EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_NODE_DOUBLE_CLICK.

EVENT-APPL_EVENT = 'X'. " process PAI if event occurs

append EVENT to EVENTS.

" item double click

EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_ITEM_DOUBLE_CLICK.

EVENT-APPL_EVENT = 'X'.

append EVENT to EVENTS.

" expand no children

EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_EXPAND_NO_CHILDREN.

EVENT-APPL_EVENT = 'X'.

append EVENT to EVENTS.

" link click

EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_LINK_CLICK.

EVENT-APPL_EVENT = 'X'.

append EVENT to EVENTS.

" button click

EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_BUTTON_CLICK.

EVENT-APPL_EVENT = 'X'.

append EVENT to EVENTS.

" checkbox change

EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_CHECKBOX_CHANGE.

EVENT-APPL_EVENT = 'X'.

append EVENT to EVENTS.

" header click

EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_HEADER_CLICK.

EVENT-APPL_EVENT = 'X'.

append EVENT to EVENTS.

" header click

EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_HEADER_CLICK.

EVENT-APPL_EVENT = 'X'.

append EVENT to EVENTS.

call method G_TREE->SET_REGISTERED_EVENTS

exporting

EVENTS = EVENTS

exceptions

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

ILLEGAL_EVENT_COMBINATION = 3.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

  • assign event handlers in the application class to each desired event

set handler G_APPLICATION->HANDLE_NODE_DOUBLE_CLICK for G_TREE.

set handler G_APPLICATION->HANDLE_ITEM_DOUBLE_CLICK for G_TREE.

set handler G_APPLICATION->HANDLE_EXPAND_NO_CHILDREN for G_TREE.

set handler G_APPLICATION->HANDLE_LINK_CLICK for G_TREE.

set handler G_APPLICATION->HANDLE_BUTTON_CLICK for G_TREE.

set handler G_APPLICATION->HANDLE_CHECKBOX_CHANGE for G_TREE.

set handler G_APPLICATION->HANDLE_HEADER_CLICK for G_TREE.

  • insert two additional columns

  • Column2

call method G_TREE->ADD_COLUMN

exporting

NAME = 'Column2'

WIDTH = 25

HEADER_TEXT = 'Cliente'

exceptions

COLUMN_EXISTS = 1

ILLEGAL_COLUMN_NAME = 2

TOO_MANY_COLUMNS = 3

ILLEGAL_ALIGNMENT = 4

DIFFERENT_COLUMN_TYPES = 5

CNTL_SYSTEM_ERROR = 6

FAILED = 7

PREDECESSOR_COLUMN_NOT_FOUND = 8.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

  • Column3

call method G_TREE->ADD_COLUMN

exporting

NAME = 'Column3'

WIDTH = 35

HEADER_TEXT = 'Nombre'

exceptions

COLUMN_EXISTS = 1

ILLEGAL_COLUMN_NAME = 2

TOO_MANY_COLUMNS = 3

ILLEGAL_ALIGNMENT = 4

DIFFERENT_COLUMN_TYPES = 5

CNTL_SYSTEM_ERROR = 6

FAILED = 7

PREDECESSOR_COLUMN_NOT_FOUND = 8.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

call method G_TREE->ADD_COLUMN

exporting

NAME = 'Column4'

WIDTH = 14

HEADER_TEXT = 'Placa'

exceptions

COLUMN_EXISTS = 1

ILLEGAL_COLUMN_NAME = 2

TOO_MANY_COLUMNS = 3

ILLEGAL_ALIGNMENT = 4

DIFFERENT_COLUMN_TYPES = 5

CNTL_SYSTEM_ERROR = 6

FAILED = 7

PREDECESSOR_COLUMN_NOT_FOUND = 8.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

call method G_TREE->ADD_COLUMN

exporting

NAME = 'Column5'

WIDTH = 30

HEADER_TEXT = 'Descripción'

exceptions

COLUMN_EXISTS = 1

ILLEGAL_COLUMN_NAME = 2

TOO_MANY_COLUMNS = 3

ILLEGAL_ALIGNMENT = 4

DIFFERENT_COLUMN_TYPES = 5

CNTL_SYSTEM_ERROR = 6

FAILED = 7

PREDECESSOR_COLUMN_NOT_FOUND = 8.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

call method G_TREE->ADD_COLUMN

exporting

NAME = 'Column6'

WIDTH = 18

HEADER_TEXT = 'Año Vehículo'

exceptions

COLUMN_EXISTS = 1

ILLEGAL_COLUMN_NAME = 2

TOO_MANY_COLUMNS = 3

ILLEGAL_ALIGNMENT = 4

DIFFERENT_COLUMN_TYPES = 5

CNTL_SYSTEM_ERROR = 6

FAILED = 7

PREDECESSOR_COLUMN_NOT_FOUND = 8.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

call method G_TREE->ADD_COLUMN

exporting

NAME = 'Column7'

WIDTH = 14

HEADER_TEXT = 'Aviso'

exceptions

COLUMN_EXISTS = 1

ILLEGAL_COLUMN_NAME = 2

TOO_MANY_COLUMNS = 3

ILLEGAL_ALIGNMENT = 4

DIFFERENT_COLUMN_TYPES = 5

CNTL_SYSTEM_ERROR = 6

FAILED = 7

PREDECESSOR_COLUMN_NOT_FOUND = 8.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

call method G_TREE->ADD_COLUMN

exporting

NAME = 'Column8'

WIDTH = 24

HEADER_TEXT = 'Estado de la Cita'

exceptions

COLUMN_EXISTS = 1

ILLEGAL_COLUMN_NAME = 2

TOO_MANY_COLUMNS = 3

ILLEGAL_ALIGNMENT = 4

DIFFERENT_COLUMN_TYPES = 5

CNTL_SYSTEM_ERROR = 6

FAILED = 7

PREDECESSOR_COLUMN_NOT_FOUND = 8.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

  • add some nodes to the tree control

  • NOTE: the tree control does not store data at the backend. If an

  • application wants to access tree data later, it must store the

  • tree data itself.

perform BUILD_NODE_AND_ITEM_TABLE using NODE_TABLE ITEM_TABLE.

call method G_TREE->ADD_NODES_AND_ITEMS

exporting

NODE_TABLE = NODE_TABLE

ITEM_TABLE = ITEM_TABLE

ITEM_TABLE_STRUCTURE_NAME = 'MTREEITM'

exceptions

FAILED = 1

CNTL_SYSTEM_ERROR = 3

ERROR_IN_TABLES = 4

DP_ERROR = 5

TABLE_STRUCTURE_NAME_NOT_FOUND = 6.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

  • expand the node with key 'Root'

call method G_TREE->EXPAND_NODE

exporting

NODE_KEY = 'Root' "#EC NOTEXT

exceptions

FAILED = 1

ILLEGAL_LEVEL_COUNT = 2

CNTL_SYSTEM_ERROR = 3

NODE_NOT_FOUND = 4

CANNOT_EXPAND_LEAF = 5.

if SY-SUBRC <> 0.

  • MESSAGE A000.

endif.

endform. " CREATE_AND_INIT_TREE

Somebody can give me tips to solve this problem.....

Thxs

Diego