*&---------------------------------------------------------------------*
*& 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
Friday, November 23, 2007
sap abap program for Use Simple ALV Functions to Make Reporting Easy
Labels:
ALV sample programs
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment