Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dear Abapers,

former_member227596
Participant
0 Kudos

I want to give colour to the cells having amount -ve. How this can be possible. If any example. Pl. send me.

Thanks in Advance

Vikas

4 REPLIES 4

Former Member
0 Kudos

How can I set the cell color in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=52107

Former Member
0 Kudos

Report code

Code:

REPORT zcuitest_alv_07.

  • Use of colours in ALV grid (cell, line and column) *

  • Table

TABLES : mara.

  • Type

TYPES : BEGIN OF ty_mara,

matnr LIKE mara-matnr,

matkl LIKE mara-matkl,

counter(4) TYPE n,

free_text(15) TYPE c,

color_line(4) TYPE c, " Line color

color_cell TYPE lvc_t_scol, " Cell color

END OF ty_mara.

  • Structures

DATA : wa_mara TYPE ty_mara,

wa_fieldcat TYPE lvc_s_fcat,

is_layout TYPE lvc_s_layo,

wa_color TYPE lvc_s_scol.

  • Internal table

DATA : it_mara TYPE STANDARD TABLE OF ty_mara,

it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,

it_color TYPE TABLE OF lvc_s_scol.

  • Variables

DATA : okcode LIKE sy-ucomm,

w_alv_grid TYPE REF TO cl_gui_alv_grid,

w_docking_container TYPE REF TO cl_gui_docking_container.

PARAMETERS : p_column AS CHECKBOX,

p_line AS CHECKBOX,

p_cell AS CHECKBOX.

START-OF-SELECTION.

PERFORM get_data.

END-OF-SELECTION.

PERFORM fill_catalog.

PERFORM fill_layout.

CALL SCREEN 2000.

&----


*& Module status_2000 OUTPUT

&----


  • text

----


MODULE status_2000 OUTPUT.

SET PF-STATUS '2000'.

ENDMODULE. " status_2000 OUTPUT

&----


*& Module user_command_2000 INPUT

&----


  • text

----


MODULE user_command_2000 INPUT.

DATA : w_okcode LIKE sy-ucomm.

MOVE okcode TO w_okcode.

CLEAR okcode.

CASE w_okcode.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " user_command_2000 INPUT

&----


*& Module alv_grid OUTPUT

&----


  • text

----


MODULE alv_grid OUTPUT.

IF w_docking_container IS INITIAL.

PERFORM create_objects.

PERFORM display_alv_grid.

ENDIF.

ENDMODULE. " alv_grid OUTPUT

&----


*& Form create_objects

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM create_objects.

  • Ratio must be included in [5..95]

CREATE OBJECT w_docking_container

EXPORTING

ratio = 95

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6.

CREATE OBJECT w_alv_grid

EXPORTING

i_parent = w_docking_container.

ENDFORM. " create_objects

&----


*& Form display_alv_grid

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_alv_grid.

CALL METHOD w_alv_grid->set_table_for_first_display

EXPORTING

is_layout = is_layout

CHANGING

it_outtab = it_mara

it_fieldcatalog = it_fieldcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

ENDFORM. " display_alv_grid

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data.

SELECT * FROM mara UP TO 5 ROWS.

CLEAR : wa_mara-color_line, wa_mara-color_cell.

MOVE-CORRESPONDING mara TO wa_mara.

ADD 1 TO wa_mara-counter.

MOVE 'Blabla' TO wa_mara-free_text.

IF wa_mara-counter = '0002'

AND p_line = 'X'.

  • Color line

MOVE 'C410' TO wa_mara-color_line.

ELSEIF wa_mara-counter = '0004'

AND p_cell = 'X'.

  • Color cell

MOVE 'FREE_TEXT' TO wa_color-fname.

MOVE '5' TO wa_color-color-col.

MOVE '1' TO wa_color-color-int.

MOVE '1' TO wa_color-color-inv.

APPEND wa_color TO it_color.

wa_mara-color_cell[] = it_color[].

ENDIF.

APPEND wa_mara TO it_mara.

ENDSELECT.

ENDFORM. " get_data

&----


*& Form fill_catalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_catalog.

  • 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) *

  • *

  • Colour overwriting priority : *

  • 1. Line *

  • 2. Cell *

  • 3. Column *

DATA : w_position TYPE i VALUE '1'.

CLEAR wa_fieldcat.

