- SAP ABAP Reports
- Report Types and Events
- Message Class
- Example of Classical Report
- Example of Interactive Report
- Example of ALV Report
- Example of Blocked ALV Report
- Example of Hierarchical Report
- Module Pool Programming
- Screen Painter Components
- Events in Flow Logic Editor
- Screen Elements and Creation Steps
- Working with Validations
- Database Operations
- OO Programming in ABAP
- Types of Programming Structure
- Key Features of OO Programming
- Classes and Objects
- Types of Visibility Section
- Class Defination and Implementation
- Object Creation for Class
- Method Declaration and Implementation
- Types of Component Class
- Global Class and implement GLOBAL methods
- OOP's ALV
- OOP's BDC
24REPORT1708 – Blocked ALV Report Example
*&———————————————————————*
*& Report ZBLOCK_ALV_REPORT
*&———————————————————————*
*&
*&———————————————————————*
REPORT ZBLOCK_ALV_REPORT.
TABLES : EKKO, EKPO, LFA1.
TYPES : BEGIN OF GTY_EKKO,
EBELN TYPE EBELN,
LIFNR TYPE LIFNR,
BUKRS TYPE BUKRS,
END OF GTY_EKKO.
DATA : IT_EKKO TYPE STANDARD TABLE OF GTY_EKKO,
GT_EKKO TYPE GTY_EKKO.
TYPES : BEGIN OF GTY_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
TXZ01 TYPE TXZ01,
MATNR TYPE MATNR,
MENGE TYPE MENGE,
MEINS TYPE MEINS,
NETWR TYPE NETWR,
END OF GTY_EKPO.
DATA : GT_EKPO TYPE STANDARD TABLE OF GTY_EKPO,
GS_EKPO TYPE GTY_EKPO.
TYPES : BEGIN OF GTY_LFA1,
LIFNR TYPE LIFNR,
NAME1 TYPE NAME1,
END OF GTY_LFA1.
DATA : GT_LFA1 TYPE STANDARD TABLE OF GTY_LFA1,
GS_LFA1 TYPE GTY_LFA1.
DATA : GT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_FCAT TYPE SLIS_FIELDCAT_ALV,
GT_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,
GS_FCAT1 TYPE SLIS_FIELDCAT_ALV,
GT_FCAT2 TYPE SLIS_T_FIELDCAT_ALV,
GS_FCAT2 TYPE SLIS_FIELDCAT_ALV,
GT_EVENTS TYPE SLIS_T_EVENT,
GS_KEYINFO TYPE SLIS_KEYINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
hdr_cnt TYPE i,
itm_cnt TYPE i,
vend_cnt TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT–001.
SELECT-OPTIONS : S_EBELN FOR EKKO–EBELN,
S_LIFNR FOR EKKO–LIFNR,
S_BUKRS FOR EKKO–BUKRS.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM GET_BUILD_DATA.
END-OF-SELECTION.
*&———————————————————————*
*& Form get_build_data
*&———————————————————————*
*& text
*&———————————————————————*
*& –> p1 text
*& <– p2 text
*&———————————————————————*
FORM GET_BUILD_DATA.
“PO HEADER DATA
SELECT EBELN, BUKRS, LIFNR, RLWRT
FROM EKKO INTO TABLE @DATA(GT_EKKO)
WHERE EBELN IN @S_EBELN
AND BUKRS IN @S_BUKRS
AND LIFNR IN @S_LIFNR.
IF GT_EKKO[] IS NOT INITIAL.
SORT GT_EKKO BY LIFNR.
“NAME OF VENDOR
SELECT LIFNR, NAME1
FROM LFA1 INTO TABLE @DATA(GT_LFA1)
FOR ALL ENTRIES IN @GT_EKKO WHERE LIFNR = @GT_EKKO–LIFNR.
SORT GT_EKKO BY EBELN.
“PO LINE ITEM
SELECT EBELN, EBELP, TXZ01, MATNR, MENGE, MEINS, NETWR
FROM EKPO INTO TABLE @DATA(GT_EKPO)
FOR ALL ENTRIES IN @GT_EKKO WHERE EBELN = @GT_EKKO–EBELN.
SORT GT_LFA1 BY LIFNR.
SORT GT_EKKO BY LIFNR EBELN.
SORT GT_EKPO BY EBELN EBELP.
******************************************************************************
CLEAR : GT_FCAT[], GT_FCAT1[], GT_FCAT2[], GS_FCAT, GS_LAYOUT, GS_KEYINFO.
*”PO header
GS_FCAT–COL_POS = ‘1’.
GS_FCAT–FIELDNAME = ‘EBELN’.
GS_FCAT–TABNAME = ‘GT_EKKO’.
GS_FCAT–SELTEXT_L = ‘PO_NUMBER’.
APPEND GS_FCAT TO GT_FCAT.
CLEAR : GS_FCAT.
GS_FCAT–COL_POS = ‘3’.
GS_FCAT–FIELDNAME = ‘LIFNR’.
GS_FCAT–TABNAME = ‘GT_EKKO’.
GS_FCAT–SELTEXT_L = ‘Vendor ID’.
APPEND GS_FCAT TO GT_FCAT.
CLEAR : GS_FCAT.
*”Vendor
GS_FCAT–COL_POS = ‘4’.
GS_FCAT1–FIELDNAME = ‘LIFNR’.
GS_FCAT1–SELTEXT_L = ‘Vendor ID’.
APPEND GS_FCAT1 TO GT_FCAT1.
CLEAR : GS_FCAT1.
GS_FCAT–COL_POS = ‘5’.
GS_FCAT1–FIELDNAME = ‘NAME1’.
GS_FCAT1–SELTEXT_L = ‘Vendor Name’.
APPEND GS_FCAT1 TO GT_FCAT1.
CLEAR: GS_FCAT1.
*”PO line items
GS_FCAT–COL_POS = ‘6’.
GS_FCAT2–FIELDNAME = ‘EBELN’.
GS_FCAT2–SELTEXT_L = ‘PO Number’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ‘7’.
GS_FCAT2–FIELDNAME = ‘EBELP’.
GS_FCAT2–SELTEXT_L = ‘PO Line Item’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ‘8’.
GS_FCAT2–FIELDNAME = ‘MATNR’.
GS_FCAT2–SELTEXT_L = ‘Material ID’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ‘9’.
GS_FCAT2–FIELDNAME = ‘TXZ01’.
GS_FCAT2–SELTEXT_L = ‘Material Description’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR: GS_FCAT2.
GS_FCAT–COL_POS = ’10’.
GS_FCAT2–FIELDNAME = ‘MENGE’.
GS_FCAT2–SELTEXT_L = ‘ORDER QTY’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ’11’.
GS_FCAT2–FIELDNAME = ‘MEINS’.
GS_FCAT2–SELTEXT_L = ‘UOM’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ’12’.
GS_FCAT2–FIELDNAME = ‘NETWR’.
GS_FCAT2–SELTEXT_L = ‘Item PO Value’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
******************************************************************************
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_INIT’
EXPORTING
i_callback_program = sy–repid
* I_CALLBACK_PF_STATUS_SET = ‘ ‘
* I_CALLBACK_USER_COMMAND = ‘ ‘
* IT_EXCLUDING =
.
“Vendor data
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fcat1
i_tabname = ‘GT_LFA1’
it_events = gt_events
* IT_SORT =
* I_TEXT = ‘ ‘
TABLES
t_outtab = gt_lfa1
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.
“PO header
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fcat
i_tabname = ‘GT_EKKO’
it_events = gt_events
* IT_SORT =
* I_TEXT = ‘ ‘
TABLES
t_outtab = gt_ekko
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.
“PO line items
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fcat2
i_tabname = ‘GT_EKPO’
it_events = gt_events
* IT_SORT =
* I_TEXT = ‘ ‘
TABLES
t_outtab = gt_ekpo
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF sy–subrc <> 0.
ENDIF.
“display data
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_DISPLAY’
* EXPORTING
* I_INTERFACE_CHECK = ‘ ‘
* IS_PRINT =
* 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 =
EXCEPTIONS
PROGRAM_ERROR =
1
OTHERS = 2
.
IF sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.
else.
message ‘No record found‘ TYPE ‘I‘.
set SCREEN 0.
endif.
ENDFORM.
Output:
Author : Aniket Pawar, 9373518385
24REPORT1708 – Blocked ALV Report Example
*&———————————————————————*
*& Report ZBLOCK_ALV_REPORT
*&———————————————————————*
*&
*&———————————————————————*
REPORT ZBLOCK_ALV_REPORT.
TABLES : EKKO, EKPO, LFA1.
TYPES : BEGIN OF GTY_EKKO,
EBELN TYPE EBELN,
LIFNR TYPE LIFNR,
BUKRS TYPE BUKRS,
END OF GTY_EKKO.
DATA : IT_EKKO TYPE STANDARD TABLE OF GTY_EKKO,
GT_EKKO TYPE GTY_EKKO.
TYPES : BEGIN OF GTY_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
TXZ01 TYPE TXZ01,
MATNR TYPE MATNR,
MENGE TYPE MENGE,
MEINS TYPE MEINS,
NETWR TYPE NETWR,
END OF GTY_EKPO.
DATA : GT_EKPO TYPE STANDARD TABLE OF GTY_EKPO,
GS_EKPO TYPE GTY_EKPO.
TYPES : BEGIN OF GTY_LFA1,
LIFNR TYPE LIFNR,
NAME1 TYPE NAME1,
END OF GTY_LFA1.
DATA : GT_LFA1 TYPE STANDARD TABLE OF GTY_LFA1,
GS_LFA1 TYPE GTY_LFA1.
DATA : GT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_FCAT TYPE SLIS_FIELDCAT_ALV,
GT_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,
GS_FCAT1 TYPE SLIS_FIELDCAT_ALV,
GT_FCAT2 TYPE SLIS_T_FIELDCAT_ALV,
GS_FCAT2 TYPE SLIS_FIELDCAT_ALV,
GT_EVENTS TYPE SLIS_T_EVENT,
GS_KEYINFO TYPE SLIS_KEYINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
hdr_cnt TYPE i,
itm_cnt TYPE i,
vend_cnt TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT–001.
SELECT-OPTIONS : S_EBELN FOR EKKO–EBELN,
S_LIFNR FOR EKKO–LIFNR,
S_BUKRS FOR EKKO–BUKRS.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM GET_BUILD_DATA.
END-OF-SELECTION.
*&———————————————————————*
*& Form get_build_data
*&———————————————————————*
*& text
*&———————————————————————*
*& –> p1 text
*& <– p2 text
*&———————————————————————*
FORM GET_BUILD_DATA.
“PO HEADER DATA
SELECT EBELN, BUKRS, LIFNR, RLWRT
FROM EKKO INTO TABLE @DATA(GT_EKKO)
WHERE EBELN IN @S_EBELN
AND BUKRS IN @S_BUKRS
AND LIFNR IN @S_LIFNR.
IF GT_EKKO[] IS NOT INITIAL.
SORT GT_EKKO BY LIFNR.
“NAME OF VENDOR
SELECT LIFNR, NAME1
FROM LFA1 INTO TABLE @DATA(GT_LFA1)
FOR ALL ENTRIES IN @GT_EKKO WHERE LIFNR = @GT_EKKO–LIFNR.
SORT GT_EKKO BY EBELN.
“PO LINE ITEM
SELECT EBELN, EBELP, TXZ01, MATNR, MENGE, MEINS, NETWR
FROM EKPO INTO TABLE @DATA(GT_EKPO)
FOR ALL ENTRIES IN @GT_EKKO WHERE EBELN = @GT_EKKO–EBELN.
SORT GT_LFA1 BY LIFNR.
SORT GT_EKKO BY LIFNR EBELN.
SORT GT_EKPO BY EBELN EBELP.
******************************************************************************
CLEAR : GT_FCAT[], GT_FCAT1[], GT_FCAT2[], GS_FCAT, GS_LAYOUT, GS_KEYINFO.
*”PO header
GS_FCAT–COL_POS = ‘1’.
GS_FCAT–FIELDNAME = ‘EBELN’.
GS_FCAT–TABNAME = ‘GT_EKKO’.
GS_FCAT–SELTEXT_L = ‘PO_NUMBER’.
APPEND GS_FCAT TO GT_FCAT.
CLEAR : GS_FCAT.
GS_FCAT–COL_POS = ‘3’.
GS_FCAT–FIELDNAME = ‘LIFNR’.
GS_FCAT–TABNAME = ‘GT_EKKO’.
GS_FCAT–SELTEXT_L = ‘Vendor ID’.
APPEND GS_FCAT TO GT_FCAT.
CLEAR : GS_FCAT.
*”Vendor
GS_FCAT–COL_POS = ‘4’.
GS_FCAT1–FIELDNAME = ‘LIFNR’.
GS_FCAT1–SELTEXT_L = ‘Vendor ID’.
APPEND GS_FCAT1 TO GT_FCAT1.
CLEAR : GS_FCAT1.
GS_FCAT–COL_POS = ‘5’.
GS_FCAT1–FIELDNAME = ‘NAME1’.
GS_FCAT1–SELTEXT_L = ‘Vendor Name’.
APPEND GS_FCAT1 TO GT_FCAT1.
CLEAR: GS_FCAT1.
*”PO line items
GS_FCAT–COL_POS = ‘6’.
GS_FCAT2–FIELDNAME = ‘EBELN’.
GS_FCAT2–SELTEXT_L = ‘PO Number’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ‘7’.
GS_FCAT2–FIELDNAME = ‘EBELP’.
GS_FCAT2–SELTEXT_L = ‘PO Line Item’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ‘8’.
GS_FCAT2–FIELDNAME = ‘MATNR’.
GS_FCAT2–SELTEXT_L = ‘Material ID’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ‘9’.
GS_FCAT2–FIELDNAME = ‘TXZ01’.
GS_FCAT2–SELTEXT_L = ‘Material Description’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR: GS_FCAT2.
GS_FCAT–COL_POS = ’10’.
GS_FCAT2–FIELDNAME = ‘MENGE’.
GS_FCAT2–SELTEXT_L = ‘ORDER QTY’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ’11’.
GS_FCAT2–FIELDNAME = ‘MEINS’.
GS_FCAT2–SELTEXT_L = ‘UOM’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
GS_FCAT–COL_POS = ’12’.
GS_FCAT2–FIELDNAME = ‘NETWR’.
GS_FCAT2–SELTEXT_L = ‘Item PO Value’.
APPEND GS_FCAT2 TO GT_FCAT2.
CLEAR : GS_FCAT2.
******************************************************************************
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_INIT’
EXPORTING
i_callback_program = sy–repid
* I_CALLBACK_PF_STATUS_SET = ‘ ‘
* I_CALLBACK_USER_COMMAND = ‘ ‘
* IT_EXCLUDING =
.
“Vendor data
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fcat1
i_tabname = ‘GT_LFA1’
it_events = gt_events
* IT_SORT =
* I_TEXT = ‘ ‘
TABLES
t_outtab = gt_lfa1
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.
“PO header
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fcat
i_tabname = ‘GT_EKKO’
it_events = gt_events
* IT_SORT =
* I_TEXT = ‘ ‘
TABLES
t_outtab = gt_ekko
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.
“PO line items
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fcat2
i_tabname = ‘GT_EKPO’
it_events = gt_events
* IT_SORT =
* I_TEXT = ‘ ‘
TABLES
t_outtab = gt_ekpo
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF sy–subrc <> 0.
ENDIF.
“display data
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_DISPLAY’
* EXPORTING
* I_INTERFACE_CHECK = ‘ ‘
* IS_PRINT =
* 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 =
EXCEPTIONS
PROGRAM_ERROR =
1
OTHERS = 2
.
IF sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.
else.
message ‘No record found‘ TYPE ‘I‘.
set SCREEN 0.
endif.
ENDFORM.
Output:
Author : Aniket Pawar, 93735183