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

ALV

Former Member
0 Likes
831

Hi,

I was displaying a report in ALV..It is showing all the employees of the company..

Niow they are asking that more than 2 yrs experience want to be displayed in different color,3+yrs different colors and so on..

I was into 4.6c

Can any body help me in this issue

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
780

hi,

when ur looping the internal table check for the select condition as experince and then use the row col, u can use the row col by declaring one more field in ur internal table of length 4 type c and then give an attribute to each row before appending to ur main internal table

Note : theres a sample demo report in r/3 which u can check also.

Regards,

Sumanjeet

7 REPLIES 7
Read only

Former Member
0 Likes
781

hi,

when ur looping the internal table check for the select condition as experince and then use the row col, u can use the row col by declaring one more field in ur internal table of length 4 type c and then give an attribute to each row before appending to ur main internal table

Note : theres a sample demo report in r/3 which u can check also.

Regards,

Sumanjeet

Read only

Former Member
0 Likes
780

Hi calculate from date of joining to system date( years of experience).

check exp. within the loop. pass diff color based on condition.

Edited by: venkat reddy on Jul 10, 2008 3:11 PM

Read only

franois_henrotte
Active Contributor
0 Likes
780

add a column in your internal table, let's say field name is COLOR

in your layout structure, put "COLOR" into INFO_FIELDNAME

for each record, check the condition and change the color value accordingly

color must be "Cxy" with x = 1,2,3,4,5,6,7,8,9 (colors according to SAP like for WRITE statement) and y=0 or 1 (intensified)

this will allow you to change (easily) color of complete row

the same can be done for individual cells, then put the field name into field coltab_fieldname of layout, and change the type of extra field in your internal table so that it is SLIS_T_SPECIALCOL_ALV

you can look at documentation of function module REUSE_ALV_GRID_DISPLAY in order to get more information

Read only

0 Likes
780

use one more field called ROWCOLOR of len char4,

and set its like c200 c400 according to experience and set layout structure field info_fname to 'ROWCOLOR'.

Read only

Former Member
0 Likes
780

Hello



REPORT  ZTEST                                 . 

TYPE-POOLS: SLIS. 

DATA: BEGIN OF ITAB OCCURS 0, 
       TEXT1(10), 
       TEXT2(10), 
       TEXT3(10), 
       COLORS TYPE LVC_T_SCOL, 
     END OF ITAB, 
     LIN LIKE LINE OF ITAB, 
     MCOL  TYPE LVC_S_SCOL, 
     REP LIKE SY-REPID, 
     LS_LAYOUT TYPE SLIS_LAYOUT_ALV, 
     LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE, 
     LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV. 

START-OF-SELECTION. 
  ITAB-TEXT1 = 'Red'. 
  ITAB-TEXT2 = 'Green'. 
  ITAB-TEXT3 = 'Yellow'. 
  DO 5 TIMES. 
     APPEND ITAB. 
  ENDDO. 

  LS_FIELDCAT-TABNAME = 'ITAB'. 
  LS_FIELDCAT-FIELDNAME = 'TEXT1'. 
  LS_FIELDCAT-OUTPUTLEN = 10. 
  LS_FIELDCAT-SELTEXT_L = 'Field1'. 
  APPEND LS_FIELDCAT TO LT_FIELDCAT. 

  LS_FIELDCAT-TABNAME = 'ITAB'. 
  LS_FIELDCAT-FIELDNAME = 'TEXT2'. 
  LS_FIELDCAT-OUTPUTLEN = 10. 
  LS_FIELDCAT-SELTEXT_L = 'Field2'. 
  APPEND LS_FIELDCAT TO LT_FIELDCAT. 

  LS_FIELDCAT-TABNAME = 'ITAB'. 
  LS_FIELDCAT-FIELDNAME = 'TEXT3'. 
  LS_FIELDCAT-OUTPUTLEN = 10. 
  LS_FIELDCAT-SELTEXT_L = 'Field3'. 
  APPEND LS_FIELDCAT TO LT_FIELDCAT. 



  LOOP AT ITAB INTO LIN. 
    MCOL-FNAME = 'TEXT1'. 
    MCOL-COLOR-COL = 6. 
    APPEND MCOL TO LIN-COLORS. 
    MCOL-FNAME = 'TEXT2'. 
    MCOL-COLOR-COL = 3. 
    APPEND MCOL TO LIN-COLORS. 
    MCOL-FNAME = 'TEXT3'. 
    MCOL-COLOR-COL = 5. 
    APPEND MCOL TO LIN-COLORS. 
    MODIFY ITAB FROM LIN. 
  ENDLOOP. 

  REP = SY-REPID. 
  LS_LAYOUT-COLTAB_FIELDNAME = 'COLORS'. 


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' 
    EXPORTING 
      I_CALLBACK_PROGRAM       = REP 
      IS_LAYOUT                = LS_LAYOUT 
      IT_FIELDCAT              = LT_FIELDCAT[] 
    TABLES 
      T_OUTTAB                 = ITAB.

Read only

Former Member
0 Likes
780

hi..

take itab n wa..

run loop like this...

LOOP AT lt_emp INTO lwa_emp.

CLEAR lwa_grid_emp.

MOVE-CORRESPONDING lwa_emp TO lwa_grid_emp.

IF lwa_emp-ename = 'RAJU' OR lwa_emp-ename = 'VINAY'.

lwa_grid_emp-rowcolor = 'C600'.

ENDIF.

  • ls_style-fieldname = 'ESAL'.

  • ls_style-style = cl_gui_alv_grid=>mc_style4_link.

  • APPEND ls_style TO lwa_grid_emp-styles.

ls_style-fieldname = 'EMPNO'.

ls_style-style = cl_gui_alv_grid=>mc_style4_link.

ls_style-style = cl_gui_alv_grid=>mc_style_button.

APPEND ls_style TO lwa_grid_emp-styles.

ls_style-fieldname = 'ENAME'.

ls_style-style = cl_gui_alv_grid=>mc_style_disabled.

APPEND ls_style TO lwa_grid_emp-styles.

APPEND lwa_grid_emp TO gt_emp.

ENDLOOP

Read only

Former Member
0 Likes
780

you are passing an final iternal table ( say itab )

to alv function module

i think your internal table may contain a field called experiance

based on which you need to give color coding

now add another field color(3) type c to your itab

now before passing your internal table to the reuse_alv_grid_display

loop at itab.

if itab-experiance gt 2 and lt 3 (put condition as per your requirement)

itab-color = 'C51'.

elseif itab-experiance = 3

itab-color = 'C61'.

.......

.........

........

endif.

MODIFY ITAB index sy-tabix.

endloop.

*in layout declerations give

wa_layout-info_fieldname = 'COLOR'(017).

and pass wa_layout also to alv function module

you will get colors

reward points if helpful

cheers

Edited by: tummala swapna on Jul 10, 2008 6:51 PM