02-09-2016 10:20 AM
Hi together,
Is it possible to use wordwraps with ALV lists?
The goal is to display several text lines on below the other in just one report cell.
Thanks for any help
02-09-2016 10:47 AM
You are using FM REUSE_ALV_LIST_DISPLAY?
This question was answered here http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/abap/_abap/u-z/Word%20Wrap%20Functiona...
If you are using CL_GUI_ALV_GRID there is this attribute : CO_WEBSTYLE_WRAP but i never used it
02-09-2016 10:47 AM
You are using FM REUSE_ALV_LIST_DISPLAY?
This question was answered here http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/abap/_abap/u-z/Word%20Wrap%20Functiona...
If you are using CL_GUI_ALV_GRID there is this attribute : CO_WEBSTYLE_WRAP but i never used it
02-09-2016 12:50 PM
Hi Simone,
The ALV list in page 6 locks OK. Unfortunately I do not access to the sample coding.
Could you provide me with it?
Thanks in advance
02-09-2016 1:01 PM
I took a screenshot from the example (it's a PDF on the Wiki here)
02-09-2016 1:07 PM
02-09-2016 1:17 PM
No, but it shows the mandatory and important points.
If you google a bit with Word Wrap ALV List you find immediately the correct link.
I do not remember if i can link external sites from SCN so i copy here the code
See below for Sample code
*&---------------------------------------------------------------------
*& Report ZTEST_WRAP
*&---------------------------------------------------------------------
*& Wrap the column into multiple lines incase Column width is less
*&---------------------------------------------------------------------
report ztest_wrap.
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_data,
emp TYPE char10,
emp_name TYPE char100,
emp_name1 TYPE char20,
END OF ty_data.
TYPES: BEGIN OF ty_wrd,
emp TYPE char20,
END OF ty_wrd.
CONSTANTS: c_len TYPE i VALUE 10.
DATA: report_id LIKE sy-repid,
it_sentence TYPE TABLE OF ty_wrd,
wa_word TYPE ty_wrd,
v_repid TYPE syst-repid,
v_tabix TYPE syst-tabix.
DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
DATA: it_evt TYPE slis_t_event,
it_fld TYPE slis_t_fieldcat_alv,
wa_fld TYPE slis_fieldcat_alv,
wa_evt TYPE slis_alv_event,
wa_lay TYPE slis_layout_alv.
DATA: watab TYPE ty_data,
i_data TYPE STANDARD TABLE OF ty_data,
count TYPE i VALUE 0.
* Number of records
DO 4 TIMES.
count = count + 1.
CASE count.
WHEN 1.
watab-emp = '10'.
CONCATENATE 'Purpose of this tutorial is to provide an easy'
'and quick reference which may be used as a'
'guide' INTO
watab-emp_name.
.
APPEND watab TO i_data.
CLEAR watab.
WHEN 2.
watab-emp = '20'.
watab-emp_name = 'Coding is done for ALV List Display'.
APPEND watab TO i_data.
CLEAR watab.
WHEN 3.
watab-emp = '30'.
CONCATENATE 'Same functionality can be implemented for ALV'
'Grid Display also'
INTO
watab-emp_name.
APPEND watab TO i_data.
CLEAR watab.
ENDCASE.
ENDDO.
report_id = sy-repid.
CLEAR wa_fld.
wa_fld-fieldname = 'EMP'.
wa_fld-ref_tabname = 'I_DATA'.
wa_fld-seltext_l = 'EMP. ID'.
wa_fld-ref_fieldname = 'EMP'.
APPEND wa_fld TO it_fld.
CLEAR wa_fld.
wa_fld-fieldname = 'EMP_NAME1'.
wa_fld-inttype = 'CHAR'.
wa_fld-outputlen = 20.
wa_fld-intlen = 20.
wa_fld-seltext_l = 'EMP. NAME'.
wa_fld-ddictxt = 'L'.
APPEND wa_fld TO it_fld.
* Word Wrap the text in multiple lines
LOOP AT i_data INTO watab.
v_tabix = sy-tabix.
CLEAR: it_sentence[].
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = watab-emp_name
outputlen = c_len
TABLES
out_lines = it_sentence
EXCEPTIONS
outputlen_too_large = 1
OTHERS = 2.
IF sy-subrc EQ 0.
IF NOT it_sentence IS INITIAL.
READ TABLE it_sentence INTO wa_word INDEX 1.
watab-emp_name1 = wa_word-emp.
MODIFY i_data FROM watab INDEX v_tabix.
ENDIF.
ENDIF.
ENDLOOP.
* Get event. We will handle BEFORE and AFTER line output
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
et_events = it_evt.
READ TABLE it_evt INTO wa_evt WITH KEY name = slis_ev_after_line_output.
wa_evt-form = slis_ev_after_line_output.
MODIFY it_evt FROM wa_evt INDEX sy-tabix.
wa_lay-edit = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = report_id
is_layout = wa_lay
it_fieldcat = it_fld
it_events = it_evt
TABLES
t_outtab = i_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Exceptions will be handled as per requirement
ENDIF.
*---------------------------------------------------------------------*
* FORM AFTER_LINE_OUTPUT *
*---------------------------------------------------------------------*
FORM after_line_output USING rs_lineinfo TYPE slis_lineinfo.
CLEAR: it_sentence, watab.
READ TABLE i_data INTO watab INDEX rs_lineinfo-tabindex.
CHECK sy-subrc = 0.
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = watab-emp_name
outputlen = c_len
TABLES
out_lines = it_sentence.
DESCRIBE TABLE it_sentence LINES v_tabix.
CHECK v_tabix > 1.
LOOP AT it_sentence INTO wa_word FROM 2.
WRITE: / sy-vline,
12 sy-vline,
13 wa_word-emp,
33 sy-vline.
ENDLOOP.
ENDFORM. "after_line_output
02-09-2016 2:05 PM
Hi Simone,
This coding does not really match the requierement, since the text is not written in only 1 cell.
In order to display the list like on page 6 of the above documentation..
10 abcde
fghij
klm
30 nopqr
stuvw
I first have to fill watab-emp (=10) and then leave it empty for 2 times...and so on.
The problem is, I am not able to sort the list by column 'watab-emp'.
02-09-2016 2:42 PM
Hi Simone,
By the way...
Can you explain to me, what form 'AFTER_LINE_OUTPUT' is for?. It is not beeing processed while executing the program.
02-09-2016 2:55 PM
That form it's called by event AFTER_LINE_OUTPUT, when the REUSE_ALV_LIST_DISPLAY "writes" a line.
After finishing each line, the form is triggered and perform anything you put in it.
02-09-2016 3:14 PM
Hi Simone,
What does "...anything you put in it" mean? Where can I put something?
In Form "AFTER_LINE_OUTPUT", V_TABIX is always = 1.
What do have to do to get an output list, comparable to page 6 of the documentation you first sent me?
10 abcde
fghij
klm
20 nopqr
stuvw
Thanks for your patience
02-09-2016 3:27 PM
It means exactly that: in that form you can put a check, a message, any piece of code you think it could be useful.
And in the example, the author implemented the "word wrapping" workaround.
Changing c_len from 100 to 10, it works perfectly for me.
02-09-2016 3:39 PM
Hi Simone,
sorry for that mess.
Your coding is just perfect.
I had copied the sample coding from another site right before you sent me your version.
But that coding deviates a little from your version, although the report name is the same.
02-09-2016 3:47 PM
So it's ok and your issue is solved? If so, close the answer before the moderators bite!
02-11-2016 1:06 PM
Hi Simone,
I have 3 more questions on that topic.
1.) Since in form 'after_line_output' sy-vline is fix you are not able to change layout settings with
the ALV List.
2.) you can not use direct-link to Excel (...without losing the word wrap).
3.) Is it possible to separate every dataset with a 'sy-unline'? ('zebra' works ok)
Do you have any idea?
Thanks in advance
02-11-2016 1:10 PM
I admit i do not know, i did a bit of google and fixed as quick test.
1) For sure, you can read the selected layout and then identify the position where to print the data
2) Yes, this is a workaround
3) You can add it in your LOOP
02-11-2016 1:35 PM
1) how does that work?
2) ok, bad news
3) I´ve already checked that out. It does not work properly since the LOOP is not being
processed for datasets without a word wrap (v_tabix EQ 1).
So there is no parameter to activate 'ulines'.
02-11-2016 1:46 PM
1) check this link with same (solved) issue: How to get ALV Field Catalog/Layout AFTER user ... | SCN
3) instead of CHECK v_tabix eq 1, put an IF
IF tabix EQ 1
Write/1: sy-uline
else.
loop as now with uline
endif
02-11-2016 2:15 PM
Hi Simone,
1) the problem is following coding section:
LOOP AT it_sentence INTO wa_word FROM 2.
WRITE: / sy-vline,
12 sy-vline,
13 wa_word-emp,
33 sy-vline.
ENDLOOP.
There is no fieldcat. The position of sy-vline and wa_word-emp can not be changed.
02-12-2016 7:26 AM
Hi Simone,
3) also does not work. The standard output list has a frame. If you put an 'IF'...
there is always a 'sy-uline' display below this frame. That looks a little weird.