cancel
Showing results for 
Search instead for 
Did you mean: 

ALV and colors

david_fryda2
Participant
0 Kudos

Hi everyone,

I want to colorize a specific cell for a certain condition.

I used the REUSE_ALV_GRID_DISPLAY function to create my ALV.

Lets say I want to turn red a cell that its value is negative.

How can I do it ?

Thanks in advance.

Regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi David,

Try the Demo program

BCALV_TEST_LIST_FIELDS

Also there are many demo programs available for ALV (list as well as Grids). Just Type BCALV* in se38 and press F4.

You will find a lot of Demo programs, which cover all the ALV Functionalities...

Hope it helps...

Lokesh

Pls. reward appropriate points

david_fryda2
Participant
0 Kudos

Hi everyone,

I do not want a tone of lines code that do not answer the problem.

Can someone here be more precise with my problem.

Thanks in advance.

PS : do not worry for the points.

Former Member
0 Kudos

Hi David,

ALV FM's doesnot support coloring the cells, instead if you can use classes you can acheive your requirement.

Hope This Info Helps YOU.

<i>Reward Points If It Helps YOU.</i>

Regards,

Raghav

suresh_datti
Active Contributor
0 Kudos

Hi David,

here is some info..


Colour code :                                                 
Colour is a 4-char field where :                                          
- 1st char = C (color property)                   
- 2nd char = color code (from 0 to 7)            
0 = background color         
1 = blue                     
2 = gray                     
3 = yellow                   
4 = blue/gray               
5 = green                     
6 = red                     
7 = orange                    
- 3rd char = intensified (0=off, 1=on)           
- 4th char = inverse display (0=off, 1=on)       
                                                               
Ex:
 CLEAR wa_fieldcat. 
  MOVE w_position TO wa_fieldcat-col_pos. 
  MOVE 'MATKL'    TO wa_fieldcat-fieldname. 
  MOVE 'MARA'     TO wa_fieldcat-ref_table. 
  MOVE 'MATKL'    TO wa_fieldcat-ref_field. 
* Color column 
  MOVE 'C610'     TO wa_fieldcat-emphasize. 
  APPEND wa_fieldcat TO it_fieldcat.                  

Regards,

Suresh Datti

Message was edited by: Suresh Datti

Former Member
0 Kudos

declare in ur internal table the following field

celcolor type slis_specialcol_alv.

declare another one

data: celcolor1 type slis_specialcol_alv.

in layout

wa_layout-coltab_fieldname = 'ITAB-CELCOLOR'.

if fld is negative.

celcolor1-fieldname = 'FLD'.

celcolor1-color = 'CXYZ'.

append celcolor1 to itab_alv1-celcolor.

X is color code,Y is intensify ,Z is inverse are

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

example on ALV with line color

http://www.geocities.com/mpioud/Z_ALV_LINE_COLOR.html

example on ALV with cell color

http://www.geocities.com/mpioud/Z_ALV_CELL_COLOR.html

regards,

Bhaskar.

david_fryda2
Participant
0 Kudos

Thanks to everyone, it finally works.

Regards.

former_member188685
Active Contributor
0 Kudos

hi

check this thread..

regards

vijay

david_fryda2
Participant
0 Kudos

Hi,

I am not using classes for my ALV.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program          = gd_repid
      i_callback_pf_status_set    = 'SET_PF_STATUS'
      i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'
      i_callback_user_command     = 'USER_COMMAND'
      it_fieldcat                 = fieldcatalog[]
      i_save                      = 'X'
    TABLES
      t_outtab                    = gt_report
    EXCEPTIONS
      program_error               = 1
      OTHERS                      = 2.

Thanks.

suresh_datti
Active Contributor
0 Kudos

David,

here is another sample report..


report zc9_alvgrid_final_now . 

*----------------------------------------------------------------------- 

*PROGRAM ON ALV-GRID. 

*----------------------------------------------------------------------- 

*----------------------------------------------------------------------- 

*TABLE DECLARATION. 

*----------------------------------------------------------------------- 

*tables:zc9_employee, zc9_empspec. 

type-pools: slis. "ALV Declarations 

data: celcol1 type slis_specialcol_alv. 

data: syprindex type i value 1. 

*----------------------------------------------------------------------- 

*INTERNAL TABLE DECLARATION. 

*----------------------------------------------------------------------- 

 

data: begin of itab_alv1 OCCURS 0, 

 emp_id(5) TYPE C, 

 emp_name(20) TYPE C, 

 certified(3) TYPE C, 

 celcol type slis_t_specialcol_alv, 

 selected(1) type c, 

 end of itab_alv1. 

 

data: begin of itab_alv3 OCCURS 0, 

 emp_id(5) TYPE C, 

 emp_name(20) TYPE C, 

 certified(3) TYPE C, 

 end of itab_alv3. 

 

data: mulrowtab1 like line of itab_alv1. 

data: mulrowtab like table of itab_alv1. 

data: wa_emp_name like zc9_employee-emp_name. 

 
data: mulrowindex type i value 1. 

data: maxlines type i. 

*----------------------------------------------------------------------- 

data: wa like line of itab_alv1. 

data: wa_itab like line of itab_alv1. 

data: ok-code like sy-ucomm. 

data: ok-code1 like sy-ucomm. 

data: ind type i. 

data: newvar type disvariant. 

data: tempvar type i value 0. 

data: gd_repid like sy-repid. 

*----------------------------------------------------------------------- 

*ALV-GRID DATA DECLARATION. 

*----------------------------------------------------------------------- 

data: fieldcatalog type slis_t_fieldcat_alv. 

* FIELD CATALOG. 

data: fieldcatalog1 type slis_fieldcat_alv. 

data: gd_layout type slis_layout_alv. 

* LAYOUT DECLARATION. 

data: id_color type c. 

data: eventtable type slis_t_event. 

data: wa_event type slis_alv_event. 

data: newvariant type disvariant. 

data: i_exclude type slis_t_extab, "ALV Exclusion Table 

 wa_exclude type slis_extab. "ALV Exclusion Structure 

 

*--------------------------------------------------------------------- 

*VARIANT DECLARATION. 

*--------------------------------------------------------------------- 

data: vartype like disvariant. 

data: var_save(1) type c. 

data: w_exit(1) type c. 

data: wx_variant like disvariant. 

data: variant_para like disvariant-variant. 

data: itab_emp like table of zc9_employee. 

data: itab_emp1 like line of itab_emp. 

data: itab_spec like table of zc9_empspec. 

data: itab_spec1 like line of itab_spec. 

data: ls_sort type slis_sortinfo_alv. 

data: lt_sort type slis_t_sortinfo_alv. 

parameter: LAYOUT like disvariant-variant. 

*----------------------------------------------------------------------- 

* INITIALIZATION. 

*----------------------------------------------------------------------- 

gd_repid = sy-repid. 

*----------------------------------------------------------------------- 

*CALLING SELECTION SCREEN-SUBROUTINES. 

*----------------------------------------------------------------------- 

*----------------------------------------------------------------------- 

*AT SELECTION SCREEN 

*---------------------------------------------------------------------- 

at selection-screen output. 

 perform init_variant. 

 perform variant_default using LAYOUT. 

 

at selection-screen on value-request for LAYOUT. 

 perform variant_select using LAYOUT. 

 

at selection-screen. 

 perform variant_fill. 

 newvar = vartype. 

*----------------------------------------------------------------------- 

 
* LAYOUT DECLARATION. 

*----------------------------------------------------------------------- 

 gd_layout-zebra = 'X'. 

 gd_layout-no_input = 'X'. 

 gd_layout-colwidth_optimize = 'X'. 

 gd_layout-box_fieldname = 'SELECTED'. 

 gd_layout-box_tabname = 'ITAB_ALV1'. 

 gd_layout-totals_text = 'Totals'(201). 

 gd_layout-coltab_fieldname = 'CELCOL'. 

 gd_layout-f2code = 'DISP'. "Sets fcode for when double 

* "click(press f2) 

 

 call function 'REUSE_ALV_FIELDCATALOG_MERGE' 

 exporting 

 i_program_name = gd_repid 

 i_internal_tabname = 'ITAB_ALV3' 

 i_inclname = gd_repid 

 changing 

 ct_fieldcat = fieldcatalog 

 . 

 

*----------------------------------------------------------------------- 

*FIELD-CATALOG DECLARATION. 

*----------------------------------------------------------------------- 

 loop at fieldcatalog into fieldcatalog1. 

 case fieldcatalog1-fieldname. 

 

 when 'EMP_ID'. 

 fieldcatalog1-seltext_m = 'EMP-ID'. 

 fieldcatalog1-col_pos = 0. 

 fieldcatalog1-outputlen = 10. 

 fieldcatalog1-emphasize = 'C2'. 

 fieldcatalog1-key = 'X'. 

 fieldcatalog1-do_sum = 'X'. 

 fieldcatalog1-sp_group = 'A'. 

 

 when 'EMP_NAME'. 

 fieldcatalog1-fieldname = 'EMP_NAME'. 

 fieldcatalog1-seltext_m = 'EMPLOYEE_NAME'. 

 fieldcatalog1-col_pos = 1. 

 fieldcatalog1-emphasize = 'C2'. 

 fieldcatalog1-hotspot = 'X'. 

 fieldcatalog1-key = 'X'. 

 fieldcatalog1-outputlen = 20. 

 fieldcatalog1-sp_group = 'B'. 

 

 when 'CERTIFIED'. 

 fieldcatalog1-fieldname = 'CERTIFIED'. 

 fieldcatalog1-seltext_m = 'CERTIFIED'. 

 fieldcatalog1-col_pos = 2. 

 fieldcatalog1-emphasize = 'C2'. 

 fieldcatalog1-key = 'X'. 

 fieldcatalog1-sp_group = 'C'. 

 endcase. 

 modify fieldcatalog from fieldcatalog1. 

 endloop. 

 

*----------------------------------------------------------------------- 

*SORTING FIELD CATALOG FIELD. 

*----------------------------------------------------------------------- 

ls_sort-spos = 1. 

ls_sort-fieldname = 'EMP_ID'. 

 
ls_sort-up = 'X'. 

ls_sort-subtot = 'X'. 

append ls_sort to lt_sort. 

 

*----------------------------------------------------------------------- 

*POPULATING THE INTERNAL TABLE. 

*----------------------------------------------------------------------- 

 

ITAB_ALV1-EMP_ID = '15530'. 

ITAB_ALV1-EMP_NAME = 'THILAKJI'. 

ITAB_ALV1-CERTIFIED = 'YES'. 

APPEND ITAB_ALV1. 

 

ITAB_ALV1-EMP_ID = '15531'. 

ITAB_ALV1-EMP_NAME = 'MATHEWS'. 

ITAB_ALV1-CERTIFIED = 'NO'. 

APPEND ITAB_ALV1. 

 

ITAB_ALV1-EMP_ID = '15532'. 

ITAB_ALV1-EMP_NAME = 'JAISI'. 

ITAB_ALV1-CERTIFIED = 'YES'. 

APPEND ITAB_ALV1. 

 

ITAB_ALV1-EMP_ID = '15533'. 

ITAB_ALV1-EMP_NAME = 'ADAMS'. 

ITAB_ALV1-CERTIFIED = 'YES'. 

APPEND ITAB_ALV1. 

 

ITAB_ALV1-EMP_ID = '15534'. 

ITAB_ALV1-EMP_NAME = 'PAUL'. 

ITAB_ALV1-CERTIFIED = 'NO'. 

APPEND ITAB_ALV1. 

 

************************************************************************ 

* FORM TO MAKE THE CELL CONTENTS INVISIBLE. 

 

 PERFORM INVISIBLE_CELL_CONTENTS. 

