Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Block ALV Report Doubt!

Former Member
0 Kudos
72

Hi!

In Block AlV we r using Fun Mod

REUSE_ALV_BLOCK_LIST_APPEND

To display data in blocks and called again to display other data in block in same screen.

I want to know REUSE_ALV_BLOCK_LIST_DISPLAY Fun mod is optional or mandatory

without using this also shall i get the required o/p.

Looking for your reply.

Rahul.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
50

Hello Rahul,

REUSE_ALV_BLOCK_LIST_DISPLAY is mandatory,otherwise layout will not trigger.

REUSE_ALV_BLOCK_LIST_APPEND is the function to append internal table as block,

REUSE_ALV_BLOCK_LIST_DISPLAY - mandatory and jus call the function module and no need to pass any data.

3 REPLIES 3

Former Member
0 Kudos
51

Hello Rahul,

REUSE_ALV_BLOCK_LIST_DISPLAY is mandatory,otherwise layout will not trigger.

REUSE_ALV_BLOCK_LIST_APPEND is the function to append internal table as block,

REUSE_ALV_BLOCK_LIST_DISPLAY - mandatory and jus call the function module and no need to pass any data.

Former Member
0 Kudos
50

Hi,

REUSE_ALV_BLOCK_LIST_DISPLAY function module is mandatory in ALV for displaying data in alv report.

follow this link for sample program.

http://www.sap-img.com/abap/reuse-alv-block-list-display.htm

regards,

Ashokreddy.

Former Member
0 Kudos
50

REUSE_ALV_BLOCK_LIST_DISPLAY is mandatory, without calling this FM, you will not get any disply.

In the below ALV if you comment out t REUSE_ALV_BLOCK_LIST_DISPLAY FM call call you will not get disply.

REPORT ztest1 .

TABLES:     ekko, mara.
TYPE-POOLS: slis.

*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
  statu TYPE ekpo-statu,
  aedat TYPE ekpo-aedat,
  matnr TYPE ekpo-matnr,
  menge TYPE ekpo-menge,
  meins TYPE ekpo-meins,
  netpr TYPE ekpo-netpr,
  peinh TYPE ekpo-peinh,
 END OF t_ekko.

TYPES: BEGIN OF t_mara,
  matnr TYPE mara-matnr,
  mtart TYPE mara-mtart,
  matkl TYPE mara-matkl,
END OF t_mara.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
      it_mara TYPE STANDARD TABLE OF t_mara INITIAL SIZE 0.


*ALV data declarations
DATA: fieldcatalog1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      fieldcatalog2 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      gd_layout     TYPE slis_layout_alv,
      gt_events_ekko TYPE slis_t_event,
      xs_event      TYPE slis_alv_event,
      gt_events_mara TYPE slis_t_event,
      gd_repid       TYPE sy-repid,
      gt_print TYPE slis_print_alv.


* START-OF-SELECTION
START-OF-SELECTION.
  PERFORM data_retrival.
  PERFORM build_fieldcat.
  PERFORM build_layout.
  PERFORM events_ekko.
  PERFORM events_mara.
  PERFORM display_alv_report.

*SUBROUTINES

*&---------------------------------------------------------------------*
*&      Form  data_retrival
*&---------------------------------------------------------------------*

FORM data_retrival .

  SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
   UP TO 10 ROWS
    FROM ekpo
    INTO TABLE it_ekko.

  SELECT matnr mtart matkl
   UP TO 10 ROWS
    FROM mara
    INTO TABLE it_mara.

ENDFORM.                    " data_retrival
*&---------------------------------------------------------------------*
*&      Form  build_fieldcat
*&---------------------------------------------------------------------*

FORM build_fieldcat .

* FOR EKKO
  fieldcatalog1-fieldname   = 'EBELN'.
  fieldcatalog1-seltext_m   = 'Purchase Order'.
  fieldcatalog1-col_pos     = 0.
  fieldcatalog1-outputlen   = 10.
  fieldcatalog1-emphasize   = 'X'.
  fieldcatalog1-key         = 'X'.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

  fieldcatalog1-fieldname   = 'EBELP'.
  fieldcatalog1-seltext_m   = 'PO Item'.
  fieldcatalog1-col_pos     = 1.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

  fieldcatalog1-fieldname   = 'STATU'.
  fieldcatalog1-seltext_m   = 'Status'.
  fieldcatalog1-col_pos     = 2.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

  fieldcatalog1-fieldname   = 'AEDAT'.
  fieldcatalog1-seltext_m   = 'Item change date'.
  fieldcatalog1-col_pos     = 3.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

  fieldcatalog1-fieldname   = 'MATNR'.
  fieldcatalog1-seltext_m   = 'Material Number'.
  fieldcatalog1-col_pos     = 4.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

  fieldcatalog1-fieldname   = 'MENGE'.
  fieldcatalog1-seltext_m   = 'PO quantity'.
  fieldcatalog1-col_pos     = 5.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

  fieldcatalog1-fieldname   = 'MEINS'.
  fieldcatalog1-seltext_m   = 'Order Unit'.
  fieldcatalog1-col_pos     = 6.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

  fieldcatalog1-fieldname   = 'NETPR'.
  fieldcatalog1-seltext_m   = 'Net Price'.
  fieldcatalog1-col_pos     = 7.
  fieldcatalog1-outputlen   = 15.
  fieldcatalog1-do_sum      = 'X'.        "Display column total
  fieldcatalog1-datatype     = 'CURR'.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

  fieldcatalog1-fieldname   = 'PEINH'.
  fieldcatalog1-seltext_m   = 'Price Unit'.
  fieldcatalog1-col_pos     = 8.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR  fieldcatalog1.

