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: 

Two colors in a cell ALV

0 Kudos

Hi All,

I want to produce a report in ALV , where I have to print two diff colors in a cell..

Eg: In a cell 128(38)

128( ) in black and 38 in red.

Thanks in advance.

Balamurugan.R

5 REPLIES 5

former_member188685
Active Contributor
0 Kudos

I Don't think it is possible with ALV, but you can try with Normal List if you want the same.

0 Kudos

Hi Vijay,

You are right we can do it with Normal List. Is it possible in ALV?.

Thanks,

Balamurugan.R

0 Kudos

It is possible with normal ALV(LIST function i.e REUSE_ALV_LIST_DISPLAY)

But you have to code a lot for this...

Other alv's it is not possible.

0 Kudos

Hi Vijay,

If it is possible in REUSE_ALV_LIST_DISPLAY, give me an examble.

My taks is to do with ALV.

Thanks,

Balamurugan.R

Former Member
0 Kudos

hi,

see the below example which may be useful.

types: begin of ty_vbak,

Vbeln type vbeln_va,

erdat type erdat,

ernam type ernam,

cellcolors type lvc_t_scol, " table type for cell coloring

cellstyles TYPE lvc_t_styl, " table type for Style Table for Cells

end of ty_vbak.

data: t_vbak type table of ty_vbak,

w_vbak type ty_vbak.

data: gt_fieldcat type lvc_t_fcat,

gs_fieldcat like line of gt_fieldcat,

gw_layout type lvc_s_layo.

Reference to Custom container

DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

G_CONTAINER TYPE SCRFNAME VALUE 'CC_ALV',

G_GRID TYPE REF TO CL_GUI_ALV_GRID,

&----


*& Module STATUS_0001 OUTPUT

&----


  • text

----


MODULE STATUS_0001 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING

  • PARENT =

CONTAINER_NAME = G_CONTAINER

  • 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 G_GRID

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

I_PARENT = G_CUSTOM_CONTAINER

  • 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.

perform populate_data.

perform fieldcat.

perform populate_layout.

perform display_output.

ENDMODULE. " STATUS_0001 OUTPUT

&----


*& Form populate_data

&----


  • populating the data

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_data .

data: color(1) type c.

DATA lw_cellcolor TYPE lvc_s_scol . "line type for cell coloring

select vbeln

erdat

ernam from vbak into CORRESPONDING FIELDS OF TABLE t_vbak up to 10 rows.

*coloring the particular cell.

*----


READ TABLE t_vbak INTO w_vbak INDEX 5 .

lw_cellcolor-fname = 'ERDAT' .

lw_cellcolor-color-col = '4' .

lw_cellcolor-color-int = '1' .

APPEND lw_cellcolor TO w_vbak-cellcolors .

modify t_vbak index 5 from w_vbak.

READ TABLE t_vbak INTO w_vbak INDEX 7.

lw_cellcolor-fname = 'ERNAM' .

lw_cellcolor-color-col = '7' .

lw_cellcolor-color-int = '1' .

APPEND lw_cellcolor TO w_vbak-cellcolors .

modify t_vbak index 7 from w_vbak.

*----


ENDFORM. " populate_data

&----


*& Form fieldcat

&----


  • populatin the fieldcat

----


  • --> p1 text

  • <-- p2 text

----


FORM fieldcat .

clear gs_fieldcat.

gs_fieldcat-fieldname = 'VBELN'.

gs_fieldcat-tabname = 'T_VBAk'.

gs_fieldcat-outputlen = '20'.

gs_fieldcat-SCRTEXT_M = 'DOCUMENT NUMBER'.

append gs_fieldcat to GT_fieldcat.

clear gs_fieldcat.

gs_fieldcat-fieldname = 'ERDAT'.

gs_fieldcat-tabname = 'T_VBAK'.

gs_fieldcat-outputlen = '20'.

gs_fieldcat-SCRTEXT_M = 'CREATED ON'.

append gs_fieldcat to GT_fieldcat.

clear gs_fieldcat.

gs_fieldcat-fieldname = 'ERNAM'.

gs_fieldcat-tabname = 'T_VBAK'.

gs_fieldcat-outputlen = '20'.

gs_fieldcat-SCRTEXT_M = 'CREATED BY'.

append gs_fieldcat to GT_fieldcat.

ENDFORM. " fieldcat

&----


*& Form display_output

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_output .

CALL METHOD G_GRID->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 = gw_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING = * IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

IT_OUTTAB = t_vbak

IT_FIELDCATALOG = GT_fieldcat

  • 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.

&----


*

*& Form populate_layout

&----


  • populating the layout

----


  • <--P_GW_LAYOUT internal table for the layput

----


FORM populate_layout." CHANGING P_GW_LAYOUT type lvc_s_layo.

  • gw_layout-zebra = 'X'.

gw_layout-ctab_fname = 'CELLCOLORS'. "cell coloring

*gw_layout-info_fname = 'ROW_COLOR'. "row coloring

gw_layout-stylefname = 'CELLSTYLES'. "styles

ENDFORM. " populate_layout

thanks and regards