MOVE w_position TO wa_fieldcat-col_pos.

MOVE 'MATNR' TO wa_fieldcat-fieldname.

MOVE 'MARA' TO wa_fieldcat-ref_table.

MOVE 'MATNR' TO wa_fieldcat-ref_field.

APPEND wa_fieldcat TO it_fieldcat.

ADD 1 TO w_position.

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

IF p_column = 'X'.

MOVE 'C610' TO wa_fieldcat-emphasize.

ENDIF.

APPEND wa_fieldcat TO it_fieldcat.

ADD 1 TO w_position.

CLEAR wa_fieldcat.

MOVE w_position TO wa_fieldcat-col_pos.

MOVE 'COUNTER' TO wa_fieldcat-fieldname.

MOVE 'N' TO wa_fieldcat-inttype.

MOVE '4' TO wa_fieldcat-intlen.

MOVE 'Counter' TO wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

ADD 1 TO w_position.

CLEAR wa_fieldcat.

MOVE w_position TO wa_fieldcat-col_pos.

MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname.

MOVE 'C' TO wa_fieldcat-inttype.

MOVE '20' TO wa_fieldcat-intlen.

MOVE 'Text' TO wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. " fill_catalog

&----


*& Form fill_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_layout.

  • Field that identify color line in internal table

MOVE 'COLOR_LINE' TO is_layout-info_fname.

  • Field that identify cell color in inetrnal table

MOVE 'COLOR_CELL' TO is_layout-ctab_fname.

ENDFORM. " fill_layout

Flow logic code

Code:

PROCESS BEFORE OUTPUT.

MODULE status_2000.

MODULE alv_grid.

PROCESS AFTER INPUT.

MODULE user_command_2000.

Former Member
0 Kudos

Hi

I had developed a reprort for displaying various colors it is working fine with me plz check this sample code

 *&---------------------------------------------------------------------*
*& Report  ZALVCOLOR                                                   *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZALVCOLOR                               .

DATA : mara TYPE mara.                 " General Material Data

TYPE-POOLS: slis.                      " ALV Global types

FIELD-SYMBOLS :
  <data> TYPE table.                   " Data to display

SELECT-OPTIONS :
  s_matnr FOR mara-matnr.              " Material number

SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '50' OBLIGATORY.
SELECTION-SCREEN END OF LINE.

*---------------------------------------------------------------------*
INITIALIZATION.

  v_1 = 'Maximum of lines to display'.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data.

  PERFORM f_display_data.

*---------------------------------------------------------------------*
*      Form  f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.

  FIELD-SYMBOLS :
    <field>    TYPE ANY,
    <field2>   TYPE ANY,
    <header>   TYPE ANY,
    <header2>  TYPE ANY,
    <lt_data>  TYPE table.             " Data read from DB

  DATA:
    lp_struct  TYPE REF TO data,
    lp_struct2 TYPE REF TO data,
    lp_table   TYPE REF TO data,       " Pointer to dynamic table
    lp_table2  TYPE REF TO data,       " Pointer to dynamic table
    ls_lvc_cat TYPE lvc_s_fcat,
    lt_lvc_cat TYPE lvc_t_fcat.        " Field catalog

* First column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MATNR'.
  ls_lvc_cat-ref_table = 'MARA'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* 2nd column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MAKTX'.
  ls_lvc_cat-ref_table = 'MAKT'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* 3rd column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MATKL'.
  ls_lvc_cat-ref_table = 'MARA'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Create 1st internal table
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING it_fieldcatalog = lt_lvc_cat
    IMPORTING ep_table = lp_table.

  ASSIGN lp_table->* TO <lt_data>.

* Read data into 1st internal table
  SELECT matnr maktx matkl
    INTO TABLE <lt_data>
    FROM v_matnr
      UP TO p_max ROWS
   WHERE matnr IN s_matnr.

* Create 2nd internal table
* Checkbox
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'CHECKBOX'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Table color
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'TABCOLOR'.
  ls_lvc_cat-ref_table = 'CALENDAR_TYPE'.
  ls_lvc_cat-ref_field = 'COLTAB'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Create 2nd internal table
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING it_fieldcatalog = lt_lvc_cat
    IMPORTING ep_table = lp_table2.

  ASSIGN lp_table2->* TO <data>.

