Wednesday, July 29, 2009

Important function modules related to dates

HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months

WEEK_GET_FIRST_DAY : Get the first day of the week

FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.

DATE_TO_DAY : Returns the Day for the entered date.

Color single row in ALV

REPORT z_alv_color.

TYPE-POOLS: slis.

DATA: BEGIN OF it_flight OCCURS 0,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
seatsmax LIKE sflight-seatsmax,
seatsocc LIKE sflight-seatsocc,
color(4),
END OF it_flight.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
layout TYPE slis_layout_alv.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'IT_FLIGHT'
i_inclname = sy-repid
CHANGING
ct_fieldcat = it_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.

SELECT carrid
connid
fldate
seatsmax
seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_flight
UP TO 20 ROWS.
*-conditionally populate the color
LOOP AT it_flight.

IF it_flight-seatsocc eq 0.
it_flight-color = 'C600'.
ENDIF.
MODIFY it_flight.
ENDLOOP.
*-Pass the color field information to layout
layout-info_fieldname = 'COLOR'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = layout
it_fieldcat = it_fieldcat
TABLES
t_outtab = it_flight
EXCEPTIONS
program_error = 1.