* FOR MARA
  fieldcatalog2-fieldname   = 'MATNR'.
  fieldcatalog2-seltext_m   = 'Material No'.
  fieldcatalog2-col_pos     = 0.
  fieldcatalog2-outputlen   = 10.
  fieldcatalog2-emphasize   = 'X'.
  fieldcatalog2-key         = 'X'.
  APPEND fieldcatalog2 TO fieldcatalog2.
  CLEAR  fieldcatalog1.

  fieldcatalog2-fieldname   = 'MTART'.
  fieldcatalog2-seltext_m   = 'Material type'.
  fieldcatalog2-col_pos     = 1.
  APPEND fieldcatalog2 TO fieldcatalog2.
  CLEAR  fieldcatalog2.

  fieldcatalog2-fieldname   = 'MATKL'.
  fieldcatalog2-seltext_m   = 'Material Group'.
  fieldcatalog2-col_pos     = 2.
  APPEND fieldcatalog2 TO fieldcatalog2.
  CLEAR  fieldcatalog2.

ENDFORM.                    " build_fieldcat
*&---------------------------------------------------------------------*
*&      Form  build_layout
*&---------------------------------------------------------------------*
FORM build_layout .
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
  gd_layout-totals_text       = 'Totals'(201).
ENDFORM.                    " build_layout
*&---------------------------------------------------------------------*
*&      Form  events_ekko
*&---------------------------------------------------------------------*

FORM events_ekko .
  CLEAR xs_event.
  xs_event-name = slis_ev_top_of_page.
  xs_event-form = 'TOP_OF_PAGE-EKKO'.
  APPEND xs_event TO gt_events_ekko.

  CLEAR xs_event.
  xs_event-name = slis_ev_end_of_list.
  xs_event-form = 'END_OF_LIST_EKKO'.
  APPEND xs_event TO gt_events_ekko.
ENDFORM.                    " events_ekko

*&---------------------------------------------------------------------*
*&      Form  TOP_OF_PAGE-EKKO
*&---------------------------------------------------------------------*

FORM top_of_page-ekko.
  WRITE: / 'TOP OF PAGE : Purchase Order'.
ENDFORM.                    "XTOP_OF_PAGE


*&---------------------------------------------------------------------*
*&      Form  END_OF_LIST_EKKO
*&---------------------------------------------------------------------*

FORM end_of_list_ekko.
  WRITE: / 'end OF list : Purchase Order'.
ENDFORM.                    "END_OF_LIST_EKKO

*&---------------------------------------------------------------------*
*&      Form  events_mara
*&---------------------------------------------------------------------*

FORM events_mara .
  CLEAR xs_event.
  xs_event-name = slis_ev_top_of_list.
  xs_event-form = 'TOP_OF_LIST-MARA'.
  APPEND xs_event TO gt_events_mara.

  CLEAR xs_event.
  xs_event-name = slis_ev_end_of_page.
  xs_event-form = 'END_OF_PAGE_MARA'.
  APPEND xs_event TO gt_events_mara.
ENDFORM.                    "events_mara


*&---------------------------------------------------------------------*
*&      Form  TOP_OF_LIST-MARA
*&---------------------------------------------------------------------*

FORM top_of_list-mara.
  WRITE: / 'TOP OF LIST : Material Master'.
ENDFORM.                    "TOP_OF_LIST-MARA



*&---------------------------------------------------------------------*
*&      Form  END_OF_PAGE_MARA
*&---------------------------------------------------------------------*

FORM end_of_page_mara.
  WRITE: / 'End OF Page : Material Master'.
ENDFORM.                    "END_OF_PAGE_MARA

*&---------------------------------------------------------------------*
*&      Form  display_alv_report
*&---------------------------------------------------------------------*

FORM display_alv_report .

  gd_repid = sy-repid.


  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program = sy-repid.


  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = gd_layout
      it_fieldcat                      = fieldcatalog1[]
      i_tabname                        = 'it_ekko'
      it_events                        = gt_events_ekko
    TABLES
      t_outtab                         = it_ekko
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = gd_layout
      it_fieldcat                      = fieldcatalog2[]
      i_tabname                        = 'it_mara'
      it_events                        = gt_events_mara
    TABLES
      t_outtab                         = it_mara
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  gt_print-reserve_lines = 2.
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    EXPORTING
      is_print = gt_print.

ENDFORM.                    " display_alv_report