Skip to Content
avatar image
Former Member

OO ALV Grid, fix with of columns

Hi all,

i use cl_gui_alv_grid to display an ALV in my dynpro and i need to set the width of columns ; i read that i had to use the field outputlen (structure LVC_S_FCAT) but it don't work.

Do you have a sample for me ?

Regards

Eric

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

9 Answers

  • Nov 03, 2015 at 07:59 PM

    It looks like there is no way to fix columns width.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 03, 2015 at 06:23 PM

    I've used this sample code with some success. The outputlen is in the build_fcat.

    ALV Report using class CL_GUI_ALV_GRID ~ Team ABAP

    Jeremy

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 04, 2015 at 06:50 AM

    Hi Eric,

    Create a reference object to the class cl_salv_columns_table and use this set of code to optimize the column length

    obj_columns = obj_salv->get_columns( ).

    obj_columns->set_key_fixation( 'X' ).

    obj_columns->set_optimize('X').

    Regards,

    Thulja

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 04, 2015 at 07:43 AM

    Hi Erik,

    Pls check

    CLEAR ls_fieldcat.

    ls_fieldcat-fieldname = 'MATNR'.

    ls_fieldcat-ref_tabname = 'VBAP'.

    ls_fieldcat-ref_fieldname = 'MATNR'.

    ls_fieldcat-outputlen = 30.

    ls_fieldcat-key = 'X'.

    APPEND ls_fieldcat TO pt_fieldcat.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 04, 2015 at 08:00 AM
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 06, 2015 at 07:37 PM

    Hi, Eric! Did you find the solution?

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 18, 2015 at 12:19 PM

    Hi Eric,

    Set the field CWIDTH_OPT as 'X' in layout structure LVC_S_LAYO.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 18, 2015 at 12:40 PM

    Hi Eric,

    Sorry to say for this problem we d'not have any solution .

    on more scenario,

    we working with interactive oalv. before interaction we have proper aliened alv but after interaction that column width automatically reset .this is the situation i face when i tried to fix the column width in O alv.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 18, 2015 at 12:51 PM

    You can only set a default/desired length (field OUTPUTLEN of field catalog) but user shall be able to change it, and of course you must remove the optimize column (field CWIDTH_OPT of layout)

    A solution "could" be coded, you have to handle the event AFTER_REFRESH to check field catalog, (GET_FRONTEND_FIELDCATALOG) and if required, update it (SET_FRONTEND_FIELDCATALOG) and display again the grid (REFRESH_TABLE_DISPLAY)

    Hint: Try to prevent infinite loop of refresh event <-> refresh method...

    Regards,

    Raymond

    Add comment
    10|10000 characters needed characters exceeded