33 Flares Twitter 0 Facebook 33 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 33 Flares ×

Blocked ALV is used to display the output in block wise (display multiple ALV lists in the same screen) a shown below.

Blocked Alv in SAP

 

Steps to work with blocked ALV:

1. Initialize the blocked ALV by using “REUSE_ALV_BLOCK_LIST_INIT” the input for above function module is current program (sy-repid)

2. Append each data internal table to the blocked ALV by using “REUSE_ALV_BLOCKED_LIST_APPEND function module

The input for the above function module is

1. Data internal table

2. Field catalog internal table

3. Event internal table

4. Layout internal table

Repeat the step 2 from each block (data internal table)

3. Display the output by using “REUSE_ALV_BLOCKED_LIST_DISPLAY” function module

OBJECT: Based on the sales document number retrieve the sales document header details(VBELN,AUART,KUNNR) and item details (VBELN, POSNR, MEINS, NETWR, KWMENG)  and display it in blocked ALV.

Code:

*&———————————————————————*
*& Report  ZBLOCKED_ALV_REPORT
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT  zblocked_alv_report NO STANDARD PAGE HEADING.

*//Type group declaraction
TYPE-POOLS slis.

*//Table delaraction
TABLES:vbak.
*//Types declaraction for VBAK
TYPES:BEGIN OF ty_vbak,
vbeln  TYPE vbeln_va,
auart  TYPE auart,
kunnr  TYPE kunag,
END OF ty_vbak.

*//Types delaraction for VBAP
TYPES:BEGIN OF ty_vbap,
vbeln TYPE vbeln_va,
posnr  TYPE posnr_va,
meins  TYPE meins,
netwr  TYPE netwr_ap,
kwmeng TYPE kwmeng,
END OF ty_vbap.

*//Internal Table delaraction
DATA:lt_vbak  TYPE TABLE OF ty_vbak,
lt_vbap  TYPE TABLE OF ty_vbap,
lt_fcat1 TYPE slis_t_fieldcat_alv,
lt_fcat2 TYPE slis_t_fieldcat_alv,
lt_event1 TYPE slis_t_event,
lt_event2 TYPE slis_t_event.

*//Work are declaraction
DATA:wa_vbak TYPE  ty_vbak,
wa_vbap TYPE  ty_vbap,
wa_fcat1 TYPE slis_fieldcat_alv,
wa_fcat2 TYPE slis_fieldcat_alv,
wa_event1 TYPE slis_alv_event,
wa_event2 TYPE slis_alv_event,
wa_layout1 TYPE slis_layout_alv,
wa_layout2 TYPE slis_layout_alv.

*//Selection screen design
SELECT-OPTIONS:s_vbeln FOR vbak-vbeln.
*//Retrieve data from
IF s_vbeln IS NOT INITIAL.
SELECT vbeln auart kunnr
FROM vbak
INTO TABLE lt_vbak
WHERE vbeln IN s_vbeln.
*//Retrieve data from VBAP
SELECT vbeln posnr meins netwr kwmeng
FROM vbap
INTO TABLE lt_vbap
WHERE vbeln IN s_vbeln.
ENDIF.

*//Filling the field catalog internal table
wa_fcat1-col_pos = 1.
wa_fcat1-fieldname = ‘VBELN’.
wa_fcat1-outputlen = 15.
wa_fcat1-seltext_m = ‘SALES ORDER NO’.
APPEND wa_fcat1 TO lt_fcat1.
CLEAR wa_fcat1.

wa_fcat1-col_pos = 2.
wa_fcat1-fieldname = ‘AUART’.
wa_fcat1-outputlen = 15.
wa_fcat1-seltext_m = ‘Document Type’.
APPEND wa_fcat1 TO lt_fcat1.
CLEAR wa_fcat1.

wa_fcat1-col_pos = 3.
wa_fcat1-fieldname = ‘KUNNR’.
wa_fcat1-outputlen = 15.
wa_fcat1-seltext_m = ‘CUSTOMER NO’.
APPEND wa_fcat1 TO lt_fcat1.
CLEAR wa_fcat1.

wa_fcat2-col_pos = 1.
wa_fcat2-fieldname = ‘VBELN’.
wa_fcat2-outputlen = 15.
wa_fcat2-seltext_m = ‘SALES ORDER NO’.
APPEND wa_fcat2 TO lt_fcat2.
CLEAR wa_fcat2.

wa_fcat2-col_pos = 2.
wa_fcat2-fieldname = ‘POSNR’.
wa_fcat2-outputlen = 15.
wa_fcat2-seltext_m = ‘ Item’.
APPEND wa_fcat2 TO lt_fcat2.
CLEAR wa_fcat2.

wa_fcat2-col_pos = 3.
wa_fcat2-fieldname = ‘MEINS’.
wa_fcat2-outputlen = 15.
wa_fcat2-seltext_m = ‘Unit of Measure’.
APPEND wa_fcat2 TO lt_fcat2.
CLEAR wa_fcat2.

wa_fcat2-col_pos = 4.
wa_fcat2-fieldname = ‘NETWR’.
wa_fcat2-outputlen = 15.
wa_fcat2-seltext_m = ‘ Currency’.
APPEND wa_fcat2 TO lt_fcat2.
CLEAR wa_fcat2.

wa_fcat2-col_pos = 5.
wa_fcat2-fieldname = ‘KWMENG’.
wa_fcat2-outputlen = 15.
wa_fcat2-seltext_m = ‘Quantit in Units’.
APPEND wa_fcat2 TO lt_fcat2.
CLEAR wa_fcat2.

*//Call the function module REUSE_ALV_BLOCK_LIST_INIT
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_INIT’
EXPORTING
i_callback_program = sy-repid.

*//Call the function module REUSE_ALV_BLOCK_LIST_APPEND for VBAK
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’
EXPORTING
is_layout   = wa_layout1
it_fieldcat = lt_fcat1
i_tabname   = ‘LT_VBAK’
it_events   = lt_event1
TABLES
t_outtab    = lt_vbak.

*//Call the function module REUSE_ALV_BLOCK_LIST_APPEND for VBAP
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’
EXPORTING
is_layout   = wa_layout2
it_fieldcat = lt_fcat2
i_tabname   = ‘LT_VBAP’
it_events   = lt_event2
TABLES
t_outtab      = lt_vbap.

*//Call the function module
CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_DISPLAY’.

 OUTPUT:

Click on execute

Provide the input values click  on execute

Blocked Alv in SAP1

 

Blocked Alv in SAP

 

Also Read:

Dynamic selection screen in SAP ABAP.

Table Maintenance without using SE11 and SE30 Transaction Codes.

Difference between SAP SCRIPTS and SMARTFORMS.

Display a Column As a Pushbutton in the ALV Report Output.

33 Flares Twitter 0 Facebook 33 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 33 Flares ×