tables: sflight.
type-pools: slis.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
data: ls_fieldcat type slis_fieldcat_alv, "Field Catalog list
gt_fieldcat type slis_t_fieldcat_alv, "Field Catalog
gs_layout type slis_layout_alv, "List Layout
**-- Report name
g_repid like sy-repid,
g_save(1) type c,
g_exit(1) type c,
g_variant like disvariant,
gx_variant like disvariant.
**-- Flight Info Internal table
data: lt_sflight like sflight occurs 0 with header line.
selection-screen begin of block a with frame title text-100.
select-options: s_carrid for sflight-carrid,
s_connid for sflight-connid,
s_fldate for sflight-fldate .
selection-screen end of block a .
initialization.
g_repid = sy-repid.
**-- Fill ALV field catalog
perform initialize_fieldcat using gt_fieldcat[].
***-- Build Events
**-- Read the default variant
perform initialize_variant.
************************************************************************
* A-T S-E-L-E-C-T-I-O-N S-C-R-E-E-N *
************************************************************************
at selection-screen on value-request for p_vari.
**-- Display all existing variants
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = g_variant
i_save = g_save
importing
e_exit = g_exit
es_variant = gx_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 g_exit = space.
p_vari = gx_variant-variant.
endif.
endif.
************************************************************************
* S-T-A-R-T O-F S-E-L-E-C-T-I-O-N *
************************************************************************
start-of-selection.
**-- Read Flight information.
perform read_flight_info.
**-- Fill ALV field catalog and display report.
if not lt_sflight[] is initial.
perform dislay_alv_report.
endif.
*&---------------------------------------------------------------------*
*& Form initialize_fieldcat
*----------------------------------------------------------------------*
form initialize_fieldcat using l_fieldcat type slis_t_fieldcat_alv.
clear ls_fieldcat.
* Air line
ls_fieldcat-fieldname = 'CARRID'.
ls_fieldcat-key = 'X'.
ls_fieldcat-col_pos = 1.
ls_fieldcat-seltext_s = 'Airline'.
ls_fieldcat-seltext_l = 'Airline'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Flight Number
ls_fieldcat-fieldname = 'CONNID'.
ls_fieldcat-key = 'X'.
ls_fieldcat-col_pos = 2.
ls_fieldcat-seltext_s = 'Flight Number'.
ls_fieldcat-seltext_l = 'Flight Number'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Flight date
ls_fieldcat-fieldname = 'FLDATE'.
ls_fieldcat-key = 'X'.
ls_fieldcat-col_pos = 3.
ls_fieldcat-seltext_s = 'Flight date'.
ls_fieldcat-seltext_l = 'Flight date'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Airfare
ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-col_pos = 4.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-seltext_s = 'Airfare'.
ls_fieldcat-seltext_l = 'Airfare'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Local Currency
ls_fieldcat-fieldname = 'CURRENCY'.
ls_fieldcat-col_pos = 5.
ls_fieldcat-seltext_s = 'Local Currency'.
ls_fieldcat-seltext_l = 'Local Currency'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Plane Type
ls_fieldcat-fieldname = 'PLANETYPE'.
ls_fieldcat-col_pos = 6.
ls_fieldcat-seltext_s = 'Plane type'.
ls_fieldcat-seltext_l = 'Plane type'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Maximum capacity
ls_fieldcat-fieldname = 'SEATSMAX'.
ls_fieldcat-col_pos = 7.
ls_fieldcat-seltext_s = 'Max. seats'.
ls_fieldcat-seltext_l = 'Max. seats'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Occupied seats
ls_fieldcat-fieldname = 'SEATSOCC'.
ls_fieldcat-col_pos = 8.
ls_fieldcat-seltext_s = 'Seats occupied'.
ls_fieldcat-seltext_l = 'Seats occupied'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Total
ls_fieldcat-fieldname = 'PAYMENTSUM'.
ls_fieldcat-col_pos = 9.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-seltext_s = 'Total amount'.
ls_fieldcat-seltext_l = 'Total amount'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Total
ls_fieldcat-fieldname = 'PAYMENTSUM'.
ls_fieldcat-col_pos = 9.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-seltext_s = 'Total amount'.
ls_fieldcat-seltext_l = 'Total amount'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Max. Capacity, Buss. Class
ls_fieldcat-fieldname = 'SEATSMAX_B'.
ls_fieldcat-col_pos = 10.
ls_fieldcat-seltext_s = 'Max.Buss.class cap.'.
ls_fieldcat-seltext_l = 'Max.Buss.class cap.'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Max. occupancy, Buss. Class
ls_fieldcat-fieldname = 'SEATSOCC_B'.
ls_fieldcat-col_pos = 11.
ls_fieldcat-seltext_s = 'Max.Bus.CL.occupied'.
ls_fieldcat-seltext_l = 'Max.Bus.CL.occupied'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Max. Capacity, First. Class
ls_fieldcat-fieldname = 'SEATSMAX_F'.
ls_fieldcat-col_pos = 12.
ls_fieldcat-seltext_s = 'Max.Buss.class cap.'.
ls_fieldcat-seltext_l = 'Max.Buss.class cap.'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Max. occupancy, First. Class
ls_fieldcat-fieldname = 'SEATSOCC_F'.
ls_fieldcat-col_pos = 13.
ls_fieldcat-seltext_s = 'Max.Bus.CL.occupied'.
ls_fieldcat-seltext_l = 'Max.Bus.CL.occupied'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
ENDFORM. " initialize_fieldcat
*&---------------------------------------------------------------------*
*& Form read_flight_info
*----------------------------------------------------------------------*
FORM read_flight_info .
refresh lt_sflight.
clear lt_sflight.
**-- Read data from SFLIGHT table
select *
from SFLIGHT
into table lt_sflight
where carrid in s_carrid
and connid in s_connid
and fldate in s_fldate.
if sy-subrc <> 0.
message e208(00) with text-101.
endif.
ENDFORM. " read_flight_info
*&---------------------------------------------------------------------*
*& Form dislay_alv_report
*----------------------------------------------------------------------*
FORM dislay_alv_report .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = g_repid
I_STRUCTURE_NAME = 'sflight'
IT_FIELDCAT = gt_fieldcat
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = GX_VARIANT
TABLES
T_OUTTAB = lt_sflight .
ENDFORM. " dislay_alv_report
*&---------------------------------------------------------------------*
*& Form initialize_variant
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------*
FORM initialize_variant .
g_save = 'A'.
clear g_variant.
g_variant-report = g_repid.
gx_variant = g_variant.
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
exporting
i_save = g_save
changing
cs_variant = gx_variant
exceptions
not_found = 2.
if sy-subrc = 0.
p_vari = gx_variant-variant.
endif.
ENDFORM. " initialize_variant
ALSO READ:
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
No comments:
Post a Comment