Skip to Content

ALV column displays either button or text ?

Dear collegues,

I want to display one column in an ALV table that either displays a button (with a text on it) or displays a text (without button). The decision what of these 2 possibilites is shown should be controlled by the runtime data (eg. the WD context).

PS: I know how to display one ALV column with only buttons or one ALV column with only text.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Oct 07, 2008 at 12:29 PM

    Hello,

    Take a look on this: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393 it's a good reference to your needs.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 07, 2008 at 12:30 PM

    Hi christain,

    Please refer this article written by me.

    In that i made one cell is with chebox and the other is with text.You can use same logic to place button instead of checkbox from my article.

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0e7461d-5e6c-2b10-dda9-9e99df4d136d

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 07, 2008 at 03:35 PM

    Thank you for your answers:

    I have another related problem: Display either a button or an icon in the same ALV column. Can I do this with the same logic (from Suman Kumar Chinnam) ?

    If yes, how to tell the cell variant that it should display not a text but a icon ?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Christian,

      It is very simple to make a column with either button or text.

      Depend on the condition you want either button or text am i right? if it is so then populate your cell_editor with either button or text thats all your column will be either button or text.

  • Oct 08, 2008 at 07:03 AM

    Hallo Saman Kumar,

    I understand your document that describes how to have either a button or a text in the same column.

    But my second problem is: I want to have either a button or an ICON in the same column.

    Thanks in advance.

    Regards,

    Christian

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Yes you can use my logic to achieve your requirement.

      check this code below.

      DATA button1 TYPE REF TO CL_SALV_WD_UIE_BUTTON.

      DATA l_column TYPE REF TO cl_salv_wd_column.

      l_column = l_table->if_salv_wd_column_settings~get_column( 'CARRID' ).

      CREATE OBJECT button1

      EXPORTING

      value_fieldname = 'CARRID'.

      l_column->set_cell_editor( input1 ).

      DATA image1 TYPE REF TO CL_SALV_WD_UIE_IMAGE.

      CREATE OBJECT image1

      EXPORTING

      value_fieldname = 'CARRID'.

      image1->set_source("image").

      DATA l_cv TYPE REF TO cl_salv_wd_cv_standard.

      CREATE OBJECT l_cv.

      l_cv->set_key( 'TEXT_VIEW' ).

      l_cv->set_editor( image1 ).

      l_column->add_cell_variant( l_cv ).

      l_column->set_sel_cell_variant_fieldname( 'CELL_VARIANT' ).

  • Oct 08, 2008 at 10:42 AM

    Hi Suman Kumar,

    thanks again. It looks fine.

    My last 2 question would be:

    a) Is the command l_cv->set_key( 'TEXT_VIEW' ) still correct to display the icon ?

    b) What I fill into the new context field 'CELL_VARIANT' while runtime ? Should it filled with u201CTEXT_VIEWu201D to display the icon

    and with u201C u201C to display the button ?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Christian,

      a) Is the command l_cv->set_key( 'TEXT_VIEW' ) still correct to display the icon ?

      yes there is a no show stopper to display icon.since TEXT_VIEW is a string value to populate text/check box conditionally.

      b) What I fill into the new context field 'CELL_VARIANT' while runtime ? Should it filled with u201CTEXT_VIEWu201D to display the iconand with u201C u201C to display the button ?

      you can give either button or icon to cell_variant.Follow my code as it is .you will get the output.