Colors in ALV report - column wise

Hi,
I have a ALV report. I want color in my report like Column Wise.
ex.
Document No........Date.........Amount......Document No......Date........Amount........Document Nov........Date.............Amount....
2008000123...10.07.2009....2000.00......2008000133....10.07.2009....2000.00.....2008000143.......10.07.2009.......2000.00
2008000124...10.07.2009....2000.00......2008000134....10.07.2009....2000.00.....2008000144.......10.07.2009.......2000.00
2008000125...10.07.2009....2000.00......2008000135....10.07.2009....2000.00.....2008000145.......10.07.2009.......2000.00
Please see, there is 3 times Document No, Date and Amount. I want that there should come diff. colors for diff. document numbers.
It is possible or not. If yes, then how...
Thanks...

Hi,
go though this link....
i hope this will help u
TABLES:
SPFLI.
TYPE-POOLS:
SLIS.
PARAMETERS:
P_COL TYPE I ,
P_ROW TYPE I,
P_COLOR(4) TYPE C .
DATA:
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FS_FIELDCAT LIKE LINE OF T_FIELDCAT,
FS_LAYOUT TYPE SLIS_LAYOUT_ALV ,
W_COLOR(4) ,
W_ROW TYPE I,
W_FIELDNAME(20),
W_PROG TYPE SY-REPID.
DATA:
BEGIN OF T_SPFLI OCCURS 0,
COLOR(4),
CHECKBOX ,
CELL TYPE SLIS_T_SPECIALCOL_ALV,
CARRID TYPE SPFLI-CARRID,
CONNID TYPE SPFLI-CONNID,
CITYFROM TYPE SPFLI-CITYFROM,
CITYTO TYPE SPFLI-CITYTO,
DISTANCE TYPE SPFLI-DISTANCE,
END OF T_SPFLI.
DATA:
FS_CELL LIKE LINE OF T_SPFLI-CELL.
SELECT *
FROM SPFLI
INTO CORRESPONDING FIELDS OF TABLE T_SPFLI.
W_COLOR = P_COLOR.
T_SPFLI-COLOR = P_COLOR.
IF P_COL IS INITIAL AND P_ROW GT 0.
MODIFY T_SPFLI INDEX P_ROW TRANSPORTING COLOR.
ENDIF.
FS_FIELDCAT-FIELDNAME = 'CARRID'.
FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
FS_FIELDCAT-COL_POS = 1.
FS_FIELDCAT-KEY = 'X'.
FS_FIELDCAT-HOTSPOT = 'X'.
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT .
FS_FIELDCAT-FIELDNAME = 'CONNID'.
FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
FS_FIELDCAT-COL_POS = 2.
FS_FIELDCAT-KEY = 'X'.
FS_FIELDCAT-HOTSPOT = 'X'.
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT .
FS_FIELDCAT-FIELDNAME = 'DISTANCE'.
FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
FS_FIELDCAT-COL_POS = 3.
FS_FIELDCAT-KEY = ' '.
FS_FIELDCAT-EDIT = 'X'.
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'CITYFROM'.
FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
FS_FIELDCAT-COL_POS = 4.
FS_FIELDCAT-KEY = ' '.
APPEND FS_FIELDCAT TO T_FIELDCAT.
LOOP AT T_FIELDCAT INTO FS_FIELDCAT.
IF FS_FIELDCAT-COL_POS EQ P_COL.
FS_FIELDCAT-EMPHASIZE = P_COLOR.
W_FIELDNAME = FS_FIELDCAT-FIELDNAME.
IF P_ROW IS INITIAL AND P_COL GT 0.
MODIFY T_FIELDCAT FROM FS_FIELDCAT TRANSPORTING EMPHASIZE.
ENDIF.
ENDIF.
ENDLOOP.
FS_CELL-FIELDNAME = W_FIELDNAME .
FS_CELL-COLOR-COL = 6.
FS_CELL-NOKEYCOL = 'X'.
APPEND FS_CELL TO T_SPFLI-CELL.
IF P_ROW IS NOT INITIAL AND P_COL IS NOT INITIAL.
MODIFY T_SPFLI INDEX P_ROW TRANSPORTING CELL.
ENDIF.
FS_LAYOUT-INFO_FIELDNAME = 'COLOR'.
FS_LAYOUT-BOX_FIELDNAME = 'CHECKBOX'.
FS_LAYOUT-COLTAB_FIELDNAME = 'CELL'.
FS_LAYOUT-F2CODE = '&ETA'.
W_PROG = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
IS_LAYOUT = FS_LAYOUT
IT_FIELDCAT = T_FIELDCAT
TABLES
T_OUTTAB = T_SPFLI
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
NOTE
Column and Row are colored with a coded color u2018Cxyzu2019.
    Where C: Color (coding must begin with C)
                 X: Color Number
                 Y: Bold
                 Z: Inverse.
Thanks
Ashu

