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

colwidth_optimize not working for alv grid report

Former Member
0 Likes
4,685

Hi friends,

I have developed an ALV grid report using 'REUSE_ALV_GRID_DISPLAY'. The field catalog field columns are having the heading size more than 30 characters. So, to optimize the size of the headings, I am using SLIS_LAYOUT_ALV and passing the value 'X' to colwidth_optimize.

but still the column heading is not getting fully display. Rather it is display first 20 characters only.

For your reference please find the code snippet


*bold* **************** declarations ************************ *bold*
DATA : fieldcat       TYPE slis_fieldcat_alv,
             t_fieldcat     TYPE slis_t_fieldcat_alv,
            ws_layout      TYPE slis_layout_alv.
            


*bold* **************** field catalogue ********************** *bold*
  CLEAR fieldcat.
  fieldcat-fieldname     = 'RFWRT_PD_MTRL'.
  fieldcat-seltext_m = 'Pending Quotation Spares Value'.   {quote} this heading not getting fully displayed {quote}
  fieldcat-tabname       = 'IT_FNL'.
***    FIELDCAT-REF_TABNAME   = 'VBFA'.
  fieldcat-col_pos       = col_pos.
  APPEND fieldcat TO t_fieldcat.
  ADD 1 TO col_pos.

  CLEAR fieldcat.
  fieldcat-fieldname     = 'RFWRT_PD_SERV'.
  fieldcat-seltext_m = 'Pend Quot-JobWorkVal'.
  fieldcat-tabname       = 'IT_FNL'.
  fieldcat-col_pos       = col_pos.
  APPEND fieldcat TO t_fieldcat.
  ADD 1 TO col_pos.


  ws_layout-colwidth_optimize = 'X'.


*bold* ****************************** alv grid function call ******************** *bold*
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*    i_buffer_active                         = space
      i_callback_program                  = sy-repid
     i_callback_user_command        = 'USER_COMMAND'
***   i_callback_pf_status_set           = 'PF_STATUS'
*   I_STRUCTURE_NAME                  =
     it_fieldcat                        = t_fieldcat[]
     is_layout                          =  ws_layout
    TABLES
      t_outtab                          = it_fnl
   EXCEPTIONS
     program_error                      = 1
     OTHERS                             = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CLEAR wa_fnl.

Please look into it.

Searched the forum for the similar issue. but didnt got any solution.

Thanks and regards,

Murali Krishna

Hi friends,

I have developed an ALV grid report using 'REUSE_ALV_GRID_DISPLAY'. The field catalog field columns are having the heading size more than 30 characters. So, to optimize the size of the headings, I am using SLIS_LAYOUT_ALV and passing the value 'X' to colwidth_optimize.

but still the column heading is not getting fully display. Rather it is display first 20 characters only.

For your reference please find the code snippet


*bold* **************** declarations ************************ *bold*
DATA : fieldcat       TYPE slis_fieldcat_alv,
             t_fieldcat     TYPE slis_t_fieldcat_alv,
            ws_layout      TYPE slis_layout_alv.
            


*bold* **************** field catalogue ********************** *bold*
  CLEAR fieldcat.
  fieldcat-fieldname     = 'RFWRT_PD_MTRL'.
  fieldcat-seltext_m = 'Pending Quotation Spares Value'.   {quote} this heading not getting fully displayed {quote}
  fieldcat-tabname       = 'IT_FNL'.
***    FIELDCAT-REF_TABNAME   = 'VBFA'.
  fieldcat-col_pos       = col_pos.
  APPEND fieldcat TO t_fieldcat.
  ADD 1 TO col_pos.

  CLEAR fieldcat.
  fieldcat-fieldname     = 'RFWRT_PD_SERV'.
  fieldcat-seltext_m = 'Pend Quot-JobWorkVal'.
  fieldcat-tabname       = 'IT_FNL'.
  fieldcat-col_pos       = col_pos.
  APPEND fieldcat TO t_fieldcat.
  ADD 1 TO col_pos.


  ws_layout-colwidth_optimize = 'X'.


*bold* ****************************** alv grid function call ******************** *bold*
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*    i_buffer_active                         = space
      i_callback_program                  = sy-repid
     i_callback_user_command        = 'USER_COMMAND'
***   i_callback_pf_status_set           = 'PF_STATUS'
*   I_STRUCTURE_NAME                  =
     it_fieldcat                        = t_fieldcat[]
     is_layout                          =  ws_layout
    TABLES
      t_outtab                          = it_fnl
   EXCEPTIONS
     program_error                      = 1
     OTHERS                             = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CLEAR wa_fnl.

Please look into it.

Searched the forum for the similar issue. but didnt got any solution.

Thanks and regards,

Murali Krishna

2 REPLIES 2
Read only

Former Member
0 Likes
1,489

you've used seltext_m instead of seltext_l...seltext_m is 20 characters.

Read only

0 Likes
1,489

Hi DaveL,

Thanks alot for your help. My problem solved.

Can you please suggest me how we can optimize the column based on the total amount which is summed up (fieldcat-do_sum)

Regards,

Murali.