* 

************************************************************************ 

*----------------------------------------------------------------------- 

*EXCLUDE-DECLARATION. 

*----------------------------------------------------------------------- 

 clear wa_exclude. 

 wa_exclude-fcode = '&VEXCEL'. 

 append wa_exclude to i_exclude. 

 

*----------------------------------------------------------------------- 

* FUNCTION MODULE CALL-REUSE-ALV-GRID-DISPLAY. 

*----------------------------------------------------------------------- 

 call function 'REUSE_ALV_GRID_DISPLAY' 

 exporting 

 i_callback_program = gd_repid 

 i_callback_top_of_page = 'TOP-OF-PAGE2' "see FORM 

 i_callback_user_command = 'USER_COMMAND' 

 i_grid_title = 'ALV GRID-EMPLOYEE' 

 

 is_layout = gd_layout 

 it_fieldcat = fieldcatalog[] 

 it_sort = lt_sort 

 it_excluding = i_exclude 

 i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM 

 i_save = 'A' 

 
 is_variant = newvar 

 tables 

 t_outtab = itab_alv1 

 exceptions 

 program_error = 1 

 others = 2. 

 

*-------------------------------------------------------------------* 

* Form TOP-OF-PAGE * 

*-------------------------------------------------------------------* 

* ALV Report Header * 

*-------------------------------------------------------------------* 

form top-of-page2. 

 data: header type slis_t_listheader, 

 wa type slis_listheader, 

 infield like wa-info, 

 nline type i, 

 nlinechar(2) type c. 

 

*TITLE AREA 

 wa-typ = 'H'. 

 wa-info = 'EMPLOYEE-DETAILS'. 

 append wa to header. 

 

*BELOW AREA. 

 wa-typ = 'S'. 

 wa-key = 'DATE'. 

concatenate sy-datum+6(2) '.' sy-datum+4(2) '.' sy-datum(4) into wa-info 

 . 

 append wa to header. 

 

*NEXT LINE. 

 wa-typ = 'S'. 

 describe table itab_alv1 lines nline. 

 nlinechar = nline. 

 wa-key = 'TABLE DETAILS'. 

 concatenate 'NO.of.Lines:' nlinechar into wa-info separated by space. 

 append wa to header. 

 

 call function 'REUSE_ALV_COMMENTARY_WRITE' 

 exporting 

 it_list_commentary = header 

 i_logo = 'ALVLOGO'. 

 

endform. 

 

*------------------------------------------------------------------* 

* FORM SET_PF_STATUS * 

*------------------------------------------------------------------* 

form set_pf_status using rt_extab type slis_t_extab. 

 set pf-status 'NEWSTATUS123'. 

 

endform. 

 

*------------------------------------------------------------------* 

* FORM USER_COMMAND * 

*------------------------------------------------------------------* 

* --> R_UCOMM * 

* --> RS_SELFIELD * 

*------------------------------------------------------------------* 

form user_command using r_ucomm like sy-ucomm 

 rs_selfield type slis_selfield. 

 
 

* Check function code 

 case r_ucomm. 

 

 when 'SELM'. 

 loop at itab_alv1 where selected = 'X'. 

 move-corresponding itab_alv1 to mulrowtab1. 

 append mulrowtab1 to mulrowtab. 

 endloop. 

 message i029(zmc). 

 clear mulrowtab1. 

 

 when 'DISP'. 

* Check field clicked on within ALVgrid report 

 if rs_selfield-fieldname = 'EMP_ID'. 

* Read data table, using index of row user clicked on 

 read table itab_alv1 into wa index rs_selfield-tabindex. 

 ind = rs_selfield-tabindex. 

 message i025(zmc) with rs_selfield-fieldname . 

 

 elseif rs_selfield-fieldname = 'EMP_NAME'. 

 read table itab_alv1 into wa index rs_selfield-tabindex. 

 ind = rs_selfield-tabindex. 

 message i028(zmc) with rs_selfield-fieldname wa-emp_name . 

 endif. 

 

 when 'EXIT'. 

* MESSAGE I026(ZMC). 

 leave program. 

 

 when 'CHAN'. 

* READ TABLE itab_alv1 INTO wa INDEX rs_selfield-tabindex. 

 read table itab_alv1 into wa index rs_selfield-tabindex. 

 call screen 1551. 

 tempvar = 1. 

 

 

*------------------------------------------------------------ 

*CALLING THE GRID DISPLAY FUNCTION AGAIN. 

*------------------------------------------------------------ 

*----------------------------------------------------------------------- 

* FUNCTION MODULE CALL-REUSE-ALV-GRID-DISPLAY. 

*----------------------------------------------------------------------- 

 call function 'REUSE_ALV_GRID_DISPLAY' 

 exporting 

 i_callback_program = gd_repid 

 i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM 

 i_callback_user_command = 'USER_COMMAND' 

 i_grid_title = 'ALV GRID-EMPLOYEE' 

 is_layout = gd_layout 

 it_fieldcat = fieldcatalog[] 

 it_events = eventtable 

 i_save = 'X' 

 it_excluding = i_exclude 

 i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM 

 is_variant = newvar 

 tables 

 t_outtab = itab_alv1 

 exceptions 

 program_error = 1 

 others = 2. 

 

 
 r_ucomm = '&F03'. 

 when '&F03'. 

* IF TEMPVAR = 1. 

 leave program. 

 endcase. 

clear r_ucomm. 

endform. 

*&---------------------------------------------------------------------* 

*& Module USER_COMMAND_1551 INPUT 

*&---------------------------------------------------------------------* 

* text 

*----------------------------------------------------------------------* 

module user_command_1551 input. 

 

 data: syprtabix type i. 

 case ok-code. 

 when 'QUIT'. 

 set screen 0. 

 leave screen. 

 clear itab_alv1. 

 sy-tabix = 0. 

 

 when 'UPDA'. 

 loop at itab_alv1 where emp_id = wa-emp_id. 

 syprtabix = sy-tabix. 

 endloop. 

 

 modify itab_alv1 from wa index syprtabix transporting emp_id emp_name 

 certified. 

 

 message i027(zmc). 

 

 leave screen. 

 endcase. 

endmodule. " USER_COMMAND_1551 INPUT 

*&---------------------------------------------------------------------* 

*& Module STATUS_1551 OUTPUT 

*&---------------------------------------------------------------------* 

* text 

*----------------------------------------------------------------------* 

module status_1551 output. 

 set pf-status 'ZNEWSTATUS'. 

* SET TITLEBAR 'xxx'. 

 

endmodule. " STATUS_1551 OUTPUT 

 

 

*----------------------------------------------------------------------- 

*FORM FOR SELECTING LAYOUT. 

*----------------------------------------------------------------------- 

 

form variant_select using form_varpar. 

 

 call function 'LVC_VARIANT_F4' 

 exporting 

 is_variant = vartype 

* IT_DEFAULT_FIELDCAT = 

 i_save = var_save 

 importing 

 e_exit = w_exit 

 es_variant = wx_variant 

 exceptions 

 
 not_found = 1 

 program_error = 2 

 others = 3 

 . 

 if sy-subrc <> 0. 

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

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

 endif. 

 

 if w_exit is initial. 

 vartype-variant = wx_variant-variant. 

 form_varpar = wx_variant-variant. 

 endif. 

endform. 

 

*&---------------------------------------------------------------------* 

*& Form init_variant 

*&---------------------------------------------------------------------* 

form init_variant. 

 

 clear: vartype. 

 gd_repid = sy-repid. 

 vartype-report = sy-repid. 

 vartype-username = sy-uname. 

 var_save = 'A'. "All types 

 

endform. 

 

*&---------------------------------------------------------------------* 

*& Form variant_default 

*&---------------------------------------------------------------------* 

