10-15-2023 9:56 AM
Hello Experts,
I call REUSE_ALV_GRID_DISPLAY .
REPORT ZTRY_GRID_AND_HOST.
TYPES: BEGIN OF lsty_lfa1_with_color,
color_tbl TYPE slis_t_specialcol_alv.
INCLUDE STRUCTURE lfa1.
TYPES: END OF lsty_lfa1_with_color.
TYPES:ltty_lfa1_with_color TYPE TABLE OF lsty_lfa1_with_color.
DATA: lt_lfa1 TYPE ltty_lfa1_with_color
,ls LIKE LINE OF lt_lfa1
,lt_fldcat TYPE slis_t_fieldcat_alv
,lt_color_tbl TYPE slis_t_specialcol_alv
,ls_color_tbl LIKE LINE OF lt_color_tbl
.
ls_color_tbl-fieldname = 'LIFNR'.
ls_color_tbl-color-col = '3'.
ls_color_tbl-color-int = '1'.
ls_color_tbl-color-inv = '1'.
APPEND ls_color_tbl TO lt_color_tbl.
ls_color_tbl-fieldname = 'LAND1'.
ls_color_tbl-color-col = '6'.
ls_color_tbl-color-int = '0'.
ls_color_tbl-color-inv = '1'.
APPEND ls_color_tbl TO lt_color_tbl.
DO 5 TIMES.
ls-lifnr = '1000'.
ls-land1 = 'A'.
ls-color_tbl = lt_color_tbl.
APPEND ls TO lt_lfa1.
ENDDO.
DATA: ls_fldcat LIKE LINE OF lt_fldcat.
ls_fldcat-reptext_ddic = 'vendor'.
ls_fldcat-fieldname = 'LIFNR'.
ls_fldcat-tabname = 'LFA1'.
ls_fldcat-outputlen = 10.
ls_fldcat-col_pos = 2.
ls_fldcat-hotspot = 'X'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-reptext_ddic = 'land'.
ls_fldcat-fieldname = 'LAND1'.
ls_fldcat-tabname = 'LFA1'.
ls_fldcat-outputlen = 10.
ls_fldcat-col_pos = 3.
APPEND ls_fldcat TO lt_fldcat.
*LOOP AT lt_fldcat ASSIGNING FIELD-SYMBOL(<ls_fldcat>) WHERE fieldname = 'LIFNR'.
* <ls_fldcat>-edit = abap_true.
*ENDLOOP.
DATA: ls_layout TYPE slis_layout_alv.
*ls_layout-coltab_fieldname = 'COLOR_TBL'.
ls_layout-colwidth_optimize = 'X'.
ls_layout-max_linesize = 30. "69
*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
* i_callback_user_command = 'USER_COMMAND'
is_layout = ls_layout
it_fieldcat = lt_fldcat
TABLES
t_outtab = lt_lfa1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE i002(zgen) DISPLAY LIKE 'E'.
ENDIF.
How can I control the width of the ALV? (not the width of a specific column). The width is fixed. When there are few columns, an unnecessary space is created (see yellow). When there are many columns, the ALV cannot be increased and a scrollbar is created.
When I set attribute max_linesize of the layout it does not affect the ALV's width. (line 69).
By the way, the problem does not exist when using REUSE_ALV_LIST_DISPLAY.
Thank you in advanced
Hagit
10-15-2023 1:26 PM
I think that you'll always see this line. The only way to reduce it is to reduce the container width to be the total width of all columns. As far as I know, SAP never did that in his own applications. I know how to approximate but it may be wrong, so need to multiply by a given factor to make sure all columns are visible. Conclusion: I think it's impossible to achieve a good result, also no interest except if you meet nitpicking people (focusing on things of no interest), so it's not worth spending time on it.
10-15-2023 1:33 PM
sandra.rossi Thank you for your answer.
How can I reduce/increase the container width (when using REUSE_ALV_GRID)?
10-15-2023 7:41 PM
Many ways. A container can be:
(also Dynpro popup if it's something you can afford)