Similar Messages

  • Colors in ALV report

    Hi all,
    I want to give color in a particular column of my ALV List report.
    Can u help me.. and also the color will change regarding a condition of that field...
    Pls reply asap....

    use below code
    DATA: g_color_green TYPE slis_t_specialcol_alv.
    create a table of fieldnames to be coloured intensified green -
    PERFORM colour_cells TABLES g_color_green
    USING 21 31 5.
    |
    |
    set cells of this line to intensified green
    IF CONDITION.....
    out-color[] = g_color_green[].
    ENDIF.
    FORM E05_LAYOUT_BUILD *
    ALV Layout options *
    <-> E05_LS_LAYOUT *
    FORM e05_layout_build USING e05_ls_layout TYPE slis_layout_alv.
    Setting this flag avoids having to define field sizes.
    e05_ls_layout-colwidth_optimize = 'X'.
    FIELD COLOR contains table of FIELDNAME and COLOURS.
    e05_ls_layout-coltab_fieldname = 'COLOR'.
    ENDFORM.
    *& Form colour_cells
    Set up table to color field groups different from default colour
    <--> t_color table of fields and colours
    <-- p_index_from - first field of catalogue to be coloured
    <-- p_index_to - last field of catalogue to be coloured
    <-- p_color - color number
    FORM colour_cells TABLES t_color
    USING p_index_from TYPE sy-index
    p_index_to TYPE sy-index
    p_color TYPE i.
    DATA: ls_fieldcat TYPE slis_fieldcat_alv,
    w_tab TYPE slis_specialcol_alv.
    use field catalogue to build new table for consecutive fields
    LOOP AT gt_fieldcat INTO ls_fieldcat FROM p_index_from TO p_index_to.
    w_tab-fieldname = ls_fieldcat-fieldname.
    w_tab-color-col = p_color.
    IF p_color = 5. "green
    w_tab-color-int = 1. "intensified on
    ELSE.
    w_tab-color-int = 0. "intensified off
    ENDIF.
    APPEND w_tab TO t_color.
    ENDLOOP.
    ENDFORM. " colour_cells
    rgds
    rajesh

  • Coloring an alv report lines

    hi
    i am creating my alv report using method cl_salv_table =>factory.
    i want to color the report lines in red
    how can i do that??
    i only found how to color a column
    thanks

    Hi,
    Check the below code:
    TYPE-POOLS: icon, col.
    type for internal table
    TYPES: BEGIN OF t_marc.
            INCLUDE STRUCTURE marc.
    internal table for cell color information
    TYPES : it_colors TYPE lvc_t_scol,
    END OF t_marc.
    DATA: it_marc TYPE TABLE OF t_marc.
    DATA: wa_marc LIKE LINE OF it_marc.
    DATA: wa_colors LIKE LINE OF wa_marc-it_colors.
    DATA: gr_alv TYPE REF TO cl_salv_table.
    DATA: lr_columns TYPE REF TO cl_salv_columns_table.
    SELECT-OPTIONS: s_mat FOR wa_marc-matnr MEMORY ID car.
    START-OF-SELECTION.
    retrieve data into internal table
      SELECT * FROM marc
        INTO CORRESPONDING FIELDS OF TABLE it_marc
      WHERE matnr IN s_mat.
      LOOP AT it_marc INTO wa_marc.
        IF wa_marc-werks = '1000'.
          CLEAR wa_colors.
          wa_colors-fname = 'WERKS'.
          wa_colors-color-col = col_negative.
          wa_colors-color-int = 1.
          APPEND wa_colors TO wa_marc-it_colors.
        ENDIF.
        MODIFY it_marc FROM wa_marc TRANSPORTING it_colors.
      ENDLOOP.
      CALL METHOD cl_salv_table=>factory
      EXPORTING
      list_display = if_salv_c_bool_sap=>false
      IMPORTING
      r_salv_table = gr_alv
      CHANGING
      t_table = it_marc.
      lr_columns = gr_alv->get_columns( ).
      lr_columns->set_color_column( value = 'IT_COLORS' ).
    display ALV
    gr_alv->display( ).
    (OR)
    check this link
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    Regards,
    Shalini
    Edited by: shalini reddy on Mar 10, 2009 4:13 PM

  • Problem with ALV Report Column

    Hi
    I have ALV report that got tons of columns and most of them are showing correctly. But there are two or three where i have a do sum checked got a small problem. The HEADING of the columns says NUMBER instead of its column name...
    Look at my code:
      ls_fieldcat-fieldname      =      'ETIME'.
      ls_fieldcat-ref_tabname    =      'REC'.
      ls_fieldcat-ref_fieldname  =      'ETIME'.
      ls_fieldcat-seltext_s      =      'ET      '.
      ls_fieldcat-seltext_m      =      'Et Tm           '.
      ls_fieldcat-seltext_l      =   'End Time             '.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-fieldname      =                'HOURS'.
      ls_fieldcat-ref_tabname    =                'PC2BF'.
      ls_fieldcat-ref_fieldname  =                'ANZHL'.
      ls_fieldcat-seltext_s      =                'Hrs    '.
      ls_fieldcat-seltext_m      =                'Hors '.
      ls_fieldcat-seltext_l      =                'Hours'.
      ls_fieldcat-decimals_out = 2.
      ls_fieldcat-no_zero = 'X'.
      ls_fieldcat-datatype = 'DEC'.
      ls_fieldcat-do_sum = 'X'.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-no_zero = ''.
      ls_fieldcat-datatype = ''.
      ls_fieldcat-outputlen = ''.
      ls_fieldcat-do_sum = ''.
      ls_fieldcat-decimals_out = ''.
      ls_fieldcat-fieldname = ''.
      ls_fieldcat-fieldname      =                'PNUMB'.
      ls_fieldcat-ref_tabname    =                'PC20E'.
      ls_fieldcat-ref_fieldname  =                'PRAKN'.
      ls_fieldcat-seltext_s      =                'P#     '.
      ls_fieldcat-seltext_m      =     'Pre #       '.
      ls_fieldcat-seltext_l      =   'Premium #           '.
      ls_fieldcat-datatype       =                'NUMC'.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-datatype       = ''.
    The column with Hours is showing NUMBER with the total sum but the column before and after that shows correctly.
    I have tried taken out the
    <b> ls_fieldcat-do_sum = 'X'.</b>
    Then its shows correctly but i need it to do the sum.
    Is there anything i need to do in order to show the columns correctly?
    Please help. <b><REMOVED BY MODERATOR></b>. thanks
    Message was edited by:
            Anwarul Kabir
    Message was edited by:
            Anwarul Kabir
    Message was edited by:
            Alvaro Tejada Galindo

    here is the whole program. you can upload this run it for your self if that helps in any way...
    *& Report  ZHEADCOUNT       *
    REPORT  ZHEADCOUNT no standard page
    heading message-id zw line-size 255.
    *       Dictionary tables/structures
    tables: teven,
            ZSHIFTS,
            ZHEADCT.
    * Global ALV Data Declarations
    type-pools slis.
    include: rpcxB200, RPTBAL01.
    DATA: BEGIN OF REC OCCURS 0,
      PERNR LIKE TEVEN-PERNR,
      LDATE LIKE TEVEN-LDATE,
      LTIME LIKE TEVEN-LTIME,
      SATZA LIKE TEVEN-SATZA,
      TERID LIKE TEVEN-TERID,
      PLANS LIKE TEVEN-PLANS.
    DATA: END OF REC.
    data:
      begin of x_sortinfo_alv occurs 0,
          spos                  like alvdynp-sortpos,
          fieldname             type slis_fieldname,
          tabname               type slis_fieldname,
          up                    like alvdynp-sortup,
          down                  like alvdynp-sortdown,
          group                 like alvdynp-grouplevel,
          subtot                like alvdynp-subtotals,
          comp(1)               type c,
          expa(1)               type c,
          obligatory(1)         type c,
        end   of x_sortinfo_alv,
        d                like scal-indicator,  
        v_variant        like disvariant,
        v_repid          like sy-repid,
        v_save(1)        type c,
        lv_sortseq       type i,
        s_title(20),    
        fieldcat         type slis_t_fieldcat_alv,
        ls_line          type slis_listheader,
        gd_layout        type slis_layout_alv,
        gt_sp_group      type slis_t_sp_group_alv,
        gt_sort          type slis_t_sortinfo_alv,
        ls_sort          type slis_sortinfo_alv,
        events           type slis_t_event,
        list_top_of_page type slis_t_listheader,
        top_of_page      type slis_formname value 'TOP_OF_PAGE',
        v_exit(1)        type c,
        v_pdsnr like assob-pdsnr,
        ls_fieldcat type slis_t_fieldcat_alv.
    constants:
      alv_slis_formname       type slis_formname value 'ALV_USER_COMMAND',
      c_yes                   like space value 'X',
      c_no                    like space value space,
      c_dev LIKE  sy-sysid VALUE 'DEV',
      c_device(4) TYPE c   VALUE 'LOCL'.
    * define selection screen
    selection-screen begin of block elmo with frame title text-001.
    selection-screen begin of line.
    selection-screen comment 1(30) text-002.
    select-options  p_terid for TEVEN-TERID.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(30) text-003.
    select-options p_shift for ZSHIFTS-DWS.
    selection-screen end of line.
    selection-screen end of block elmo.
    selection-screen begin of block blk2 with frame title text-004.
    PARAMETERS: p_vari like disvariant-variant.
    selection-screen end   of block blk2.
    *  Form  Initialization
    initialization.
      v_repid = sy-repid.
      v_save = 'A'.
      clear v_variant.
      v_variant-report = v_repid.
    * Get default variant
      alv_variant = v_variant.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = v_save
        CHANGING
          cs_variant = alv_variant
        EXCEPTIONS
          not_found  = 2.
      if sy-subrc = 0.
        p_vari = alv_variant-variant.
      endif.
    *  At Selection-Screen event (value help)
    at selection-screen on value-request for p_vari.
      perform f4_for_variant.
    *  At Selection-Screen event (check input data)
    at selection-screen on p_vari.
      if p_vari <> space.
        v_variant-report  = v_repid.
        v_variant-variant = p_vari.
        call function 'REUSE_ALV_VARIANT_SELECT'
          EXPORTING
            i_dialog            = c_no
            it_default_fieldcat = field_tab[]
            i_layout            = gs_layout
          CHANGING
            cs_variant          = v_variant.
        if sy-subrc <> 0.
          call function 'REUSE_ALV_VARIANT_SELECT'
            EXPORTING
              i_dialog            = c_yes
              it_default_fieldcat = field_tab[]
              i_layout            = gs_layout
            CHANGING
              cs_variant          = v_variant.
        endif.
      endif.
    *                       main logic
    TOP-OF-PAGE.
    START-OF-SELECTION.
    GET PERNR.
      RP-PROVIDE-FROM-LAST P0001 SPACE PNPBEGDA PNPENDDA.
    * process the data according to the payroll area
      IF PERNR-WERKS EQ P0001-WERKS AND PERNR-BTRTL EQ P0001-BTRTL
         AND PERNR-KOSTL EQ P0001-KOSTL AND PERNR-BUKRS EQ P0001-BUKRS
         AND PERNR-ABKRS EQ P0001-ABKRS AND PERNR-KOKRS EQ P0001-KOKRS.
        PERFORM RETRIEVE_Time.
      ENDIF.
    END-OF-SELECTION.
      Perform call_alv.
    *==================================*
    *=================================*
    FORM RETRIEVE_Time.
    Clear: REC.
           Select * from teven where PERNR EQ PERNR-PERNR
                                 AND TERID IN p_terid
                                 AND LDATE >= PNPBEGDA
                                 AND LDATE <= PNPENDDA.
                MOVE:
                     TEVEN-PERNR TO REC-PERNR,
                     TEVEN-LDATE TO REC-LDATE,
                     TEVEN-LTIME TO REC-LTIME,
                     TEVEN-SATZA TO REC-SATZA,
                     TEVEN-TERID TO REC-TERID,
                     TEVEN-PLANS TO REC-PLANS.
                APPEND REC.
           endselect.
    ENDFORM.                            " RETRIEVE_PAYROLL
    *  CALL_ALV
    form call_alv.
      perform build_field_catalog using field_tab[].
      perform build_eventtab      using events[].
      perform comment_build       using header_alv[].
      perform build_sorttab       using gt_sort[].
      perform build_layout.
    * Call ABAP List Viewer
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = v_repid
          i_callback_user_command = 'ALV_USER_COMMAND'
          i_structure_name        = 'REC'
          it_fieldcat             = field_tab
          it_special_groups       = gt_sp_group
          it_sort                 = gt_sort
          i_save                  = v_save
          is_variant              = v_variant
          it_events               = events
          is_layout               = gd_layout
        tables
          t_outtab                 = REC
        exceptions
          program_error            = 1
          others                   = 2.
    endform.                    "call_alv
    * BUILD_FIELD_CATALOG
    form build_field_catalog USING pt_fieldcat type
                                   slis_t_fieldcat_alv.
    *  data:  ls_fieldcat type slis_fieldcat_alv.
      clear: fieldcat, pt_fieldcat[].
      data : l_tabname type slis_tabname. " Table Name
       l_tabname = 'REC'.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
        exporting
          i_program_name = v_repid
          i_internal_tabname = l_tabname
          i_inclname = v_repid
        changing
          ct_fieldcat = ls_fieldcat
        exceptions
          inconsistent_interface = 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.
      else.
    *    append ls_fieldcat to pt_fieldcat.
      endif.
    endform.                    "build_field_catalog
    * BUILD_EVENTTAB
    form build_eventtab using events type slis_t_event.
    * Registration of events to happen during list display
      data: tmp_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = events.
      read table events with key name = slis_ev_top_of_page into tmp_event.
      if sy-subrc = 0.
        move top_of_page to tmp_event-form.
        append tmp_event to events.
      endif.
    endform.                    "build_eventtab
    * COMMENT_BUILD
    form comment_build using pt_top_of_page type slis_t_listheader.
      data: v_head_string(255) value space, d1(2), m1(2), y1(2), d2(2), m2(2), y2(2).
      clear: ls_line, pt_top_of_page.
      ls_line-typ  = 'H'.
      data pnpfrom(10).
      data pnpto(10).
      data: print_date(10).
      data: print_time(10).
      d1 = PNPBEGDA+6(2).          d2 = PNPENDDA+6(2).
      m1 = PNPBEGDA+4(2).          m2 = PNPENDDA+4(2).
      y1 = PNPBEGDA+2(2).          y2 = PNPENDDA+2(2).
      concatenate m1 '/' d1 '/' y1 into pnpfrom.
      concatenate m2 '/' d2 '/' y2 into pnpto.
      ls_line-info = sy-repid.
      append ls_line to pt_top_of_page.
      concatenate 'Printed by:' sy-uname 'on' print_date 'at' print_time
      into ls_line-info separated by space.
      append ls_line to pt_top_of_page.
      ls_line-info = 'BGM INDUSTRIES, INC.'.
      append ls_line to pt_top_of_page.
      concatenate 'Period:' pnpfrom 'to' pnpto
      into ls_line-info separated by space.
      append ls_line to pt_top_of_page.
    endform.                    "comment_build
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
    *  gd_layout-totals_text       = 'Totals'(255).
    *  gd_layout-info_fieldname    = 'LINE_COLOR'.
    endform.                    " BUILD_LAYOUT
    * TOP_OF_PAGE
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'Z_BGLOGO'
          it_list_commentary = header_alv.
    endform.                    "top_of_page
    *&      Form  build_sorttab
    *       Set up the sorting for the report.
    form build_sorttab using pt_sort type slis_t_sortinfo_alv.
      clear lv_sortseq.
      perform build_sort tables pt_sort changing ls_sort.
      ls_sort-fieldname = 'PERNR'.
      ls_sort-subtot    = 'X'.
    endform.                    " build_sorttab
    *  Use to add another sort field.
    form build_sort
      tables   pt_sort
      changing ls_sort structure x_sortinfo_alv.
      clear ls_sort.
      add 1 to lv_sortseq.
      ls_sort-spos = lv_sortseq.
      ls_sort-up = 'X'.
      ls_sort-tabname = 'REC'.
    endform.                    "build_sort
    *&      Form  f4_for_variant
    form f4_for_variant.
      call function 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = v_variant
          i_save     = v_save
        IMPORTING
          e_exit     = v_exit
          es_variant = alv_variant
        EXCEPTIONS
          not_found  = 2.
      if sy-subrc = 2.
        message id sy-msgid type 'S' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
        if v_exit = space.
          p_vari = alv_variant-variant.
        endif.
      endif.
    endform.
    Message was edited by:
            Anwarul Kabir

  • How to display the alv report blocks wise with out using the blocked alv

    Hi
    How to display the alv report with out using the blocked alv function module.
    Thanks
    Chinnu

    see this Standard Program
    RPR_ABAP_SOURCE_SCAN

  • Fill colors to ALV cells

    Hi All,
    How can I display multiple colors to different cells in an ALV ?.
    Please help..
    Thanks in advance,
    sudeep v d..

    Hi Sudeep,
    In the below mentioned link a topic Color of ALV output, columns, and cells has been mentioned in the section '4.17.3 Appearance of ALV Output'.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/db22242d-0701-0010-28a2-aeaa1fefd706
    Best regards,
    Suresh

  • ALV Report coloring columns

    In my ALV report I am displaying SO & DN as separate columns. I want to give them each a different color.
    In my BUILF_FIELDCATALOG, I tried the following but that gives them the same color i.e. blue. I would like to give them different colors. Also it puts them side by side even though when I comment the code out for the delivery, it goes back to the correct column.
         WHEN 'VBELN_VA'.
            wa_fieldcatalog-seltext_l = 'Order No.'.
            wa_fieldcatalog-reptext_ddic = 'Order No.'.
            wa_fieldcatalog-emphasize = 'X'.
            wa_fieldcatalog-key = 'X'.
            MOVE: wa_fieldcatalog-seltext_l TO wa_fieldcatalog-seltext_m,
                  wa_fieldcatalog-seltext_l TO wa_fieldcatalog-seltext_s.
            ADD 1 TO wa_fieldcatalog-col_pos.
          WHEN 'VBELN_VL'.
            wa_fieldcatalog-seltext_l = 'Delivery'.
            wa_fieldcatalog-reptext_ddic = 'Delivery'.
    *        wa_fieldcatalog-emphasize = 'X'.
    *        wa_fieldcatalog-key = 'X'.
            MOVE: wa_fieldcatalog-seltext_l TO wa_fieldcatalog-seltext_m,
                  wa_fieldcatalog-seltext_l TO wa_fieldcatalog-seltext_s.
            ADD 1 TO wa_fieldcatalog-col_pos.

    Use the following Form to color the cells after building the field catalog ....
    [code]
    *&      Form  SET_CELL_COLORS
          text
    FORM SET_CELL_COLORS.
    LOOP AT ITAB.
       L_INDEX = SY-TABIX.
       IF ITAB-VGBEL = 'DELETED'.
         LS_CELLCOLOR-FNAME = 'VGBEL'.
         LS_CELLCOLOR-COLOR-COL = '6'.
         LS_CELLCOLOR-COLOR-INT = '1'.
         LS_CELLCOLOR-COLOR-INV = '1'.
         APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
         MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
       ENDIF.
       IF ITAB-FACT = 'XXXXXX'.
         LS_CELLCOLOR-FNAME = 'FACT'.
         LS_CELLCOLOR-COLOR-COL = '3'.
         LS_CELLCOLOR-COLOR-INT = '1'.
         LS_CELLCOLOR-COLOR-INV = '1'.
         APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
         MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
       ENDIF.
         LS_CELLCOLOR-FNAME = 'CL_QUANT'.
         LS_CELLCOLOR-COLOR-COL = '6'.
         LS_CELLCOLOR-COLOR-INT = '0'.
         LS_CELLCOLOR-COLOR-INV = '1'.
         APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
         MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
    ENDLOOP.
    ENDFORM. " SET_CELL_COLORS
    /code]

  • How to color row in ALV report?

    hi
    I am creating an ALV report using factory method.
    my report is based on itab which contain 3 coulms, 1 column is ERROR_TYPE . how can i color all the rows which contain E in error_type ???
    thanks
    Ami

    TABLES:LFA1.
    SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    REGIO LIKE LFA1-REGIO,
    SORTL LIKE LFA1-SORTL,
    CFIELD(4) TYPE C,
    END OF ITAB.
    data:col(4).
    data:num value '1'.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
    IN LIFNR.
    LOOP AT ITAB.
    concatenate 'C' num '10' into col .
    ITAB-CFIELD = col.
    num = num + 1.
    if num = '8'.
    num = '1'.
    endif.
    MODIFY ITAB.
    ENDLOOP.
    TYPE-POOLS:SLIS.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    LAYOUT-WINDOW_TITLEBAR = 'VENDORS DETAILS SCREEN'.
    LAYOUT-EDIT = 'X'.
    LAYOUT-info_fieldname = 'CFIELD'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = FCAT.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    this is for coloring cols
    REPORT ZBHCOLOR_COLS.
    TABLES:LFA1.
    SELECT-OPTIONS:C_LIFNR FOR LFA1-LIFNR. " FOR GRID ONLY
    PARAMETERS:LIST RADIOBUTTON GROUP ALV DEFAULT 'X',
    GRID RADIOBUTTON GROUP ALV.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    SORTL LIKE LFA1-SORTL,
    REGIO LIKE LFA1-REGIO,
    COL TYPE LVC_T_SCOL,
    END OF ITAB.
    DATA:COLR TYPE LVC_S_SCOL.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB.
    LOOP AT ITAB.
    IF ITAB-LIFNR IN C_LIFNR.
    COLR-FNAME = 'NAME1'.
    COLR-COLOR-COL = '5'.
    COLR-COLOR-INT = '1'.
    COLR-COLOR-INV = '0'.
    COLR-NOKEYCOL = 'X'.
    APPEND COLR TO ITAB-COL.
    COLR-FNAME = 'LIFNR'.
    APPEND COLR TO ITAB-COL.
    MODIFY ITAB.
    ENDIF.
    ENDLOOP.
    TYPE-POOLS:SLIS.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
    LAYOUT-ZEBRA = 'X'.
    layout-coltab_fieldname = 'COL'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = FCAT.
    IF LIST = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    ELSEIF GRID = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    ENDIF.
    Reward points if useful.

  • Color a row in ALV report

    Hi Freinds,
    I want to color a particular row based on the condition in ALV report can any one tell me how to do it.
    Thanx and advance,
    Line

    Hi,
    REPORT  zrnp_alv_so  MESSAGE-ID z7new .
    TABLE DECLARATION
    TABLES: vbak ,             "Sales Document: Header Data
            vbap ,             "Sales Document: Item Data
            makt ,             "Material Descriptions
            lips .             "SD document: Delivery: Item data
    DECLARATION OF TYPE-POOL
    *THIS TYPE-POOL CONTAINS THE EVENTS,
    TYPE-POOLS : slis.
    DECLARATION OF EVENTS
    DATA: i_event TYPE slis_t_event.
    DATA: t_event TYPE slis_alv_event.
    DECLARATION OF LIST HEADER
    DATA: i_listheader TYPE slis_t_listheader.
    DECLARATION OF FIELD CATALOG FOR SCREEN 1
    DATA: i_fldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    DECLARATION OF FIELD CATALOG FOR SCREEN 2
    DATA: i_fldcat2 TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    DECLARATION OF FIELD LAYOUT
    DATA: i_layout TYPE slis_layout_alv.
    SORTING OF OUTPUT
    DATA: i_sort TYPE slis_t_sortinfo_alv.
    *DATA DECLARATION
    DATA: v_auart TYPE tvak-auart,
          v_vkorg TYPE tvko-vkorg,
          v_kunnr TYPE kna1-kunnr,
          v_matnr TYPE mara-matnr ,
          v_spart TYPE tvta-spart .
    TYPES: BEGIN OF it_so ,
           vbeln TYPE vbeln_va ,          "SALES ORDER NO.
           auart TYPE auart ,             "SALES DOC. TYPE
           vkorg TYPE vkorg ,             "SALES ORG.
           spart TYPE spart ,             "DIVISION
           kunnr TYPE kunag ,             "SOLD TO PARTY
           posnr TYPE posnr_va ,          "SALES DOC. ITEM
           matnr TYPE matnr ,             "MATERIAL NO
           maktx TYPE maktx ,             "DESCRIPTION
           kwmeng TYPE kwmeng ,           "QUANTITY
           vrkme TYPE vrkme ,             "SALES UNIT
           line_color(4) TYPE c ,
           END OF it_so .
    TYPES: BEGIN OF it_del ,
           vbeln TYPE vbeln_vl ,         "SALES ORDER NO.
           posnr TYPE posnr_vl ,         "SALES DOC. ITEM
           matnr TYPE matnr ,            "MATERIAL NO
           werks TYPE werks_d ,          "PLANT
           lgort TYPE lgort_d ,          "STORAGE LOCATION
           charg TYPE charg_d ,          "BATCH NO.
           lfimg TYPE lfimg ,            "ACTUAL DELIVERY QTY.
           vrkme TYPE vrkme ,            "SALES UNIT
           END OF it_del .
    TYPES: BEGIN OF type_vbfa ,
          vbelv TYPE vbeln_von , "Preceding sales and distribution document
          posnv TYPE posnr_von , "Preceding item of an SD document
          vbeln TYPE vbeln_nach, "Subsequent sales and distribution document
          posnn TYPE posnr_nach, "Document category of subsequent document
          vbtyp_n TYPE vbtyp_n ,
          END OF type_vbfa .
    DATA: it_so1 TYPE STANDARD TABLE OF it_so ,
          it_del1 TYPE STANDARD TABLE OF it_del ,
          it_vbfa TYPE STANDARD TABLE OF type_vbfa,
          it_del_ful TYPE STANDARD TABLE OF it_del.
    DATA: wa_so TYPE it_so ,
          wa_del TYPE it_del ,
          wa_vbfa TYPE type_vbfa,
          wa_it_del_ful TYPE it_del.
    DATA:  i_title_vbfa TYPE lvc_title VALUE 'SALES ORDER LIST DISPLAYED'.
    DATA:  i_title_vbpa TYPE lvc_title VALUE
    'DELIVERY DETAILS DISPLAYED AGAINST GIVEN SALES ORDER'.
    *SELECTION SCREEN                                                      *
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-004 .
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln ,
                    s_auart FOR v_auart ,
                    s_vkorg FOR v_vkorg ,
                    s_spart FOR v_spart ,
                    s_kunnr FOR v_kunnr ,
                    s_matnr FOR v_matnr .
    SELECTION-SCREEN END OF BLOCK blk1 .
    *AT SELECTION SCREEN                                                   *
    AT SELECTION-SCREEN.
      SELECT SINGLE vbeln
                     FROM vbak INTO vbak-vbeln
                     WHERE vbeln IN s_vbeln.
      IF sy-subrc <> 0.
        MESSAGE e202.
      ENDIF.
    *START OF SELECTION                                                    *
    START-OF-SELECTION .
      PERFORM data_select.
      PERFORM t_sort USING i_sort .
      PERFORM event_cat USING i_event .
      PERFORM fld_cat USING i_fldcat[] .
      PERFORM t_layout USING i_layout .
      PERFORM fld_cat2 USING i_fldcat2[] .
      PERFORM call_alv.
    DATA SELECT                                                          *
    *&      Form  DATA_SELECT
          text
    -->  p1        text
    <--  p2        text
    FORM data_select .
      REFRESH: it_vbfa, it_so1, it_del_ful ,it_del1 .
      BREAK-POINT.
      SELECT
            a~vbeln
            a~auart
            a~vkorg
            a~spart
            a~kunnr
            b~posnr
            b~matnr
            c~maktx
            b~kwmeng
            b~vrkme
            INTO TABLE it_so1 FROM vbak AS a
                  JOIN vbap AS b ON bvbeln = avbeln
                  JOIN makt AS c ON cmatnr = bmatnr
                  AND c~spras = sy-langu
                  WHERE a~vbeln IN s_vbeln .
    COLURING DISPLAY                                                     *
      DATA: ld_color(1) TYPE  c .
      LOOP AT it_so1 INTO wa_so.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
              i.e. wa_ekko-line_color = 'C410'
        ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
        IF ld_color = 8.
          ld_color = 1.
        ENDIF.
        CONCATENATE 'C' ld_color '10' INTO wa_so-line_color.
    wa_ekko-line_color = 'C410'.
        MODIFY it_so1 FROM wa_so.
      ENDLOOP .
      IF sy-subrc = 0.
        SELECT vbelv
               posnv
               vbeln
               posnn
               vbtyp_n
               INTO TABLE it_vbfa
               FROM vbfa
               FOR ALL ENTRIES IN it_so1
               WHERE vbelv = it_so1-vbeln
               AND   posnn = it_so1-posnr
               AND vbtyp_n ='J' .
        IF sy-subrc = 0.
          SELECT vbeln
                 posnr
                 matnr
                 werks
                 lgort
                 charg
                 lfimg
                 vrkme
                 FROM lips INTO TABLE it_del_ful
                 FOR ALL ENTRIES IN it_vbfa
                 WHERE vbeln = it_vbfa-vbeln
                 AND   posnr = it_vbfa-posnn.
        ENDIF.
      ENDIF.
    ENDFORM.                    " DATA_SELECT
    EVENT CATALOG ****************************************
    *&      Form  EVENT_CAT
          text
         -->P_I_EVENT  text
    FORM event_cat  USING    p_i_event TYPE slis_t_event .
      REFRESH p_i_event .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      I_LIST_TYPE           = 0
       IMPORTING
          et_events             = p_i_event
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      READ TABLE p_i_event WITH KEY name = slis_ev_top_of_page INTO t_event.
      IF sy-subrc = 0.
        MOVE 'TOP_OF_PAGE' TO t_event-form.
        MODIFY p_i_event FROM t_event INDEX sy-tabix TRANSPORTING form.
      ENDIF.
      CLEAR t_event .
    ENDFORM.                    " EVENT_CAT
    *********FORM FOR EVENT TOP_OF_PAGE*********************************
    FORM top_of_page .
      REFRESH i_listheader.
      DATA: t_header TYPE slis_listheader.
      DATA: v_text(50).
      WRITE sy-datum TO v_text.
      CLEAR t_header.
      t_header-typ = 'S'.
      t_header-key = 'Date'.
      t_header-info = v_text.
      APPEND t_header TO i_listheader.
      CLEAR t_header.
      CLEAR v_text.
    WRITE:  'SALES ORDER REPORT  ' TO v_text .
    t_header-typ = 'S'.
    t_header-key = 'TITLE'.
    t_header-info = v_text.
    APPEND t_header TO i_listheader.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = i_listheader.
         I_LOGO             = 'ALV_BACKGROUND'.
      I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP_OF_PAGE
    FIRST ALV GRID DISPLAY ***************************************
    *&      Form  CALL_ALV
          text
    -->  p1        text
    <--  p2        text
    FORM call_alv .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = sy-repid
       I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
         i_callback_user_command           = 'USER_COMMAND1'
         i_callback_top_of_page            = 'TOP_OF_PAGE'
         I_BACKGROUND_ID                   = 'ALV_BACKGROUND'
         i_grid_title                      = i_title_vbfa
         is_layout                         = i_layout
         it_fieldcat                       = i_fldcat[]
         it_sort                           = i_sort
         it_events                         = i_event
        TABLES
         t_outtab                          = it_so1
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " CALL_ALV
    FIRST FIELDCATALOG *************************************
    *&      Form  FLD_CAT
          text
         -->P_I_FLDCAT[]  text
    FORM fld_cat  USING    p_i_fldcat TYPE slis_t_fieldcat_alv.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'VBELN'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'."TABLE NAME
      i_fldcat-seltext_m   = 'SALES ORDER NO.'.
      i_fldcat-col_pos     = 1.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'AUART'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'."TABLE NAME
      i_fldcat-seltext_m   = 'SALES DOC. TYPE'.
      i_fldcat-col_pos     = 2.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 15.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'VKORG'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'.
      i_fldcat-seltext_m   = 'SALES ORG.'.
      i_fldcat-col_pos     = 3.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 12.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'SPART'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'.
      i_fldcat-seltext_m   = 'DIVISION'.
      i_fldcat-col_pos     = 4.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 10.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'KUNNR'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'.
      i_fldcat-seltext_m   = 'SOLD TO PARTY'.
      i_fldcat-col_pos     = 5.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 15.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'POSNR'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'.
      i_fldcat-seltext_m   = 'SALES DOC. ITEM'.
      i_fldcat-col_pos     = 6.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 17.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'MATNR'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'.
      i_fldcat-seltext_m   = 'MATERIAL NO.'.
      i_fldcat-col_pos     = 7.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'MAKTX'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'.
      i_fldcat-seltext_m   = 'DESCRIPTION'.
      i_fldcat-col_pos     = 8.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'KWMENG'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'.
      i_fldcat-seltext_m   = 'QUANTITY'.
      i_fldcat-col_pos     = 9.        " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 15.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-do_sum    = 'X'.        " For doing "SUM"
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
      CLEAR i_fldcat.
      i_fldcat-fieldname   = 'VRKME'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat-tabname     = 'IT_SO1'.
      i_fldcat-seltext_m   = 'SALES UNIT'.
      i_fldcat-col_pos     = 10.       " POSITION OF THE COLUMN.
      i_fldcat-outputlen   = 10.       " SET THE OUTPUT LENGTH.
      i_fldcat-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat-just(1)     = 'C'.
      APPEND i_fldcat.
    ENDFORM.                    " FLD_CAT
    ALV SORTING  ***************************************
    *&      Form  SORT
          text
         -->P_I_SORT  text
    FORM t_sort  USING    p_i_sort TYPE slis_t_sortinfo_alv .
      DATA: i_sort TYPE slis_sortinfo_alv .
      REFRESH p_i_sort .
      CLEAR i_sort.
      i_sort-spos = 1.
      i_sort-tabname = 'IT_SO1'.
      i_sort-fieldname = 'VBELN'.
      i_sort-up = 'X'.
      i_sort-subtot = 'X'.
      i_sort-group = '*'.
      APPEND i_sort TO p_i_sort.
    ENDFORM.                    " SORT
    *FORM SET_PF_STATUS USING rt_extab TYPE slis_t_extab.
    SET PF-STATUS 'ZSTANDARD'.
    *ENDFORM. "Set_pf_status
    **********FORM FOR EVENT USER_COMMAND1*******************************
    FORM user_command1 USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
    *CASE R_UCOMM .
       WHEN '&IC1' .
       IF rs_selfield-FIELDNAME = 'VBELN' .
       ENDIF .
    WHEN OTHERS .
    ENDCASE .
      CLEAR wa_so.
      REFRESH: it_del1 .
      IF r_ucomm = '&IC1' AND rs_selfield-fieldname = 'VBELN' AND
      rs_selfield-value IS NOT INITIAL.
        READ TABLE it_so1 INTO wa_so INDEX rs_selfield-tabindex.
        IF sy-subrc = 0.
          LOOP AT it_vbfa INTO wa_vbfa WHERE vbelv = wa_so-vbeln
                                       AND   posnv = wa_so-posnr.
            READ TABLE it_del_ful INTO wa_it_del_ful
                 WITH KEY vbeln = wa_vbfa-vbelv
                          posnr = wa_vbfa-posnn.
            IF sy-subrc = 0.
              CLEAR wa_del.
              MOVE wa_it_del_ful TO wa_del.
              APPEND wa_del TO it_del1.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
    SECOND ALV GRID DISPLAY ***********************************
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
        i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
        i_callback_user_command           = 'USER_COMMAND2'
        i_callback_top_of_page            = 'TOP_OF_PAGE'
        I_BACKGROUND_ID                   = 'ALV_BACKGROUND'
         i_grid_title                      = i_title_vbpa
        it_fieldcat                       = i_fldcat2[]
        it_sort                           = i_sort
        TABLES
        t_outtab                          = it_del_ful
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM .                    "USER_COMMAND1
    FORM FOR EVENT USER_COMMAND 2 ******************************
    FORM user_command2 USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      CLEAR wa_so.
      REFRESH: it_del1 .
      IF r_ucomm = '&IC1' AND rs_selfield-fieldname = 'VBELN' AND
      rs_selfield-value IS NOT INITIAL.
        READ TABLE it_so1 INTO wa_so INDEX rs_selfield-tabindex.
       IF SY-SUBRC = 0.
          LOOP AT it_vbfa INTO wa_vbfa WHERE vbelv = WA_SO-vbeln
                                       AND   posnv = WA_SO-posnr.
        READ TABLE it_del_ful INTO wa_it_del_ful
             WITH KEY vbeln = rs_selfield-value
                      posnr = wa_vbfa-posnn.
        IF rs_selfield-fieldname = 'VBELN'.
          SET PARAMETER ID 'VL' FIELD wa_vbfa-vbeln .
          CALL TRANSACTION 'VL03' AND SKIP FIRST SCREEN.
        ENDIF .
          ENDLOOP.
       ENDIF.
      ENDIF.
    ENDFORM .                    "USER_COMMAND2
    SECOND FIELDCATALOG ******************************************
    *&      Form  FLD_CAT2
          text
         -->P_I_FLDCAT2[]  text
    FORM fld_cat2  USING    p_i_fldcat2 TYPE slis_t_fieldcat_alv .
      CLEAR i_fldcat2.
      i_fldcat2-fieldname   = 'VBELN'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat2-tabname     = 'IT_DEL_FUL'."TABLE NAME
      i_fldcat2-seltext_m   = 'DELIVERY NO.'.
      i_fldcat2-col_pos     = 1.        " POSITION OF THE COLUMN.
      i_fldcat2-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat2-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat2-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat2-hotspot     = 'X'.
      i_fldcat2-just(1)     = 'C'.
      APPEND i_fldcat2.
      CLEAR i_fldcat2.
      i_fldcat2-fieldname   = 'POSNR'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat2-seltext_m   = 'DELIVERY ITEM'.
      i_fldcat2-col_pos     = 2.        " POSITION OF THE COLUMN.
      i_fldcat2-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat2-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat2-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat2-just(1)     = 'C'.
      APPEND i_fldcat2.
      CLEAR i_fldcat2.
      i_fldcat2-fieldname   = 'MATNR'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat2-seltext_m   = 'MATERIAL NO.'.
      i_fldcat2-col_pos     = 3.        " POSITION OF THE COLUMN.
      i_fldcat2-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat2-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat2-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat2-just(1)     = 'C'.
      APPEND i_fldcat2.
      CLEAR i_fldcat2.
      i_fldcat2-fieldname   = 'WERKS'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat2-seltext_m   = 'PLANT.'.
      i_fldcat2-col_pos     = 4.        " POSITION OF THE COLUMN.
      i_fldcat2-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat2-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat2-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat2-just(1)     = 'C'.
      APPEND i_fldcat2.
      CLEAR i_fldcat2.
      i_fldcat2-fieldname   = 'LGORT'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat2-seltext_m   = 'ST. LOCATION'.
      i_fldcat2-col_pos     = 5.        " POSITION OF THE COLUMN.
      i_fldcat2-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat2-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat2-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat2-just(1)     = 'C'.
      APPEND i_fldcat2.
      CLEAR i_fldcat2.
      i_fldcat2-fieldname   = 'CHARG'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat2-seltext_m   = 'BATCH NO.'.
      i_fldcat2-col_pos     = 6.        " POSITION OF THE COLUMN.
      i_fldcat2-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat2-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat2-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat2-just(1)     = 'C'.
      APPEND i_fldcat2.
      CLEAR i_fldcat2.
      i_fldcat2-fieldname   = 'LFIMG'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat2-seltext_m   = 'ACT. DEL. QTY.'.
      i_fldcat2-col_pos     = 7.        " POSITION OF THE COLUMN.
      i_fldcat2-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat2-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat2-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat2-just(1)     = 'C'.
      APPEND i_fldcat2.
      CLEAR i_fldcat2.
      i_fldcat2-fieldname   = 'VRKME'. "FIELD FOR WHICH CATALOG ID FILLED
      i_fldcat2-seltext_m   = 'SALES UNIT.'.
      i_fldcat2-col_pos     = 8.        " POSITION OF THE COLUMN.
      i_fldcat2-outputlen   = 20.       " SET THE OUTPUT LENGTH.
      i_fldcat2-emphasize   = 'X'.      " COLOR OF THIS COLUMN.
      i_fldcat2-key         = 'X'.      " SO THAT THIS FIELD IS NOT
      "SCROLLABLE AND HIDDABLE.
      i_fldcat2-just(1)     = 'C'.
      APPEND i_fldcat2.
    ENDFORM.                                                    " FLD_CAT2
    ALV LAYOUT *******************************************
    *&      Form  LAYOUT
          text
         -->P_I_LAYOUT  text
    FORM t_layout  USING    p_i_layout TYPE slis_layout_alv .
      p_i_layout-zebra  = 'X'.
      p_i_layout-totals_text = 'GRAND TOTAL ='.
    p_i_layout-CONFIRMATION_PROMPT = 'X'.
    p_i_layout-DEF_STATUS  = ' '.
      p_i_layout-info_fieldname = 'LINE_COLOR'.
    ENDFORM.                    " LAYOUT
    Note: Reward points if helpful.

  • Display Color for sigle  CELL in ALV report

    Hi all,
    I have one doubt is it possible to make a particular cell as read color in ALV.
    Ex: I have one field which shows amount in my ALV report,My requirement is that when ever the amount is less then 'ZERO', I have to show that particular cell in read color.
    Regards
    Anil Kumar.N

    hi,
    here code for coloring a perticular cell
    TYPE-POOLS:slis.
    TABLES:mara,
           makt,
           marc.
    DATA:BEGIN OF itab OCCURS 0,
          matnr LIKE mara-matnr,
          maktx LIKE makt-maktx,
          werks LIKE marc-werks,
          mtart LIKE mara-mtart,
          matkl LIKE mara-matkl,
          meins LIKE mara-meins,
          ntgew LIKE mara-ntgew,
         rowcolor(4) TYPE c,
          cellcolors TYPE lvc_t_scol,
         END OF itab.
    DATA:t_fcat TYPE slis_t_fieldcat_alv,
         t_eve TYPE slis_t_event.
    DATA : st_layout TYPE slis_layout_alv.
    SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:mat FOR mara-matnr.  " no intervals no-extension.
    *PARAMETERS:mat LIKE mara-matnr.
    SELECTION-SCREEN:END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_cata USING t_fcat.
      PERFORM build_event.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM display_data.
    *&      Form  build_cata
          text
         -->TEMP_FCAT  text
    FORM build_cata USING temp_fcat TYPE slis_t_fieldcat_alv.
      sy-tvar0 = sy-uname.
      WRITE sy-datum TO sy-tvar1.
      DATA:wa_fcat TYPE slis_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'Material'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Description'.
      wa_fcat-fix_column = 'x'.
      wa_fcat-key = 'X'.                                     "To color a column
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Plant'.
      wa_fcat-key = ' '.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MTART'.
      wa_fcat-seltext_m = 'Type'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATKL'.
      wa_fcat-seltext_m = 'Group'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MEINS'.
      wa_fcat-seltext_m = 'Measurement Unit'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'NTGEW'.
      wa_fcat-seltext_m = 'Net Value'.
      APPEND wa_fcat TO temp_fcat.
    ENDFORM.                    "build_cata
    *&      Form  build_event
          text
    FORM build_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = t_eve
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "build_event
    *&      Form  data_retrieval
          text
    FORM data_retrieval.
      SELECT maramatnr  maramtart maramatkl marameins mara~ntgew
       maktmaktx  marcwerks
      INTO CORRESPONDING FIELDS OF TABLE itab
      FROM mara INNER JOIN makt ON
      maramatnr = maktmatnr
      INNER JOIN marc ON
      maramatnr = marcmatnr
      WHERE mara~matnr IN mat.
      SORT itab BY matnr.
      DELETE ADJACENT DUPLICATES FROM itab.
    ENDFORM.                    "data_retrieval
    *&      Form  display_data
          text
    FORM display_data.
    *******************************For setting Cell Color*******************************************
      DATA ls_cellcolor TYPE lvc_s_scol .
      st_layout-coltab_fieldname = 'CELLCOLORS'.
      READ TABLE itab INDEX 5 .
      ls_cellcolor-fname = 'MATNR' .
      ls_cellcolor-color-col = '1' .
      ls_cellcolor-color-int = '1' .
      APPEND ls_cellcolor TO itab-cellcolors .
      MODIFY itab INDEX 5 .
    st_layout-colwidth_optimize = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = 'ZALV_DS'
          is_layout          = st_layout
          i_save             = 'A'
          it_fieldcat        = t_fcat
          it_events          = t_eve
        TABLES
          t_outtab           = itab
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "display_data
    Please reward if useful...

  • Dynamic columns in report... NON ALV REPORT

    Hey Guys,
    I have a internal table which has abt 50 columns now i wanna show only the columns that have any value in it...
    Now this is not an ALV report... this is a basic report....
    So anyideas as to where i can start  on this.... i dont want to write if conditions...
    i am tryin to make this as elegent as possible...
    all help will be appreciated
    Thanks

    Hi,
    Try this..
    In this example..I have an internal table with the columns MATNR, WERKS, LGORT & MENGE...The ITAB is having value only for matnr and werks..It will print only MATNR and WERKS in the output..
    <b>* Data declarations.</b>
    DATA: BEGIN OF itab OCCURS 0,
            matnr  TYPE matnr,
            werks  TYPE werks_d,
            lgort  TYPE mard-lgort,
            menge  TYPE ekpo-menge,
          END OF itab.
    DATA: BEGIN OF itab_desc OCCURS 0,
            compname(30),
            text(20),
          END OF itab_desc.
    DATA: v_repid TYPE syrepid.
    DATA: t_comp  LIKE rstrucinfo OCCURS 0 WITH HEADER LINE.
    FIELD-SYMBOLS: <fs>.
    DATA: t_allowed_fields(30) OCCURS 0 WITH HEADER LINE.
    <b>* Program.</b>
    v_repid = sy-repid.
    <b>* Sample data.</b>
    itab-matnr = 'TEST'.   itab-lgort = '0001'.APPEND itab.
    itab-matnr = 'TEST12'. itab-lgort = '0001'.APPEND itab.
    itab-matnr = 'TEST123'.itab-lgort = '0001'.APPEND itab.
    <b>* Store the columns texts.</b>
    itab_desc-compname = 'MATNR'. itab_desc-text = 'Material'.
    APPEND itab_desc.
    itab_desc-compname = 'WERKS'. itab_desc-text = 'Plant'.
    APPEND itab_desc.
    itab_desc-compname = 'LGORT'. itab_desc-text = 'Sto. Loc'.
    APPEND itab_desc.
    itab_desc-compname = 'MENGE'. itab_desc-text = 'Quantity'.
    APPEND itab_desc.
    <b>* Get the components for that internal table.</b>
    CALL FUNCTION 'GET_COMPONENT_LIST'
         EXPORTING
              program    = v_repid
              fieldname  = 'ITAB'
         TABLES
              components = t_comp.
    <b>* Get the columns that has some value.</b>
    LOOP AT t_comp.
      LOOP AT itab.
        ASSIGN COMPONENT t_comp-compname OF STRUCTURE itab TO <fs>.
        IF NOT <fs> IS INITIAL.
          EXIT.
        ENDIF.
      ENDLOOP.
    Allowed columns.
      IF NOT <fs> IS INITIAL.
        t_allowed_fields = t_comp-compname.
        APPEND t_allowed_fields.
      ENDIF.
    ENDLOOP.
    <b>* Print the Header.</b>
    LOOP AT t_allowed_fields.
      READ TABLE t_comp WITH KEY compname = t_allowed_fields.
      READ TABLE itab_desc WITH KEY compname = t_allowed_fields.
      WRITE: AT (t_comp-olen) itab_desc-text COLOR COL_HEADING.
    ENDLOOP.
    <b>* Print the data.</b>
    LOOP AT itab.
      WRITE: / space.
      LOOP AT t_allowed_fields.
        READ TABLE t_comp WITH KEY compname = t_allowed_fields.
        ASSIGN COMPONENT t_comp-compname OF STRUCTURE itab TO <fs>.
        WRITE: AT (t_comp-olen) <fs>.
      ENDLOOP.
    ENDLOOP.
    Thanks,
    Naren

  • To make different colours for the columns of ALV report in Grid display.

    Hai Friends,
                       I have created an ALV report in grid display method by using the call function reuse_alv_grid_display.
    I have obtained the report.In that report i want to change the colour of each column.Plz provide the answer with a sample program.
                    Thank u.

    hi i had a program  for the rows with diff colors....do the same thing for the columns..
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) type c,     "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    Set layout field for row attributes(i.e. color)
      gd_layout-info_fieldname =      'LINE_COLOR'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    data: ld_color(1) type c.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    *Populate field with color attributes
    loop at it_ekko into wa_ekko.
      ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
      if ld_color = 8.
        ld_color = 1.
      endif.
      concatenate 'C' ld_color '10' into wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
      modify it_ekko from wa_ekko.
    endloop.
    endform.                    " DATA_RETRIEVAL
    regards,
    venkat

  • Fix columns in alv report

    hi!
    i wrote an alv report. i want the first 3 columns of the report to be fixed, and let the option of scrolling to the left or to the right to the rest of the columns.
    thanks
    yifat

    hi Yifat,
      Try The KEY option in your field catalogue..
    If this field is set, the ALV Grid Control color-codes the column as a key field and  fixes this column during horizontal scrolling
    regards
    satesh

  • Change color in alv column

    how do change color of a column in ALV.

    Hi
    The below abap program shows how to change the colour of individual ALV cells /fields. Only a small number of changes are required from a basic ALV grid which include adding a new field to ALV data declaration table(it_ekko), populating this field with the field name identifier and colour attributes and finally adding an entry to layout control work area. These changes are highlighted in bold below.
    REPORT  zdemo_alvgrid                 .
    REPORT  ZALV_CELLCOLOR.
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      CELLCOLOR TYPE LVC_T_SCOL,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
      perform data_retrieval.
      perform build_fieldcatalog.
      perform build_layout.
      perform set_cell_colours.
      perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you  more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
                  I.e. Field type may be required in-order for
                       the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
      gd_LAYOUT-coltab_fieldname = 'CELLCOLOR'.  "CTAB_FNAME
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      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           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
              it_events               = gt_events
              is_print                = gd_prntparams
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
      select ebeln ebelp statu aedat matnr menge meins netpr peinh
       up to 10 rows
        from ekpo
        into CORRESPONDING FIELDS OF TABLE it_ekko.
    endform.                    " DATA_RETRIEVAL
    Form  TOP-OF-PAGE                                                 *
    ALV Report Header                                                 *
    Form top-of-page.
    *ALV Header declarations
      data: t_header type slis_t_listheader,
            wa_header type slis_listheader,
            t_line like wa_header-info,
            ld_lines type i,
            ld_linesc(10) type c.
    Title
      wa_header-typ  = 'H'.
      wa_header-info = 'EKKO Table Report'.
      append wa_header to t_header.
      clear wa_header.
    Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      CONCATENATE  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) INTO wa_header-info.   "todays date
      append wa_header to t_header.
      clear: wa_header.
    Total No. of Records Selected
      describe table it_ekko lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'Total No. of Records Selected: ' ld_linesc
                        into t_line separated by space.
      wa_header-typ  = 'A'.
      wa_header-info = t_line.
      append wa_header to t_header.
      clear: wa_header, t_line.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_header.
               i_logo             = 'Z_LOGO'.
    endform.                    "top-of-page
    *&      Form  SET_CELL_COLOURS
          Set colour of individual ALV cell, field
    FORM SET_CELL_COLOURS .
      DATA: WA_CELLCOLOR TYPE LVC_S_SCOL.
      DATA: ld_index TYPE SY-TABIX.
      LOOP AT IT_EKKO into wa_ekko.
        LD_INDEX = SY-TABIX.
      Set colour of EBELN field to various colors based on sy-tabix value
        WA_CELLCOLOR-FNAME = 'EBELN'.
        WA_CELLCOLOR-COLOR-COL = sy-tabix.  "color code 1-7, if outside rage defaults to 7
        WA_CELLCOLOR-COLOR-INT = '1'.  "1 = Intensified on, 0 = Intensified off
        WA_CELLCOLOR-COLOR-INV = '0'.  "1 = text colour, 0 = background colour
        APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
        MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
      Set colour of NETPR field to color 4 if gt 0
        if wa_ekko-netpr gt 0.
          WA_CELLCOLOR-FNAME = 'NETPR'.
          WA_CELLCOLOR-COLOR-COL = 4.  "color code 1-7, if outside rage defaults to 7
          WA_CELLCOLOR-COLOR-INT = '0'.  "1 = Intensified on, 0 = Intensified off
          WA_CELLCOLOR-COLOR-INV = '0'.  "1 = text colour, 0 = background colour
          APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
          MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
        endif.
      Set colour of AEDAT field text to red(6)
        WA_CELLCOLOR-FNAME = 'AEDAT'.
        WA_CELLCOLOR-COLOR-COL = 6.  "color code 1-7, if outside rage defaults to 7
        WA_CELLCOLOR-COLOR-INT = '0'.  "1 = Intensified on, 0 = Intensified off
        WA_CELLCOLOR-COLOR-INV = '1'.  "1 = text colour, 0 = background colour
        APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
        MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
      ENDLOOP.
    ENDFORM.                    " SET_CELL_COLOURS

  • How to switch off column coloring of alv grid printouts?

    Hello World!
    Is there any possibility (a customizing option or a parameter) to switch off cell/column coloring of alv grid printouts?
    It is very useful to see colored columns in screens, but they are darkened in printouts. How to avoid it?
    Thanks and regards,
    Vladimir

    Hi,
    You can have different layouts for a ALV report and each layout the look and feel can be different.
    So, the manual activity is the user will have to switch to the B/W layout before printing. I am not sure if you have enabled the LAYOUT option for the user to change it by himself.
    I hope I am able to get across my point.
    If you are using OO ALV control, you can dynamically change the layout using set_frontend_layout  method. The user can also change the layout --
    choose Change layout or Settings ® Layout ® Change.
    The Change Layout dialog box shows you which columns are currently displayed and which additional columns can be displayed.
    Regards,
    Ravi
    Note - Please mark the helpful answers
    Message was edited by: Ravikumar Allampallam

Maybe you are looking for

  • How to create a duplicate address book contact?

    This seems so simple yet I cannot determine how to create a new duplicate address book contact. I have a few contacts from the same company and want to change the variable data instead of re entering the data I can create a new contact, copy the data

  • BAPI_APOATP_CHECK Third Party Processing

    Hi, I am wondering whether it is possible to use BAPI_APOATP_CHECK for third party processing. I have read note 1409611 and it says that since SCM 4.1 a BAPI for ATP is available. However, the BAPI for ATP is not for third party processing. Is BAPI_A

  • How do I start firefox in full screen?

    I would like to start Firefox in LINUX environment from the command line. That is easy just type FIREFOX and hit enter or call a script for that instruction ios what I do. The challenge is to start the browser FULL SCREEN, WITHOUT showing the cursor

  • : Photoshop Premier 10 is installed correctly but when I open it I get the following message:' a red

    Photoshop Premier 10 is installed correctly (from content DVD) on Windows 7 Pro but when I open it I get the following message:' a reduced set of content has been installed. You can install full content by inserting your content dvd, when I click ins

  • Scheduled even for an extract from CRM OD

    Hi all, I need to extract in a scheduled manner data from CRM OD. An example may be that each day i need to extract all new accounts from CRM OD and put this info in an excel file. Now, I can develop a web services that can do this, but the problem i