form variant_default using p_variant. 

 

 wx_variant = vartype. 

 

 if not p_variant is initial. 

 wx_variant-variant = p_variant. 

 endif. 

 

 call function 'LVC_VARIANT_DEFAULT_GET' 

 exporting 

 i_save = var_save 

 changing 

 cs_variant = wx_variant 

 exceptions 

 wrong_input = 1 

 not_found = 2 

 program_error = 3 

 others = 4. 

 

 case sy-subrc. 

 when 0. 

 p_variant = wx_variant-variant. 

 when 2. 

 clear: p_variant. 

 endcase. 

 

endform. 

 

*&---------------------------------------------------------------------* 

*& Form variant_fill 

*&---------------------------------------------------------------------* 

 
form variant_fill. 

 

 clear: vartype. 

 

 if LAYOUT is initial. 

 vartype-variant = 'STANDARD'. 

 vartype-report = sy-repid. 

 else. 

 

 vartype-variant = LAYOUT. 

 vartype-report = sy-repid. 

 

 call function 'LVC_VARIANT_EXISTENCE_CHECK' 

 exporting 

 i_save = var_save 

 changing 

 cs_variant = vartype 

 exceptions 

 others = 01. 

 if sy-subrc ne 0. 

 message i000(zz) with text-g02. 

 endif. 

 endif. 

endform. 

 

*&---------------------------------------------------------------------* 

*& Module STATUS_1234 OUTPUT 

*&---------------------------------------------------------------------* 

* text 

*----------------------------------------------------------------------* 

module status_1234 output. 

 

* SET PF-STATUS 'xxxxxxxx'. 

* SET TITLEBAR 'xxx'. 

 

endmodule. " STATUS_1234 OUTPUT 

*&---------------------------------------------------------------------* 

*& Module USER_COMMAND_1234 INPUT 

*&---------------------------------------------------------------------* 

* text 

*----------------------------------------------------------------------* 

module user_command_1234 input. 

 

sort mulrowtab. 

describe table mulrowtab lines maxlines. 

 

case ok-code1. 

when 'OUT1'. 

set screen 0. 

leave screen. 

 

when 'PUSH'. 

clear mulrowtab1. 

if mulrowindex <= maxlines. 

read table mulrowtab into mulrowtab1 index mulrowindex. 

mulrowindex = mulrowindex + 1. 

 

else. 

message i030(zmc). 

endif. 

endcase. 

endmodule. " USER_COMMAND_1234 INPUT 

 
 

*---------------------------------------------------------------------- 

* CEL COLOR TABLE POPULATION. 

*---------------------------------------------------------------------- 

FORM INVISIBLE_CELL_CONTENTS. 

 loop at itab_alv1 INTO WA. 

 IF WA-EMP_ID = ' '. 

 EXIT. 

 ENDIF. 

 clear itab_alv1. 

 move-corresponding WA to itab_alv1. 

 

 clear celcol1. 

 celcol1-fieldname = 'EMP_ID'. 

 celcol1-color-col = syprindex. 

 append celcol1 to itab_alv1-celcol. 

 

 celcol1-fieldname = 'EMP_NAME'. 

 celcol1-color-col = syprindex + 2. 

 append celcol1 to itab_alv1-celcol. 

 

************************************************************************ 

* CODE FOR MAKING THE GRID CELL CONTENTS INVISIBLE BASED ON THE VALUE OF 

*THE CELL.THE CONDITION CHECKED IS WHETHER 

* CERTIFIED FIELD HAS VALUE 'NO'. 

************************************************************************ 

 celcol1-fieldname = 'CERTIFIED'. 

 if itab_alv1-certified = 'NO'. 

 itab_alv1-emp_name = ' '. 

 endif. 

 celcol1-color-col = syprindex + 3. 

 append celcol1 to itab_alv1-celcol. 

 MODIFY ITAB_ALV1. 

 syprindex = celcol1-color-col - 1. 

 CLEAR ITAB_ALV1. 

 endloop. 

ENDFORM. 


Regards,

Suresh Datti

Former Member
0 Kudos

Hi David,

