Application Development 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: 

How to wrap text in ALV?

Former Member
0 Kudos

Hi Guys,

I am facing one problem with displaying text in output list.The text is more than one line and I am trying to bring it to the next line.

As there are too many fields in output, I am displaying in 4 rows ( So, each record in 4 rows ). But my last field is some text and it could be any number of lines.

Any suggestions how to get this?

Thanks in advance,

Br

9 REPLIES 9

Former Member
0 Kudos

How about put the first line of text on the screen. In front of that put an integer field that lists the total number of lines. Make the integer field a hotspot. You could also make the text field a hotspot. If the user clicks on it, then display a popup window with an ALV grid or editor control to display all of the text.

Lot of details missing here. Let us know how it goes.

0 Kudos

Thanks very much Charles for ur reply..

AM using the FM REUSE ALV LIST DISPLAY. Through field catalog(Defined row position) I am displying each record in 4 rows and the output list width is fixed to 120 columns.Where as my last field(4th row) is text which is around 500 Char. Now I want to break this and bring it to next line. Hope you understand my problem..

Guys any ideas?

Regards,

Br

0 Kudos

As I understand you want to split long text into lines inside your 4th row. Am I right? If so, as far as I know ALV doesn't permit to do this.

May be "dynamic documents" will suit your needs?

See for example programs:

DD_ADD_TEXT

DD_ADD_FORM_BUTTON

DD_ADD_FORM_INPUT

DD_ADD_LINK

DD_ADD_LINK_SCROLLED

DD_ADD_PICTURE

DD_ADD_STATIC_HTML

DD_ADD_TABLE

Regards,

Maxim.

0 Kudos

Hi,

You have said that this last field is about 500 characters. Is this field likely to contain so many characters? For example, if you think that this field will usually contain only, let us say, 60 characters, then you can modify the field catalog to display only the 60 characters.

On the other hand, if this field is likely to contain very long texts of unpredictable length, then I guess the users will not always want to see and read the contents of this field. In such a case, you can display, simply an icon in this field and make it a Hotspot. those users who are interested in reading the long text will click the icon and on that event you can display the text in a pop-up.

Under the given constraints, this is the only option I can think of.

Please do let us know how it goes.

Regards,

Anand Mandalika.

0 Kudos

Hi,

We have had a similar situation. Since ALV List does not support automatic truncation to next line, a work around could be to define a small subroutine of your own that breaks up the text into multiple lines and save it temporarily in an itab. While filling your expected fourth/last line, you could loop on your itab and append as many lines to your final itab as you want.

The subroutine could be something like;

1. Take text, text lenght, and base lenght as input. Take a ref to str_tab to return broken text

2. Loop through the text and break at base lenght to fill lines of str_tab

3. Return str_tab.

NOTE: you will have to take care of the situation when a particular word is not completed at base_len.

There are a couple of FMs in SAP as well that you might want to take a look at. Search in SE37 for split. They might be helpful.

Regards

Shehryar

Message was edited by: Shehryar Khan

0 Kudos

Thanks very much guys..

Right now I am doing the same, breaking the text into multiple lines and appending to my main internal table as separate line.But when I pass my main itab to ALV FM it displaying as next record.The cells should merge if it founds the same value in other fields. But it's not happening here..I think This FM(REUSE_ALV_LIST_DISPLY) doesn't support for cell merge..

Thanks once again for all your suggestion...

Regds,

Br

0 Kudos

have you tried REUSE_ALV_GRID_DISPLY same but output looks nicer and rows should merge.

0 Kudos

Put the first line of text in a char field. Put all lines of text in an internal table that is the last component of the internal table that you are displaying in the ALV grid.

So now we have an internal table with a field defined at the end that is another internal table. The structure that you pass on to ALV should not include any definition for the internal table component at the end. As far as I know, ALV cannot handle an internal table within an internal table so by putting it at the end and not defining it in your structure and/or fieldcatalog, ALV will ignore.

Now you can hotspot the one char field that you are displaying to bring up a popup window that shows all of the text that was hiding in the internal table at the end of the row. You could also add an interger field as I mentioned earlier to let the user know how much text is hiding. That can also be a hotspot.

Again, lots of details missing but maybe this will help.

Former Member
0 Kudos

All,

You should not use REUSE_ALV_GRID_DISPLAY or REUSE_ALV_LIST_DISPLAY for this. For lists that have multiple lines per record, you have 2 choices:

1) Use REUSE_ALV_HIERSEQ_LIST_DISPLAY. This will output a multi-line line in ALV, albeit and ALV list. You will still need to split your long text into multiple rows in your internal table.

2) Use CL_SALV_HIERSEQ_TABLE if you are using WebAS 6.40. Same principle as (1) but in a SAP Control context.