*&---------------------------------------------------------------------*
*& Report ZBC_ALV_EXAMPLE *
*& *
*&---------------------------------------------------------------------*
* This program explains how we can use simple ALV functions to make *
* reporting easy and looks pretty
************************************************************************
* Programmer : Venkat Reddy ETA *
* Date : 10/02/04 *
************************************************************************
* Maintenance Log *
*----------------------------------------------------------------------*
* Changed By Date Transport# Description *
*------------ ---------------------------------------------------------*
* Venkat Reddy 10/02/04 EGD913575 Changed program to avoid *
*----------------------------------------------------------------------*
REPORT ZBC_ALV_EXAMPLE.
************************************************************************
* D-A-T-A D-E-C-L-A-R-A-T-I-O-N-S *
************************************************************************
tables: sflight.
**-- TYPE-POOLS Definition
**Includes the types and constants of a type group. Since the types and
*constants specified in a type group have global validity, you cannot
*use the statement within a FORM or FUNCTION.
type-pools: slis.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
**-- ALV variables
*****- Field Catalog structure
data: ls_fieldcat type slis_fieldcat_alv, "Field Catalog list
**--- Field Catalog table
gt_fieldcat type slis_t_fieldcat_alv, "Field Catalog
**--- Layout ( How you would like to see the output )
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.
************************************************************************
* C-O-N-S-T-A-N-T-S *
************************************************************************
************************************************************************
* S-E-L-E-C-T-I-O-N S-C-R-E-E-N *
************************************************************************
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 default sy-datum.
selection-screen end of block a .
************************************************************************
* I-N-I-T-I-A-L-I-Z-A-T-I-O-N *
************************************************************************
initialization.
g_repid = sy-repid.
**-- Fill ALV field catalog
perform initialize_fieldcat using gt_fieldcat[].
***-- Build Events
* perform build_eventtab using gt_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.
*======================================================================*
* FORMS / SUB ROUTINES *
*======================================================================
*&---------------------------------------------------------------------*
*& Form initialize_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_FIELDCAT[] text
*----------------------------------------------------------------------*
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
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
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
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM dislay_alv_report .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'sflight'
* IS_LAYOUT =
IT_FIELDCAT = gt_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = GX_VARIANT
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = lt_sflight
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
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
Thursday, February 12, 2009
sap abap program for Use Simple ALV Functions to Make Reporting Easy
Labels:
ALV Sample Programs
Subscribe to:
Post Comments (Atom)
Archives
-
▼
2009
(86)
-
▼
February
(58)
- Vb codes (or VBA macro code) for access SAP, and r...
- An Introduction to SAP
- sap abap program for Upload Logo for REUSE_ALV_COM...
- What is SLIS in sap abap ALV
- How to Refresh ALV List/Grid once it is displayed?
- sap abap ALV 'Classic' Creating User/Global Layout...
- How to use ALV for Hierarchical Lists
- sap abap program for Sample ALV: Heading in ALV
- sap abap program for Test ALV Display With Header ...
- Sample programs on sap abap ALV Grid
- what is abap REUSE_ALV_GRID_DISPLAY Functions Example
- Display a Secondary List using ALV Grid
- sap abap program for Line Color in ALV Example
- sap abap program for How to make ALV header like t...
- sap abap program for Use Simple ALV Functions to M...
- sap abap ALV Reporting - Z_LIST_MATERIALS
- sap abap program for Reincarnation of REUSE_ALV_FI...
- ALV Reporting - REUSE_ALV_BLOCK_LIST_DISPLAY
- sap abap program for An Interactive ALV Report
- sap abap program for Example of a Simple ALV Grid ...
- ABAP Example Program ALV Grid Control
- What Are The Events In abap ALV
- abap program for Creation Of Active Icon
- using alv grid real time implementation
- Adding custom buttons on ALV grid controls
- SAP free download book on ALV grid Control Tutorial
- SAP Highlighting only a particular cell instead of...
- SAP ALV - Details of Y/Z objects with lists of use...
- SAP ALV report to find the list of infotypes confi...
- SAP ALV Report using REUSE
- ALV ABAP List Viewer
- What is ALV Programming in sap abap?
- SAP ALV Function Modules
- All the SAP Online Help in PDFs
- All the SAP Online Help in PDFs A-C
- All the SAP Online Help in PDFs D-M
- All the SAP Online Help in PDFs N-S
- All the SAP Online Help in PDFs T-Z
- PDF freedownloads for all module books
- PDF free download ALE Programming Guide
- PDF free download ALE Programming Guide
- ABAP ALE Tutorials PDF Free downloads
- PDF Free Download Advance Payments
- Adding additional fields to Delivery Due List
- PDF Free Download Actual Costing / Material Ledger
- PDF Book free download activity-Based Costing
- Free Download Activity-Based Costing CO-OM-ABC
- SAP Activity-Based Costing pdf free download
- SAP Activities/Strategies in FI
- SAP ABAP program OR implementation: Accounting Doc...
- Accessing BAPI using VB PPT free download
- SAP ABAP4 Tuning Checklist
- sap abap/4 sample codes
- SAP ABAP/4 programming language overview
- SAP ABAP/4 Optimization Techniques
- ABAP/4 OLE Automation Controller pdf book free dow...
- ABAP/4 OLE Automation Controller pdf free download
- Questions and Answers about ABAP/4 and Developments
-
▼
February
(58)
No comments:
Post a Comment