OO ALV USING DOCKING CONTAINER & COLORING ROWS BASED ON CONDITION


*coloring particular rows in alv on condition*

TYPE-POOLS : col.
TYPES BEGIN OF tab,
carrid     TYPE sflight-carrid,
connid     TYPE sflight-connid,
fldate     TYPE sflight-fldate,
price      TYPE sflight-price,
seatsmax   TYPE sflight-seatsmax,
seatsocc   TYPE sflight-seatsocc,
color(4),
END OF   tab.

DATA : it_flight   TYPE TABLE OF tab,
wa_flight   TYPE tab,
ok_code     TYPE syst-ucomm,
o_alv       TYPE REF TO cl_gui_alv_grid,
o_dock      TYPE REF TO cl_gui_docking_container,
is_layo     TYPE lvc_s_layo,
it_fcat     TYPE lvc_t_fcat,
is_fcat     TYPE lvc_s_fcat.

START-OF-SELECTION.
PERFORM data_fetch.
PERFORM build_fieldcatalog.
PERFORM build_layout.

END-OF-SELECTION.
CALL SCREEN 100.
*————————————————————-*
FORM data_fetch .
SELECT carrid
connid
fldate
price
seatsmax  seatsocc FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_flight.

CONCATENATE ‘C’ col_group ’10’ INTO wa_flight-color.
MODIFY it_flight FROM wa_flight TRANSPORTING color WHERE price > 5000.
ENDFORM.                    ” DATA_FETCH

*————————————————————*
FORM build_fieldcatalog .
is_fcat-col_pos = 1.
is_fcat-fieldname = ‘CARRID’.
is_fcat-tabname = ‘IT_FLIGHT’.
is_fcat-key = ‘X’.
APPEND is_fcat TO it_fcat.
CLEAR is_fcat.

is_fcat-col_pos = 1.
is_fcat-fieldname = ‘CONNID’.
is_fcat-tabname = ‘IT_FLIGHT’.
is_fcat-key = ‘X’.
APPEND is_fcat TO it_fcat.
CLEAR is_fcat.

is_fcat-col_pos = 3.
is_fcat-fieldname = ‘FLDATE’.
is_fcat-tabname = ‘IT_FLIGHT’.
is_fcat-key = ‘X’.
APPEND is_fcat TO it_fcat.
CLEAR is_fcat.

is_fcat-col_pos = 4.
is_fcat-fieldname = ‘PRICE’.
is_fcat-tabname = ‘IT_FLIGHT’.
APPEND is_fcat TO it_fcat.
CLEAR is_fcat.

is_fcat-col_pos = 5.
is_fcat-fieldname = ‘SEATSMAX’.
is_fcat-tabname = ‘IT_FLIGHT’.
APPEND is_fcat TO it_fcat.
CLEAR is_fcat.

is_fcat-col_pos = 6.
is_fcat-fieldname = ‘SEATSOCC’.
is_fcat-tabname = ‘IT_FLIGHT’.
APPEND is_fcat TO it_fcat.
CLEAR is_fcat.

ENDFORM.                    ” BUILD_FIELDCATALOG

*———————————————————–*
FORM build_layout .
is_layo-info_fname = ‘COLOR’.
ENDFORM.                    ” BUILD_LAYOUT
*————————————————————*
MODULE status_0100 OUTPUT.
SET PF-STATUS ‘STATUS’.
*  SET TITLEBAR ‘xxx’.

ENDMODULE.                 ” STATUS_0100  OUTPUT

*———————————————————-*
MODULE display_alv OUTPUT.
IF o_dock IS NOT BOUND.
CREATE OBJECT o_dock
EXPORTING
side      = cl_gui_docking_container=>dock_at_left
extension = 500.
ENDIF.

if o_alv is not bound.
CREATE OBJECT o_alv
EXPORTING
i_parent          = o_dock.
CALL METHOD o_alv->set_table_for_first_display
EXPORTING
is_layout                     = is_layo
CHANGING
it_outtab                     = it_flight
it_fieldcatalog               = it_fcat.
endif.
ENDMODULE.                 ” DISPLAY_ALV  OUTPUT
*———————————————————–*
MODULE user_command_0100 INPUT.
CASE  ok_code.
WHEN ‘BACK’ OR ‘EXIT’ OR ‘CANCEL’.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.                 ” USER_COMMAND_0100  INPUT

*————————————————————-*

SCREEN 100 FLOW LOGIC

  PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE display_alv.

PROCESS AFTER INPUT.
MODULE user_command_0100.

*————————————————————-*


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s