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

Column Tree Control: how to format data?

Former Member
0 Likes
745

Hello *,

I want to use a Column Tree Control (CL_GUI_COLUMN_TREE) to display some data. But I can't figure out, how to format the displayed values.

For example, I have one column, that should display a date value, like 01.01.2007. (DD.MM.YYYY). In my internal table, the corresponding column is of type "DATS" and stores the value as "20070101". But when I display the column tree control, it does not format the value as "01.01.2007". Instead it shows "20070101", so the date value does not get formatted. But that's very uncomfortable, especially for the user. They want to see the date in that format,they are used to.

When using an ALV-Tree, it is possible to create a field-catalog, which is responsible for formatting data and so on. But what do I have to do, to achieve the same with a column tree control?

Kind regards, Lars

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
649

Hi Lars,

Change your internal table column data type to character of 10 and move the date as you reqd to the final internal table and display.

hope it may work.

Regards

Muthappan

4 REPLIES 4
Read only

Former Member
0 Likes
650

Hi Lars,

Change your internal table column data type to character of 10 and move the date as you reqd to the final internal table and display.

hope it may work.

Regards

Muthappan

Read only

0 Likes
649

Hello Muthappan,

I'm still not able to display the value in the desired formar. I tried the following:


DATA  l_item TYPE mtreeitem.
DATA l_date TYPE dats.
DATA l_char TYPE char10.

READ TABLE itab WITH key ... ASSIGNING <l_entry>.
l_date = <l_entry>-datab.
l_char = l_date.
l_item-text = l_char.

(It should be the same like changing the type from dats to char10 for the 20070101. Did I do something wrong, or does a tree control not offer the functionality of formatting data? The following code does'nt work either:


l_item-text = l_date.

Do you have any other suggestions or a complexte code example? The problem is, I have other values as well, that should get formatted, too. For example I have numbers with leading "0", like 0000012345. And I don't want the the leading "0" to be displayed, too. So, I'm looking for a generic solution. I know, that an ALV Grid has that feature, so my hope is, that the tree control offers this as well.

Kind regards, Lars

Read only

0 Likes
649

Hi

Use WRITE statament when you transfer the value to the TREE:

DATA l_item TYPE mtreeitem.

DATA l_date TYPE dats.

DATA l_char TYPE char10.

READ TABLE itab WITH key ... ASSIGNING <l_entry>.

l_date = <l_entry>-datab.

WRITE l_date TO l_item-text.

If field DATAB is type DATS, you can write it directly in the TREE without to use L_DATE:

WRITE <l_entry>-datab TO l_item-text.

Max

Read only

0 Likes
649

Thanks Max,

that made the trick.

Kind regards, Lars