Professional Documents
Culture Documents
* select flights data from SFLIGHT; get no. of selected flights and related
* SPFLI record; calculate total PaymentSum of selected flights
CALL FUNCTION 'ZCFM1_00_MB'
EXPORTING
iv_carrid
= p_carrid
iv_connid
= p_connid
IMPORTING
et_sflight
= gt_sflight
es_spfli
= gs_spfli
es_scarr
= gs_scarr
ev_records
= gv_records
ev_sum
= gv_sum
EXCEPTIONS
no_data
= 1
carrid_not_found = 2
connid_not_found = 3
negative_sum
= 4
OTHERS
= 5.
IF sy-subrc = 0.
SORT gt_sflight BY carrid connid fldate.
ELSE.
MESSAGE 'Error selecting flights data' TYPE 'E'.
ENDIF.
ENDFORM.
" SELECT_DATA
*&---------------------------------------------------------------------*
*&
Form OUTPUT_DATA
*&---------------------------------------------------------------------*
*&
Output selected data using an ALV GRID tool
*&---------------------------------------------------------------------*
FORM output_data.
*** Data Declaration for ALV GRID **************************************
**
*
*
*
*
TYPE lvc_title.
list display
(LT_SORT[]), the caller determines the sort order an
basic list.
slis_t_sortinfo_alv.
" OUTPUT_DATA
*&---------------------------------------------------------------------*
*&
Form PREPARE_LAYOUT
*&---------------------------------------------------------------------*
*
Prepare Layout specifications for ALV GRID
*----------------------------------------------------------------------*
FORM prepare_layout CHANGING cs_layout TYPE slis_layout_alv. .
** Display options
* Optimize the column width to ensure that the content is displayed completely
cs_layout-colwidth_optimize = gc_on.
* Striped pattern
cs_layout-zebra
= gc_on.
** Totals
* Calculating subtotals is allowed
cs_layout-no_subtotals
= gc_off.
** Other
* Input not allowed
cs_layout-no_input
= gc_on.
ENDFORM.
" PREPARE_LAYOUT
*&---------------------------------------------------------------------*
*&
Form PREPARE_ALV_FCAT
*&---------------------------------------------------------------------*
*
Prepare Field Catalog for ALV GRID
*----------------------------------------------------------------------*
FORM prepare_alv_fcat CHANGING ct_fcat TYPE slis_t_fieldcat_alv.
** Set output attributes for each Field/Column of the ALV GRID
*
* Structure used to assign output attributes to a field of internal table
* containting data to be displayed
DATA ls_fcat
TYPE slis_fieldcat_alv.
** Set output attributes for field SFLIGHT-CARRID
CLEAR ls_fcat.
* Identification component (FIELDNAME) in the output attributes structure
ls_fcat-fieldname
= 'CARRID'.
* Reference to the Data Dictionary - name of a structure or table in the Data
Dictionary
ls_fcat-ref_tabname = 'SFLIGHT'.
* Reference to the Data Dictionary - name of a field in the Data Dictionary
ls_fcat-ref_fieldname = 'CARRID'.
* Key (Key column)
ls_fcat-key
= gc_on.
* Store output attributes for current field in the Field Catalog Internal Tabl
e
APPEND ls_fcat TO ct_fcat.
** Set output attributes for field SFLIGHT-CONNID
CLEAR ls_fcat.
ls_fcat-fieldname
= 'CONNID'.
ls_fcat-ref_tabname = 'SFLIGHT'.
ls_fcat-ref_fieldname = 'CONNID'.
ls_fcat-key
= gc_on.
APPEND ls_fcat TO ct_fcat.
** Set output attributes for field SFLIGHT-FLDATE
CLEAR ls_fcat.
ls_fcat-fieldname
= 'FLDATE'.
ls_fcat-ref_tabname = 'SFLIGHT'.
ls_fcat-ref_fieldname = 'FLDATE'.
ls_fcat-key
= gc_on.
APPEND ls_fcat TO ct_fcat.
** Set output attributes for field SFLIGHT-PRICE
CLEAR ls_fcat.
ls_fcat-fieldname
= 'PRICE'.
ls_fcat-ref_tabname = 'SFLIGHT'.
ls_fcat-ref_fieldname = 'PRICE'.
* Reference to the Currency Unit: relevant to amount columns with unit reference
.
ls_fcat-cfieldname
= 'CURRENCY'.
* Parameters for texts
ls_fcat-seltext_s
= 'Tick.Price'(g01).
"(short field label)
ls_fcat-seltext_m
= 'Tick.Price'(g01).
"(medium field label)
ls_fcat-seltext_l
= 'Tick.Price'(g01).
"(long field label)
ls_fcat-reptext_ddic = 'Tick.Price'(g01).
APPEND ls_fcat TO ct_fcat.
"(heading)
" PREPARE_ALV_FCAT
*&---------------------------------------------------------------------*
*&
Form PREPARE_SORT_CRITERIA
*&---------------------------------------------------------------------*
*
Set the sort order
*----------------------------------------------------------------------*
FORM prepare_sort_criteria CHANGING ct_sort TYPE slis_t_sortinfo_alv.
** Set sort attributes for specific fields of ALV GRID Field Catalog
*
*
= 'CONNID'.
= 2.
= gc_on.
ct_sort.
CLEAR ls_sort.
ls_sort-fieldname
ls_sort-spos
ls_sort-down
APPEND ls_sort TO
= 'SEATSOCC'.
= 3.
= gc_on.
ct_sort.
ENDFORM.
" PREPARE_SORT_CRITERIA
*&---------------------------------------------------------------------*
*&
Form TOP_OF_PAGE_FORM
*&---------------------------------------------------------------------*
*
EXIT routine for handling TOP-OF-PAGE
*----------------------------------------------------------------------*
FORM top_of_page_form.
"#EC CALLED
** Set data in Top Of Page of ALV GRID
*
*
" TOP_OF_PAGE_FORM