Wednesday, December 4, 2013

ZRDEMO_COLORING_ALV_ROWS_7AM

*&---------------------------------------------------------------------*
*& Module pool       ZRDEMO_COLORING_ALV_ROWS_7AM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

PROGRAM  ZRDEMO_COLORING_ALV_ROWS_7AM.

DATA : O_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
       O_GRID     TYPE REF TO CL_GUI_ALV_GRID.

TYPES  BEGIN OF TY_T001.
       INCLUDE STRUCTURE T001.
TYPES: COLOR_LINE(4) TYPE C,
       END OF TY_T001.
DATA : WA_T001 TYPE TY_T001,
       IT_T001 TYPE TABLE OF TY_T001.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS 'ZSTATUS'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
IF SY-UCOMM = 'BACK'.
    LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*
*&      Module  READ_DATA  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE READ_DATA OUTPUT.

SELECT * INTO TABLE IT_T001 FROM T001 UP TO 20 ROWS.
ENDMODULE.                 " READ_DATA  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  DISPLAY_DATA  OUTPUT
*&---------------------------------------------------------------------*
MODULE DISPLAY_DATA OUTPUT.
data WA_LAYOUT TYPE LVC_S_LAYO.

*CREATE CONTAINER OBJ
create object O_CONTAINER
  exporting

    CONTAINER_NAME              = 'CONTAINER'
    .
if SY-SUBRC = 0.
*CREATE GRID OBJ
create object O_GRID
  exporting

    I_PARENT          = O_CONTAINER

    .
if SY-SUBRC = 0.
WA_LAYOUT-INFO_FNAME = 'COLOR_LINE'.

LOOP AT IT_T001 INTO WA_T001.
    CASE WA_T001-LAND1.
        WHEN 'IN'.
              WA_T001-COLOR_LINE = 'C111'.
        WHEN 'DE'.
              WA_T001-COLOR_LINE = 'C511'.
        WHEN 'US'.
              WA_T001-COLOR_LINE = 'C311'.
     ENDCASE.
     MODIFY  IT_T001 FROM WA_T001 TRANSPORTING COLOR_LINE.
     CLEAR WA_T001.
ENDLOOP.

call method O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
  EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
    I_STRUCTURE_NAME              = 'T001'
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
    IS_LAYOUT                     = wa_layout
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
*    IR_SALV_ADAPTER               =
  changing
    IT_OUTTAB                     = IT_T001
*    IT_FIELDCATALOG               =
*    IT_SORT                       =
*    IT_FILTER                     =
*  EXCEPTIONS
*    INVALID_PARAMETER_COMBINATION = 1
*    PROGRAM_ERROR                 = 2
*    TOO_MANY_LINES                = 3
*    others                        = 4
        .
if SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

endif.


endif.


ENDMODULE.                 " DISPLAY_DATA  OUTPUT

No comments: