In this post we use some basics Events and Control Break Statements for Generating Classical Report Based On single Table.
* Local Structure
TYPES : BEGIN OF TY_MARA,
MATNR TYPE MATNR,
ERSDA TYPE ERSDA,
MTART TYPE MTART,
MATKL TYPE MATKL,
END OF TY_MARA.
* Define Work Area And Internal Table
DATA : GS_MARA TYPE TY_MARA,
GT_MARA LIKE STANDARD TABLE OF GS_MARA.
* Selection Screen For Material Code AS a Input
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_MATNR FOR MARA-MATNR OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
*Define Class Definition
CLASS CLASSICAL_RPT DEFINITION.
PUBLIC SECTION.
* Define Two Methods (Get_data and Display_data) Under Public Section
METHODS : GET_DATA IMPORTING I_MATNR TYPE STANDARD TABLE
CHANGING I_MARA TYPE STANDARD TABLE,
DISPLAY_DATA IMPORTING IT_MARA TYPE STANDARD TABLE.
ENDCLASS.
* Implementation of Above Defined Class And Methods
CLASS CLASSICAL_RPT IMPLEMENTATION.
METHOD GET_DATA.
SELECT MATNR
ERSDA
MTART
MATKL FROM MARA INTO TABLE I_MARA WHERE MATNR IN S_MATNR.
ENDMETHOD.
METHOD DISPLAY_DATA.
LOOP AT IT_MARA INTO GS_MARA.
* at First Control Break Statements
AT FIRST .
WRITE: / 'Material No.' COLOR 5,20 'Created on' COLOR 7,40 'Type' COLOR 7,50 'Material Group' COLOR 7.
* Uline For Under line
ULINE.
SKIP.
ENDAT.
WRITE : / GS_MARA-MATNR,20 GS_MARA-ERSDA,40 GS_MARA-MTART,50 GS_MARA-MATKL.
* at last Control Break Statements
AT LAST.
ULINE.
WRITE :25 '----* END-OF-MATERIAL *----' .
ENDAT.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
* Start-of-Selection Events
START-OF-SELECTION.
DATA : OBJ TYPE REF TO CLASSICAL_RPT.
* Call Method ANd Export Parameters To The Called Method
CALL METHOD OBJ->GET_DATA EXPORTING I_MATNR = S_MATNR[]
CHANGING I_MARA = GT_MARA.
IF GT_MARA IS NOT INITIAL.
CALL METHOD OBJ->DISPLAY_DATA EXPORTING IT_MARA = GT_MARA.
ENDIF.
* Top-of-page events
TOP-OF-PAGE.
WRITE : SY-ULINE.
WRITE : 'Material Master Details'.
WRITE : SY-DATUM.
WRITE : SY-ULINE.
SKIP.
If You want some Basic Knowledge About Events and Control Break Statements then must Visit on This Post Events in ABAP Report and Control Break Statements
Example -
*&---------------------------------------------------------------------*
*& Report ZWEB
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
* Classical Report of Single Table
REPORT ZWEB NO STANDARD PAGE HEADING LINE-SIZE 90.
TABLES : MARA .
*& Report ZWEB
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
* Classical Report of Single Table
REPORT ZWEB NO STANDARD PAGE HEADING LINE-SIZE 90.
TABLES : MARA .
* Local Structure
TYPES : BEGIN OF TY_MARA,
MATNR TYPE MATNR,
ERSDA TYPE ERSDA,
MTART TYPE MTART,
MATKL TYPE MATKL,
END OF TY_MARA.
* Define Work Area And Internal Table
DATA : GS_MARA TYPE TY_MARA,
GT_MARA LIKE STANDARD TABLE OF GS_MARA.
* Selection Screen For Material Code AS a Input
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_MATNR FOR MARA-MATNR OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
*Define Class Definition
CLASS CLASSICAL_RPT DEFINITION.
PUBLIC SECTION.
* Define Two Methods (Get_data and Display_data) Under Public Section
METHODS : GET_DATA IMPORTING I_MATNR TYPE STANDARD TABLE
CHANGING I_MARA TYPE STANDARD TABLE,
DISPLAY_DATA IMPORTING IT_MARA TYPE STANDARD TABLE.
ENDCLASS.
* Implementation of Above Defined Class And Methods
CLASS CLASSICAL_RPT IMPLEMENTATION.
METHOD GET_DATA.
SELECT MATNR
ERSDA
MTART
MATKL FROM MARA INTO TABLE I_MARA WHERE MATNR IN S_MATNR.
ENDMETHOD.
METHOD DISPLAY_DATA.
LOOP AT IT_MARA INTO GS_MARA.
* at First Control Break Statements
AT FIRST .
WRITE: / 'Material No.' COLOR 5,20 'Created on' COLOR 7,40 'Type' COLOR 7,50 'Material Group' COLOR 7.
* Uline For Under line
ULINE.
SKIP.
ENDAT.
WRITE : / GS_MARA-MATNR,20 GS_MARA-ERSDA,40 GS_MARA-MTART,50 GS_MARA-MATKL.
* at last Control Break Statements
AT LAST.
ULINE.
WRITE :25 '----* END-OF-MATERIAL *----' .
ENDAT.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
* Start-of-Selection Events
START-OF-SELECTION.
DATA : OBJ TYPE REF TO CLASSICAL_RPT.
* Create Object OF CLASSICAL_RPT Class
CREATE OBJECT OBJ.
CREATE OBJECT OBJ.
* Call Method ANd Export Parameters To The Called Method
CALL METHOD OBJ->GET_DATA EXPORTING I_MATNR = S_MATNR[]
CHANGING I_MARA = GT_MARA.
IF GT_MARA IS NOT INITIAL.
CALL METHOD OBJ->DISPLAY_DATA EXPORTING IT_MARA = GT_MARA.
ENDIF.
* Top-of-page events
TOP-OF-PAGE.
WRITE : SY-ULINE.
WRITE : 'Material Master Details'.
WRITE : SY-DATUM.
WRITE : SY-ULINE.
SKIP.
Selection-Screen :-
Output: