Application Development 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: 

'Reuse_alv_grid_display' : making a specific row bold

Former Member
0 Kudos

Hi,

I am using the FM : 'Reuse_alv_grid_display' to display my list. Could You please tell me how i can make a specific row in the output bold ???

Thanks

Akash

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Akashdeep,

I dont think it is possible using REUSE_ALV_GRID_DISPLAY

but it is possible using REUSE_ALV_GRID_DISPLAY_LVC.

Check the below example.

TYPE-POOLS: abap.

TYPES : BEGIN OF ty_outtab,
        celltab TYPE lvc_t_styl.
        INCLUDE STRUCTURE qals.
TYPES   END   OF ty_outtab.

DATA  : gt_outtab  TYPE TABLE OF ty_outtab WITH HEADER LINE,
        gs_layout  TYPE lvc_s_layo,
        ls_celltab TYPE lvc_s_styl,
        lt_celltab TYPE lvc_t_styl.

SELECT * FROM qals INTO CORRESPONDING FIELDS OF TABLE gt_outtab UP TO 20 ROWS.

ls_celltab-style = '00000120'.

INSERT ls_celltab INTO lt_celltab INDEX 1.

READ TABLE gt_outtab INDEX 1.

gt_outtab-celltab = lt_celltab.

INSERT gt_outtab INDEX 1.

gs_layout-stylefname = 'CELLTAB'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_structure_name = 'QALS'
    is_layout_lvc    = gs_layout
  TABLES
    t_outtab         = gt_outtab
  EXCEPTIONS
    program_error    = 1
    OTHERS           = 2.

Cheers,

Jose.

10 REPLIES 10

Former Member
0 Kudos

just check out the specifications in List layout specifications i.e.IS_LAYOUT.

probably you can find the attribute over there for changing the font size nad making it bold

former_member598013
Active Contributor
0 Kudos

Hi Akshadeep,

By using the FM " REUSE_ALV_GRID_DISPLAY" you cannot set any particular row as a bold. But you can set the Colum as a Bold.

Instead of this why dont you try by OOALV. This will solve your problem,

Thanks,

Chidanand

Former Member
0 Kudos

coltab_fieldname

Value range: SPACE, field name of the internal output table

You can color cells individually by using a color code that is set for the row of the cells in a column of the internal output table.

You must assign the field name of the field with the color code to this parameter.

The field of the internal output table must be of type SLIS_T_SPECIALCOL_ALV.

Principle: The field for the color code is filled in the row in which the cells to be colored are located. The field then contains an internal table of the above structure that includes the field names of the cells to be colored with the color code. The cell coordinates are therefore derived from the row position in which the color code is written and the column information contained in the color table.

The row structure of the internal color table of type SLIS_T_SPECIALCOL_ALV is as follows:

Farbtabelle-NAME = Field name of cell to be colored

Farbtabelle-COLOR-COL = Color number (1 - 9)

Farbtabelle-COLOR-INT = Intensified (0 = off, 1 = on)

Farbtabelle-COLOR-INV = Inverse (0 = off, 1 = on)

Farbtabelle-NOKEYCOL = Ignore key coloring ('X' = yes, ' ' = no)

If parameter Farbtabelle-NAME is not filled, all color specifications refer to all fields. As a result, the entire row is colored.

Default

In many cases, the default layout settings can be kept so that you frequently do not need to pass this structure with modified flags.

Note:

All other fields not specified here explicitly are not relevant for use with REUSE_ALV_GRID_DISPLAY or are not released.

Regards,

Swami.

Former Member
0 Kudos

hi..

i dont think we can BOLD a particular row in alv.

u can try with coloring them.

check this thread.

regards,

padma

Former Member
0 Kudos

Hi,

You can try like this to highlight a particular row....


loop your table...
condition :- the row you want to highlight....
then for that row...
wa_final-line_color = 'C400'----------------> ( its combination can varry...
                                                            1st charecter = C
                                                             2nd = 1-9
                                                             3rd = 1 or 0
                                                             4th = 1or 0 )
modify your final table....
endloop.

also..



declare line_color(4) TYPE c, in your final table structure...

and IN LAYOUT pass
  it_layout-info_fieldname =      'LINE_COLOR'.

Regards

Debarshi

Former Member
0 Kudos

Hi Akashdeep,

I dont think it is possible using REUSE_ALV_GRID_DISPLAY

but it is possible using REUSE_ALV_GRID_DISPLAY_LVC.

Check the below example.

TYPE-POOLS: abap.

TYPES : BEGIN OF ty_outtab,
        celltab TYPE lvc_t_styl.
        INCLUDE STRUCTURE qals.
TYPES   END   OF ty_outtab.

DATA  : gt_outtab  TYPE TABLE OF ty_outtab WITH HEADER LINE,
        gs_layout  TYPE lvc_s_layo,
        ls_celltab TYPE lvc_s_styl,
        lt_celltab TYPE lvc_t_styl.

SELECT * FROM qals INTO CORRESPONDING FIELDS OF TABLE gt_outtab UP TO 20 ROWS.

ls_celltab-style = '00000120'.

INSERT ls_celltab INTO lt_celltab INDEX 1.

READ TABLE gt_outtab INDEX 1.

gt_outtab-celltab = lt_celltab.

INSERT gt_outtab INDEX 1.

gs_layout-stylefname = 'CELLTAB'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_structure_name = 'QALS'
    is_layout_lvc    = gs_layout
  TABLES
    t_outtab         = gt_outtab
  EXCEPTIONS
    program_error    = 1
    OTHERS           = 2.

Cheers,

Jose.

0 Kudos

Hi all,

Thanks for ur help... Thanks so much..

Hi Jose,

Can i set a particular row to a different colour which has already been set to bold by your code ?

0 Kudos

Hi Akashdeep,

Coloring a row here is very simillar to coloring a row using REUSE_ALV_GRID_DISPLAY.

check the modified code....

TYPE-POOLS: abap.

TYPES : BEGIN OF ty_outtab,
        celltab TYPE lvc_t_styl.
        INCLUDE STRUCTURE qals.
TYPES   color   TYPE char04.              " new line added
TYPES   END   OF ty_outtab.

DATA  : gt_outtab  TYPE TABLE OF ty_outtab WITH HEADER LINE,
        gs_layout  TYPE lvc_s_layo,
        ls_celltab TYPE lvc_s_styl,
        lt_celltab TYPE lvc_t_styl.

SELECT * FROM qals INTO CORRESPONDING FIELDS OF TABLE gt_outtab UP TO 20 ROWS.

ls_celltab-style = '00000120'.

INSERT ls_celltab INTO lt_celltab INDEX 1.

READ TABLE gt_outtab INDEX 1.

gt_outtab-celltab = lt_celltab.
gt_outtab-color   = 'C500'.              " new line added

INSERT gt_outtab INDEX 1.

gs_layout-stylefname = 'CELLTAB'.
gs_layout-info_fname = 'COLOR'.          " new line added

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_structure_name = 'QALS'
    is_layout_lvc    = gs_layout
  TABLES
    t_outtab         = gt_outtab
  EXCEPTIONS
    program_error    = 1
    OTHERS           = 2.

Cheers,

Jose.

former_member188685
Active Contributor
0 Kudos

you can do some thing like this.., but you have to use the top_of_page event and show some information.

REPORT  ztest_alv_001.

include <CL_ALV_CONTROL>.
TYPE-POOLS: slis.

DATA: it_sort TYPE  slis_t_sortinfo_alv,
      wa_sort LIKE LINE OF it_sort.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
      wa_fcat LIKE LINE OF it_fieldcat.

DATA: BEGIN OF it_flight OCCURS 0,
      carrid LIKE sflight-carrid,
      connid LIKE sflight-connid,
      style TYPE lvc_t_styl, "FOR DISABLE
     END OF it_flight.
DATA: wa_flight LIKE LINE OF it_flight.
DATA: layout TYPE lvc_s_layo.
DATA: o_grid TYPE REF TO cl_gui_alv_grid.

START-OF-SELECTION.

  SELECT carrid connid FROM sflight
  INTO CORRESPONDING FIELDS OF TABLE it_flight
  UP TO 20 ROWS.

 "{ FOR Applying styles
  DATA: ls_style TYPE lvc_s_styl,
        lt_style TYPE lvc_t_styl.
  "} FOR Styles


  wa_fcat-seltext_l = 'CARRID'.
  wa_fcat-fieldname = 'CARRID'.
  wa_fcat-tabname = 'IT_FLIGHT'.
  wa_fcat-outputlen = '10'.
  APPEND wa_fcat TO it_fieldcat.
  CLEAR wa_fcat.

  wa_fcat-seltext_l = 'Connid'.
  wa_fcat-fieldname = 'CONNID'.
  wa_fcat-tabname = 'IT_FLIGHT'.
  wa_fcat-outputlen = '10'.
  APPEND wa_fcat TO it_fieldcat.
  CLEAR wa_fcat.


  LOOP AT it_flight INTO wa_flight.
    IF sy-tabix = 6.
      ls_style-style = alv_style_font_bold.
    ELSE.
      ls_style-style = alv_style_font_italic.
    ENDIF.

    ls_style-fieldname = 'CARRID'.
    INSERT ls_style INTO TABLE lt_style.
    ls_style-fieldname = 'CONNID'.
    INSERT ls_style INTO TABLE lt_style.
    INSERT LINES OF lt_style INTO TABLE wa_flight-style.
    MODIFY it_flight INDEX sy-tabix FROM wa_flight  TRANSPORTING
                                      style .
    CLEAR lt_style.

  ENDLOOP.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program          = sy-repid
      i_callback_html_top_of_page = 'TOP_OF_PAGE'
      it_fieldcat                 = it_fieldcat
    TABLES
      t_outtab                    = it_flight
    EXCEPTIONS
      program_error               = 1
      OTHERS                      = 2.
  IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->HEADER     text
*----------------------------------------------------------------------*
FORM top_of_page USING header TYPE REF TO cl_dd_document.
  DATA: ls_text TYPE sdydo_text_element,
        meth(20) TYPE c VALUE 'SET_FRONTEND_LAYOUT'.

  IF o_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = o_grid.

    layout-stylefname = 'STYLE'.

    CALL METHOD o_grid->(meth)
      EXPORTING
        is_layout = layout.

    CALL METHOD o_grid->refresh_table_display.

  ENDIF.
  BREAK-POINT.
ENDFORM.                    "top_of_page

Former Member
0 Kudos

hi Frnd,

the below given program coloring the last row of ALV

Try this code ...

REPORT ZPRI_ALV_ROW_COLOR.

TABLES: MARA , MAKT .

DATA: LAYOUT TYPE LVC_S_LAYO .

DATA: CONT1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER .

DATA: GRID1 TYPE REF TO CL_GUI_ALV_GRID .

DATA: FCAT1 TYPE LVC_T_FCAT .

DATA: WA_FCAT1 LIKE LINE OF FCAT1 .

TYPES : BEGIN OF TYPE_ITAB1 ,

MATNR LIKE MARA-MATNR ,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL ,

MAKTX LIKE MAKT-MAKTX ,

COL(4) TYPE C ,

END OF TYPE_ITAB1 .

DATA: IT_ITAB1 TYPE STANDARD TABLE OF TYPE_ITAB1 WITH HEADER LINE .

DATA: LEN TYPE I.

LAYOUT-INFO_FNAME = 'COL' .

break devuser .

WA_FCAT1-TABNAME = 'IT_ITAB1' .

WA_FCAT1-FIELDNAME = 'MATNR' .

WA_FCAT1-COLTEXT = 'Material' .

WA_FCAT1-OUTPUTLEN = 18 .

APPEND WA_FCAT1 TO FCAT1 .

CLEAR WA_FCAT1 .

WA_FCAT1-TABNAME = 'IT_ITAB1' .

WA_FCAT1-FIELDNAME = 'MTART' .

WA_FCAT1-COLTEXT = 'Material Type' .

WA_FCAT1-OUTPUTLEN = 15 .

APPEND WA_FCAT1 TO FCAT1 .

CLEAR WA_FCAT1 .

WA_FCAT1-TABNAME = 'IT_ITAB1' .

WA_FCAT1-FIELDNAME = 'MATKL' .

WA_FCAT1-COLTEXT = 'Material Group' .

WA_FCAT1-OUTPUTLEN = 15 .

APPEND WA_FCAT1 TO FCAT1 .

CLEAR WA_FCAT1 .

WA_FCAT1-TABNAME = 'IT_ITAB1' .

WA_FCAT1-FIELDNAME = 'MAKTX' .

WA_FCAT1-COLTEXT = 'Description' .

WA_FCAT1-OUTPUTLEN = 25 .

APPEND WA_FCAT1 TO FCAT1 .

CLEAR WA_FCAT1 .

SELECT AMATNR AMTART AMATKL BMAKTX INTO TABLE IT_ITAB1 FROM MARA AS A INNER JOIN MAKT AS B ON AMATNR = BMATNR .

DESCRIBE TABLE IT_ITAB1 LINES LEN .

LEN = LEN .

IT_ITAB1-COL = 'C601' .

MODIFY IT_ITAB1 INDEX LEN FROM IT_ITAB1

TRANSPORTING COL .

CALL SCREEN 100 .

&----


*& Module SHOWALV OUTPUT

&----


  • text

----


module SHOWALV output.

CREATE OBJECT cont1

EXPORTING

  • PARENT =

container_name = 'CUSTOM'

  • STYLE =

  • LIFETIME = lifetime_default

  • REPID =

  • DYNNR =

  • NO_AUTODEF_PROGID_DYNNR =

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • CNTL_SYSTEM_ERROR = 2

  • CREATE_ERROR = 3

  • LIFETIME_ERROR = 4

  • LIFETIME_DYNPRO_DYNPRO_LINK = 5

  • others = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT grid1

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

i_parent = CONT1

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_NAME =

  • I_FCAT_COMPLETE = SPACE

  • EXCEPTIONS

  • ERROR_CNTL_CREATE = 1

  • ERROR_CNTL_INIT = 2

  • ERROR_CNTL_LINK = 3

  • ERROR_DP_CREATE = 4

  • others = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD grid1->set_table_for_first_display

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

IS_LAYOUT = LAYOUT

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

it_outtab = IT_ITAB1[]

IT_FIELDCATALOG = FCAT1

  • IT_SORT =

  • IT_FILTER =

  • EXCEPTIONS

  • INVALID_PARAMETER_COMBINATION = 1

  • PROGRAM_ERROR = 2

  • TOO_MANY_LINES = 3

  • others = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

endmodule. " SHOWALV OUTPUT

thanks and Regards .

Priyank dixit