* Create structure = structure of the 1st internal table
  CREATE DATA lp_struct LIKE LINE OF <lt_data>.
  ASSIGN lp_struct->* TO <header>.

* Create structure = structure of the 2nd internal table
  CREATE DATA lp_struct2 LIKE LINE OF <data>.
  ASSIGN lp_struct2->* TO <header2>.

* Move data from 1st internal table --> 2nd internal table
  LOOP AT <lt_data> ASSIGNING <header>.

    DESCRIBE TABLE lt_lvc_cat.
    CLEAR <header2>.

*   Fill the internal to display <data>
    DO sy-tfill TIMES.
      READ TABLE lt_lvc_cat INTO ls_lvc_cat INDEX sy-index.
*     For each field of lt_lvc_cat.
      ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE <header>
                    TO <field>.
      IF sy-subrc NE 0. EXIT .ENDIF.
      ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE <header2>
                    TO <field2>.
      IF sy-subrc NE 0. EXIT .ENDIF.
      <field2> = <field>.
    ENDDO.

*   Modify color
    ASSIGN COMPONENT 'TABCOLOR' OF STRUCTURE <header2>
                  TO <field2>.
    IF sy-subrc EQ 0.
      PERFORM f_modify_color USING 'MAKTX' <field2>.
      PERFORM f_modify_color USING 'MATKL' <field2>.
    ENDIF.

    APPEND <header2> TO <data> .
  ENDLOOP.

ENDFORM.                    " f_read_data
*---------------------------------------------------------------------*
*      Form  F_DISPLAY_DATA
*---------------------------------------------------------------------*
FORM f_display_data.

* Macro definition
  DEFINE m_sort.
    add 1 to ls_sort-spos.
    ls_sort-fieldname = &1.
    ls_sort-down      = 'X'.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.

  DATA:
    ls_layout   TYPE slis_layout_alv,
    lt_sort     TYPE slis_t_sortinfo_alv,
    ls_sort     TYPE slis_sortinfo_alv,
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.  " Field catalog

* Build Fieldcatalog - First column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MATNR'.
  ls_fieldcat-ref_tabname = 'MARA'.
  ls_fieldcat-key  = 'X'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Build Fieldcatalog - 2nd column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MAKTX'.
  ls_fieldcat-ref_tabname = 'MAKT'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Build Fieldcatalog - 3rd column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MATKL'.
  ls_fieldcat-ref_tabname = 'MARA'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Layout
  ls_layout-zebra = 'X'.
  ls_layout-colwidth_optimize = 'X'.
  ls_layout-box_fieldname = 'CHECKBOX'.
  ls_layout-coltab_fieldname = 'TABCOLOR'.

  m_sort 'MATNR'.                      " Sort by creation date

* Display data
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            is_layout   = ls_layout
            it_fieldcat = lt_fieldcat
            it_sort     = lt_sort
       TABLES
            t_outtab    = <data>.

ENDFORM.                               " F_DISPLAY_DATA
*---------------------------------------------------------------------*
*      Form  F_modify_color
*---------------------------------------------------------------------*
FORM f_modify_color USING u_fieldname TYPE lvc_fname
                          ut_tabcolor TYPE table.

  DATA:
    l_rnd_value TYPE datatype-integer2,
    ls_tabcolor TYPE lvc_s_scol.

* Random value
  CALL FUNCTION 'RANDOM_I2'
       EXPORTING
            rnd_min   = 0
            rnd_max   = 3
       IMPORTING
            rnd_value = l_rnd_value.

  CLEAR ls_tabcolor.
  ls_tabcolor-fname = u_fieldname.

  CASE l_rnd_value.
    WHEN 0.
      ls_tabcolor-color-col = 1.       " Blue.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 1.
      ls_tabcolor-color-col = 3.       " Yellow.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 2.
      ls_tabcolor-color-col = 5.       " Green.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 3.
      ls_tabcolor-color-col = 6.       " Red.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
  ENDCASE.

  INSERT ls_tabcolor INTO TABLE ut_tabcolor.

ENDFORM.                               " F_MODIFY_COLOR

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos

Hi check the sample program below:

Hope this helps you a lot.

REPORT Z_ALV04.

*******Declare Data Areas for List Viewer (Begin)***********

TYPE-POOLS: SLIS.

PARAMETERS:

P_ROW TYPE I,

P_COLUMN TYPE I.

DATA:

FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

FIELDCAT_LN LIKE LINE OF FIELDCAT,

SORTCAT TYPE SLIS_T_SORTINFO_ALV,

SORTCAT_LN LIKE LINE OF SORTCAT,

EVENTCAT TYPE SLIS_T_EVENT,

EVENTCAT_LN LIKE LINE OF EVENTCAT.

DATA:

COL_POS TYPE I.

******Declare Data Areas for List Viewer (End)**************

******Declare Internal Table to Store Selected Data (Begin)*

DATA:

BEGIN OF ISPFLI OCCURS 0,

CHECK TYPE SLIS_FIELDNAME,

R_COLOR(3) TYPE C,

CELL TYPE SLIS_T_SPECIALCOL_ALV,

CARRID LIKE SPFLI-CARRID,

CONNID LIKE SPFLI-CONNID,

COUNTRYFR LIKE SPFLI-COUNTRYFR,

END OF ISPFLI.

DATA:

WA LIKE LINE OF ISPFLI,

W_LINES TYPE I.

DATA:

FS_CELL LIKE LINE OF ISPFLI-CELL.

DATA:

LAYOUT1 TYPE SLIS_LAYOUT_ALV.

******Declare Internal Table to Store Selected Data (End)***

*******Select Data into Internal Table (Begin) ***************

SELECT CARRID CONNID COUNTRYFR

INTO CORRESPONDING FIELDS OF TABLE ISPFLI

FROM SPFLI.

DESCRIBE TABLE ISPFLI LINES W_LINES.

IF P_ROW IS INITIAL AND

P_COLUMN IS INITIAL .

MESSAGE 'Enter atlest one number' TYPE 'I'.

STOP.

ELSEIF P_ROW GT W_LINES.

MESSAGE 'Row with the row number is not there' TYPE 'I'.

STOP.

ENDIF.

IF P_COLUMN IS NOT INITIAL AND

P_COLUMN GT 3.

MESSAGE 'Field with the column number is not there' TYPE 'I'.

STOP.

ENDIF.

              • Select Data into Internal Table (End) ****************

              • Build Field Catalogs (Begin)**************************

IF P_ROW IS NOT INITIAL AND P_COLUMN IS INITIAL.

PERFORM BUILD_FIELDCAT.

PERFORM BUILD_FIELDCAT2.

PERFORM BUILD_FIELDCAT4.

PERFORM BUILD_LAYOUT1.

PERFORM ROW_COLOR.

ELSEIF P_COLUMN IS NOT INITIAL

AND P_ROW IS NOT INITIAL.

PERFORM BUILD_FIELDCAT.

PERFORM BUILD_FIELDCAT2.

PERFORM BUILD_FIELDCAT4.

PERFORM BUILD_LAYOUT1.

PERFORM CELL_COLOR.

ELSE.

PERFORM BUILD_FIELDCAT.

PERFORM BUILD_FIELDCAT2.

PERFORM BUILD_FIELDCAT3.

PERFORM BUILD_LAYOUT1.

ENDIF.

  • PERFORM ROW_COLOR.

  • PERFORM CELL_COLOR.

  • PERFORM BUILD_FIELDCAT.

  • PERFORM BUILD_FIELDCAT2.

  • PERFORM BUILD_FIELDCAT3.

  • PERFORM BUILD_LAYOUT1.

  • PERFORM ROW_COLOR.

  • PERFORM CELL_COLOR.

  • PERFORM ROW_COLOR.

  • PERFORM CELL_COLOR.

  • PERFORM BUILD_SORTCAT.

  • PERFORM BUILD_SORTCAT2.

******Build Field Catalogs (End)*****************************

******Build Event Catalog (Begin)****************************

PERFORM BUILD_EVENTCAT.

******Build Event Catalog (End)******************************

******Start List Viewer (Begin)******************************

PERFORM START_LIST_VIEWER.

******Start List Viewer (End)********************************

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

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

********FORM ROUTINES (Begin)********************************

FORM ROW_COLOR.

CLEAR WA.

READ TABLE ISPFLI INDEX P_ROW INTO WA.

WA-R_COLOR = 'C61'.

MODIFY ISPFLI FROM WA INDEX P_ROW.

CLEAR WA.

ENDFORM.

FORM CELL_COLOR.

CLEAR WA.

CLEAR FS_CELL.

FS_CELL-FIELDNAME = 'CONNID'.

FS_CELL-COLOR-COL = P_COLUMN."4.

FS_CELL-COLOR-INT = 0.

FS_CELL-COLOR-INV = 1.

  • READ TABLE ISPFLI INDEX P_ROW INTO WA.

APPEND FS_CELL TO WA-CELL.

MODIFY ISPFLI FROM WA INDEX P_ROW TRANSPORTING CELL.

CLEAR WA.

CLEAR FS_CELL.

ENDFORM.

  • Color table-FIELDNAME = field name of the cell to be colored

  • Color table-COLOR-COL = color number (1 - 9)

  • Color table-COLOR-INT = bold (0 = off, 1 = on)

  • Color table-COLOR-INV = inverse (0 = off, 1 = on)

  • Color table-NOKEYCOL = ignore key coloring ('X' = yes, ' ' = no)

FORM BUILD_FIELDCAT.

CLEAR FIELDCAT_LN.

  • ADD 1 TO COL_POS.

FIELDCAT_LN-REF_TABNAME = 'SPFLI'.

FIELDCAT_LN-FIELDNAME = 'CARRID'.

  • FIELDCAT_LN-REF_FIELDNAME = SPACE.

FIELDCAT_LN-OUTPUTLEN = 20.

FIELDCAT_LN-KEY = 'X'.

FIELDCAT_LN-NO_OUT = 'X'."SPACE.

  • FIELDCAT_LN-DO_SUM = SPACE.

FIELDCAT_LN-COL_POS = 2.

FIELDCAT_LN-NO_OUT = SPACE.

  • FIELDCAT_LN-QFIELDNAME = SPACE.

FIELDCAT_LN-HOTSPOT = 'X'.

APPEND FIELDCAT_LN TO FIELDCAT.

ENDFORM. "BUILD_FIELDCAT

&----


*& Form BUILD_FIELDCAT2

&----


  • text

----


FORM BUILD_FIELDCAT2.

CLEAR FIELDCAT_LN.

  • ADD 1 TO COL_POS.

FIELDCAT_LN-REF_TABNAME = 'SPFLI'.

FIELDCAT_LN-FIELDNAME = 'CONNID'.

  • FIELDCAT_LN-REF_FIELDNAME = SPACE.

FIELDCAT_LN-OUTPUTLEN = 20.

FIELDCAT_LN-KEY = 'X'.

  • FIELDCAT_LN-DO_SUM = SPACE.

FIELDCAT_LN-COL_POS = 1.

FIELDCAT_LN-NO_OUT = SPACE .

  • FIELDCAT_LN-QFIELDNAME = SPACE.

FIELDCAT_LN-HOTSPOT = SPACE.

APPEND FIELDCAT_LN TO FIELDCAT.

ENDFORM. "BUILD_FIELDCAT2

&----


*& Form BUILD_FIELDCAT3

&----


  • text

----


FORM BUILD_FIELDCAT3.

CLEAR FIELDCAT_LN.

  • ADD 1 TO COL_POS.

FIELDCAT_LN-REF_TABNAME = 'SPFLI'.

FIELDCAT_LN-FIELDNAME = 'COUNTRYFR'.

  • FIELDCAT_LN-REF_FIELDNAME = SPACE.

FIELDCAT_LN-OUTPUTLEN = 20.

FIELDCAT_LN-EMPHASIZE = 'C310'.

  • FIELDCAT_LN-EMPHASIZE = 'X'.

  • FIELDCAT_LN-EMPHASIZE = SPACE.

  • FIELDCAT_LN-KEY = SPACE.

  • FIELDCAT_LN-DO_SUM = 'X'.

FIELDCAT_LN-COL_POS = 3.

FIELDCAT_LN-NO_OUT = SPACE.

  • FIELDCAT_LN-QFIELDNAME = SPACE.

  • FIELDCAT_LN-HOTSPOT = SPACE.

APPEND FIELDCAT_LN TO FIELDCAT.

ENDFORM. "BUILD_FIELDCAT3

FORM BUILD_FIELDCAT4.