GUI dependent - COL_BACKGROUND

Gray blue - COL_HEADING

Light gray - COL_NORMAL

Yellow - COL_TOTAL

Blue green - COL_KEY

Green - COL_POSITIVE

Red - COL_NEGATIVE

Orange - COL_GROUP

Also check on to this link.This should solve ur problem.

http://help.sap.com/saphelp_erp2005/helpdata/en/34/e7eb40c4f8712ae10000000a155106/frameset.htm

Regards,

Nagarajan.

Former Member
0 Kudos

&----


*& Report ZCHA_ALV_GRID_CELL_COLOR *

*& *

&----


*& *

*& *

&----


REPORT ZCHA_ALV_GRID_CELL_COLOR .

TABLES:MARA.

DATA: W_CONTAINER TYPE SCRFNAME VALUE 'ALV_CONTAINER',

W_GRID TYPE REF TO CL_GUI_ALV_GRID,

W_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

  • W_EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.

*layout

DATA: WA_LAYOUT TYPE LVC_S_LAYO.

*field catalog

DATA: IT_FIELDCAT_WRT_OFF TYPE LVC_T_FCAT,

WA_FIELDCAT_WRT_OFF TYPE LVC_S_FCAT.

DATA:BEGIN OF IT_MARA OCCURS 0,

MATNR LIKE MARA-MATNR,

MAKTX LIKE MAKT-MAKTX,

CELLCOLORS TYPE LVC_T_SCOL,

END OF IT_MARA.

SELECT P~MATNR

Q~MAKTX

INTO CORRESPONDING FIELDS OF TABLE IT_MARA

FROM MARA AS P INNER JOIN

MAKT AS Q ON

PMATNR = QMATNR.

CALL SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'STATUS'.

  • SET TITLEBAR 'xxx'.

IF NOT W_CONTAINER IS INITIAL.

CREATE OBJECT W_CUSTOM_CONTAINER

EXPORTING CONTAINER_NAME = W_CONTAINER.

CREATE OBJECT W_GRID

EXPORTING I_PARENT = W_CUSTOM_CONTAINER.

ENDIF.

CLEAR IT_FIELDCAT_WRT_OFF.

REFRESH IT_FIELDCAT_WRT_OFF.

WA_FIELDCAT_WRT_OFF-FIELDNAME = 'MATNR'.

WA_FIELDCAT_WRT_OFF-COL_POS = '1'.

WA_FIELDCAT_WRT_OFF-OUTPUTLEN = '35'.

WA_FIELDCAT_WRT_OFF-SCRTEXT_L = 'Material No'.

APPEND WA_FIELDCAT_WRT_OFF TO IT_FIELDCAT_WRT_OFF.

CLEAR WA_FIELDCAT_WRT_OFF.

WA_FIELDCAT_WRT_OFF-FIELDNAME = 'MAKTX'.

WA_FIELDCAT_WRT_OFF-COL_POS = '2'.

WA_FIELDCAT_WRT_OFF-OUTPUTLEN = '45'.

WA_FIELDCAT_WRT_OFF-SCRTEXT_L = 'Material Desc'.

APPEND WA_FIELDCAT_WRT_OFF TO IT_FIELDCAT_WRT_OFF.

CLEAR WA_FIELDCAT_WRT_OFF.

DATA LS_CELLCOLOR TYPE LVC_S_SCOL.

READ TABLE IT_MARA INDEX 5 .

LS_CELLCOLOR-FNAME = 'MATNR'.

LS_CELLCOLOR-COLOR-COL = '3'.

LS_CELLCOLOR-COLOR-INT = '1'.

APPEND LS_CELLCOLOR TO IT_MARA-CELLCOLORS.

MODIFY IT_MARA INDEX 5.

WA_LAYOUT-CTAB_FNAME = 'CELLCOLORS'.

CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = WA_LAYOUT

CHANGING

IT_FIELDCATALOG = IT_FIELDCAT_WRT_OFF

IT_OUTTAB = IT_MARA[].

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT