Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Refresh Tree ALV Container

Former Member
0 Likes
692

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

2 REPLIES 2
Read only

Former Member
0 Likes
549

Hi Diego,

Can you expalin your problem in details

I feel you can mathod frontend_update to update information.

Read only

0 Likes
549

Yes, of course....

I have 2 screens...on the first one i'm having an ALV TREE and on the second one the detail from the first screen using a TABLE CONTROL

On the first one the root is the day and the nodes are hours/minutes separated by 15 minutes ,each node has the option to add two lines through a bottom

Example

Day 20.12.2006

08:00

Placa 1 Order Sales Name Date Etc (informacion lines)

Placa 2

08:15

Placa 1

Placa 2

08:30

Placa 1

Placa 2

.

.

.

when I pick the node that is below and select the buttom i can reasign the coresponding hour,this is done on the second screen doindg and executing BAPIS in order to generate Service orders(CS)

This is done correctly,but when i click the back buttom and it takes me to the former screen,viewing the ALVTREE still withthe former information without being updated

I've tried executing and search REFRESH ,but I haven't gotten to find out how to do this action

Please if you need some extra information pls let me know...

Diego