CLEAR FIELDCAT_LN.

  • ADD 1 TO COL_POS.

FIELDCAT_LN-REF_TABNAME = 'SPFLI'.

FIELDCAT_LN-FIELDNAME = 'COUNTRYFR'.

  • FIELDCAT_LN-REF_FIELDNAME = SPACE.

FIELDCAT_LN-OUTPUTLEN = 20.

  • FIELDCAT_LN-EMPHASIZE = 'C310'.

  • FIELDCAT_LN-EMPHASIZE = 'X'.

  • FIELDCAT_LN-EMPHASIZE = SPACE.

  • FIELDCAT_LN-KEY = SPACE.

  • FIELDCAT_LN-DO_SUM = 'X'.

FIELDCAT_LN-COL_POS = 3.

FIELDCAT_LN-NO_OUT = SPACE.

  • FIELDCAT_LN-QFIELDNAME = SPACE.

  • FIELDCAT_LN-HOTSPOT = SPACE.

APPEND FIELDCAT_LN TO FIELDCAT.

ENDFORM. "BUILD_FIELDCAT3

&----


*& Form BUILD_SORTCAT

&----


  • text

----


FORM BUILD_SORTCAT.

CLEAR SORTCAT_LN.

SORTCAT_LN-SPOS = '1'.

SORTCAT_LN-FIELDNAME = 'CONNID'.

SORTCAT_LN-UP = 'X'..

  • SORTCAT_LN-DOWN = SPACE.

SORTCAT_LN-SUBTOT = 'X'.

APPEND SORTCAT_LN TO SORTCAT.

ENDFORM. "BUILD_SORTCAT

&----


*& Form BUILD_SORTCAT2

&----


  • text

----


FORM BUILD_SORTCAT2.

CLEAR SORTCAT_LN.

SORTCAT_LN-SPOS = '2'.

SORTCAT_LN-FIELDNAME = 'CARRID'.

  • SORTCAT_LN-UP = SPACE.

SORTCAT_LN-DOWN = 'X'.

  • SORTCAT_LN-SUBTOT = SPACE.

APPEND SORTCAT_LN TO SORTCAT.

ENDFORM. " BUILD_SORTCAT2

FORM BUILD_LAYOUT1.

LAYOUT1-BOX_FIELDNAME = 'CHECK'.

LAYOUT1-INFO_FIELDNAME = 'R_COLOR'.

LAYOUT1-COLTAB_FIELDNAME = 'CELL'.

ENDFORM. " BUILD_LAYOUT1

&----


*& Form BUILD_EVENTCAT

&----


  • text

----


FORM BUILD_EVENTCAT.

EVENTCAT_LN-NAME = 'TOP_OF_PAGE'.

EVENTCAT_LN-FORM = 'PAGE_HEADER'.

APPEND EVENTCAT_LN TO EVENTCAT.

ENDFORM. "BUILD_EVENTCAT

&----


*& Form START_LIST_VIEWER

&----


  • text

----


FORM START_LIST_VIEWER.

DATA: PGM LIKE SY-REPID.

PGM = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = PGM

  • i_callback_pf_status_set = ' '

  • I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

IS_LAYOUT = LAYOUT1

IT_FIELDCAT = FIELDCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = SORTCAT

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = 'A'

  • IS_VARIANT = ' '

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • es_exit_caused_by_user =

TABLES

T_OUTTAB = ISPFLI

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

ENDFORM. "START_LIST_VIEWER

*******Process Call Back Events (Begin)**************************

*FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM

  • SELFIELD TYPE SLIS_SELFIELD.

*READ TABLE ISPFLI INDEX SELFIELD-TABINDEX.

*CHECK SY-SUBRC = 0.

*CASE UCOMM.

*WHEN '&IC1'.

*CASE SELFIELD-SEL_TAB_FIELD.

  • WHEN 'ISPFLI-CARRID'.

  • SET PARAMETER ID 'AUN' FIELD IVBAP-VBELN.

  • CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

  • WHEN 'IVBAP-MATNR'.

  • SET PARAMETER ID 'MAT' FIELD IVBAP-MATNR.

  • CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

*ENDCASE.

*ENDCASE.

*ENDFORM.

*******Process Call Back Events (End)*****************************

**********FORM ROUTINES (END)*************************************

Regds,

Rama.Pammi