BLOCKED ALV

BLOCKED ALV:

Blocked ALV is used to display the output in block wise.

Steps to work with blocked ALV: -

A. Initialize the blocked ALV by using ‘REUSE_ALV_BLOCK_LIST_INIT’ function module.
B.The input for the above function module is ‘current program name’.
C.Append the data IT to the blocked ALV by using ‘REUSE_ALV_BLOCK_LIST_APPEND’               function module.
D.The input for the above function module is

      1.<Data IT>
      2.<Field catalog IT>
      3.<event IT> Dummy also ok
      4.<Layout WA>


E.Display the data in blocked ALV by using ‘REUSE_ALV_BLOCK_LIST_DISPLAY’ function           module.

 Based on the given purchasing document numbers display the purchasing document header (EBELN, BEDAT, LIFNR) and item (EBELN EBELP MENGE MEINS NETPR) details by using blocked ALV as shown in the below.





PROGRAM:

*&---------------------------------------------------------------------*
*& Report  ZR_BLOCKED_ALV
*&
*&---------------------------------------------------------------------*

REPORT ZR_BLOCKED_ALV.
TABLES EKKO.

*SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK WITH FRAME.
SELECT-OPTIONS SO_EBELN FOR EKKO-EBELN.
SELECTION-SCREEN END OF BLOCK A.

*TYPES DECLARATION
TYPES BEGIN OF TY_EKKO,
        EBELN 
TYPE EKKO-EBELN,
        BEDAT 
TYPE EKKO-BEDAT,
        LIFNR 
TYPE EKKO-LIFNR,
        
END OF TY_EKKO,
        
BEGIN OF TY_EKPO,
        EBELN 
TYPE EKPO-EBELN,
        EBELP 
TYPE EKPO-EBELP,
        MENGE 
TYPE EKPO-MENGE,
        MEINS 
TYPE EKPO-MEINS,
        NETPR 
TYPE EKPO-NETPR,
        
END OF TY_EKPO.

*DECLARE WORK AREA AND INTERNAL TABLES
DATA : WA_EKKO TYPE TY_EKKO,
       IT_EKKO 
TYPE TABLE OF TY_EKKO,
       WA_EKPO 
TYPE TY_EKPO,
       IT_EKPO 
TYPE TABLE OF TY_EKPO,
       IT_FCAT1 
TYPE SLIS_T_FIELDCAT_ALV,
       WA_FCAT1 
LIKE LINE OF IT_FCAT1,
       IT_FCAT2 
TYPE SLIS_T_FIELDCAT_ALV,
       WA_FCAT2 
LIKE LINE OF IT_FCAT2,
       IT_EVENT1 
TYPE SLIS_T_EVENT,
       IT_EVENT2 
TYPE SLIS_T_EVENT,
       WA_LAYOUT1 
TYPE SLIS_LAYOUT_ALV,
       WA_LAYOUT2 
TYPE SLIS_LAYOUT_ALV.

*GET DATA
SELECT EBELN BEDAT LIFNR
       
FROM EKKO
       
INTO TABLE IT_EKKO
       
WHERE EBELN IN SO_EBELN.
SELECT EBELN EBELP MENGE MEINS NETPR
       
FROM EKPO
       
INTO TABLE IT_EKPO
       
WHERE EBELN IN SO_EBELN.

*FILL FIELDCATLOG
WA_FCAT1
-FIELDNAME 'EBELN'.
WA_FCAT1
-COL_POS '1'.
WA_FCAT1
-SELTEXT_M 'PUR DOC'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT1
-FIELDNAME 'BEDAT'.
WA_FCAT1
-COL_POS '2'.
WA_FCAT1
-SELTEXT_M 'DOC DATE'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT1
-FIELDNAME 'LIFNR'.
WA_FCAT1
-COL_POS '3'.
WA_FCAT1
-SELTEXT_M 'VENDOR NO'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.

WA_FCAT2
-FIELDNAME 'EBELN'.
WA_FCAT2
-COL_POS '1'.
WA_FCAT2
-SELTEXT_M 'PUR DOC'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2
-FIELDNAME 'EBELP'.
WA_FCAT2
-COL_POS '2'.
WA_FCAT2
-SELTEXT_M 'ITEM'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2
-FIELDNAME 'MENGE'.
WA_FCAT2
-COL_POS '3'.
WA_FCAT2
-SELTEXT_M 'QTY'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2
-FIELDNAME 'MEINS'.
WA_FCAT2
-COL_POS '4'.
WA_FCAT2
-SELTEXT_M 'UOM'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2
-FIELDNAME 'NETPR'.
WA_FCAT2
-COL_POS '5'.
WA_FCAT2
-SELTEXT_M 'NET PRICE'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.


*INITIALIZE BLOCKED ALV
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  
EXPORTING
    I_CALLBACK_PROGRAM             
SYCPROG
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
          
.
*APPEND THE DATA INTERNAL TABLE TO BLOCKED ALV
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  
EXPORTING
    IS_LAYOUT                        
WA_LAYOUT1
    IT_FIELDCAT                      
IT_FCAT1
    I_TABNAME                        
'IT_EKKO'
    IT_EVENTS                        
IT_EVENT1
*   IT_SORT                          =
*   I_TEXT                           = ' '
  
TABLES
    T_OUTTAB                         
IT_EKKO
* EXCEPTIONS
*   PROGRAM_ERROR                    = 1
*   MAXIMUM_OF_APPENDS_REACHED       = 2
*   OTHERS                           = 3
          
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

*APPEND THE DATA INTERNAL TABLE TO BLOCKED ALV
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  
EXPORTING
    IS_LAYOUT                        
WA_LAYOUT2
    IT_FIELDCAT                      
IT_FCAT2
    I_TABNAME                        
'IT_EKPO'
    IT_EVENTS                        
IT_EVENT1
*   IT_SORT                          =
*   I_TEXT                           = ' '
  
TABLES
    T_OUTTAB                         
IT_EKPO
* EXCEPTIONS
*   PROGRAM_ERROR                    = 1
*   MAXIMUM_OF_APPENDS_REACHED       = 2
*   OTHERS                           = 3
          
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

*DISPLAY BLOCKED ALVCALL 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.


OUTPUT :