Hierarchical ALV Report

Hierarchical ALV Report :

  • It is used to display the header and corresponding item details in Hierarchical format.
  • The standard Function Module 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' used to display the header and corresponding item details.

*&---------------------------------------------------------------------*
*& Report ZVB_HIERA_ALV
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zvb_hiera_alv.

TABLES:ekko,ekpo.

TYPE-POOLSslis.

*Data Declarations
TYPESBEGIN OF ty_ekko,
         ebeln  TYPE ekko-ebeln,
         bukrs  TYPE ekko-bukrs,
         aedat  TYPE ekko-aedat,
         ernam  TYPE ekko-ernam,
         expand,
       END OF ty_ekko,
       BEGIN OF ty_ekpo,
         ebeln TYPE ekpo-ebeln,
         ebelp TYPE ekpo-ebelp,
         matkl TYPE ekpo-matkl,
         menge TYPE ekpo-menge,
         meins TYPE ekpo-meins,
       END OF ty_ekpo.

DATAit_ekko TYPE TABLE OF ty_ekko,
      it_ekpo TYPE TABLE OF ty_ekpo.

DATAwa_fcat   TYPE slis_fieldcat_alv,
      it_fact   TYPE slis_t_fieldcat_alv,
      wa_layout TYPE slis_layout_alv,
      wa_key    TYPE slis_keyinfo_alv.

*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1.
  SELECT-OPTIONS s_ebeln FOR ekko-ebeln.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
*Fetch data
  SELECT ebeln
         bukrs
         aedat
         ernam
    FROM ekko
    INTO TABLE it_ekko
    WHERE ebeln IN s_ebeln.
  IF it_ekko IS NOT INITIAL.
    SELECT ebeln
           ebelp
           matkl
           menge
           meins
      FROM ekpo
      INTO TABLE it_ekpo
      FOR ALL ENTRIES IN it_ekko
      WHERE ebeln it_ekko-ebeln.
  ENDIF.

*Layout
  wa_layout-zebra 'X'.
  wa_layout-colwidth_optimize 'X'.
  wa_layout-expand_fieldname 'EXPAND'.
  wa_layout-window_titlebar 'Hierarchical PO header & item display'.

*Field catalog for header details (EKKO)
  CLEAR:wa_fcat.
  wa_fcat-col_pos '1'.
  wa_fcat-fieldname 'EBELN'.
  wa_fcat-tabname 'IT_EKKO'.
  wa_fcat-outputlen '15'.
  wa_fcat-seltext_l 'PO Number'.
  APPEND wa_fcat TO it_fact.

  CLEAR:wa_fcat.
  wa_fcat-col_pos '2'.
  wa_fcat-fieldname 'BUKRS'.
  wa_fcat-tabname 'IT_EKKO'.
  wa_fcat-outputlen '30'.
  wa_fcat-seltext_l 'Company code'.
  APPEND wa_fcat TO it_fact.

  CLEAR:wa_fcat.
  wa_fcat-col_pos '3'.
  wa_fcat-fieldname 'AEDAT'.
  wa_fcat-tabname 'IT_EKKO'.
  wa_fcat-outputlen '45'.
  wa_fcat-seltext_l 'creation date'.
  APPEND wa_fcat TO it_fact.

  CLEAR:wa_fcat.
  wa_fcat-col_pos '4'.
  wa_fcat-fieldname 'ERNAM'.
  wa_fcat-tabname 'IT_EKKO'.
  wa_fcat-outputlen '55'.
  wa_fcat-seltext_l 'User Name'.
  APPEND wa_fcat TO it_fact.

*Field catalog for Item details (EKPO).
  CLEAR:wa_fcat.
  wa_fcat-col_pos '1'.
  wa_fcat-fieldname 'EBELP'.
  wa_fcat-tabname 'IT_EKPO'.
  wa_fcat-outputlen '15'.
  wa_fcat-seltext_l 'PO Item'.
  APPEND wa_fcat TO it_fact.

  CLEAR:wa_fcat.
  wa_fcat-col_pos '2'.
  wa_fcat-fieldname 'MATKL'.
  wa_fcat-tabname 'IT_EKPO'.
  wa_fcat-outputlen '40'.
  wa_fcat-seltext_l 'Materail Type'.
  APPEND wa_fcat TO it_fact.

  CLEAR:wa_fcat.
  wa_fcat-col_pos '3'.
  wa_fcat-fieldname 'MENGE'.
  wa_fcat-tabname 'IT_EKPO'.
  wa_fcat-outputlen '50'.
  wa_fcat-seltext_l 'Quantity'.
  APPEND wa_fcat TO it_fact.

  CLEAR:wa_fcat.
  wa_fcat-col_pos '4'.
  wa_fcat-fieldname 'MEINS'.
  wa_fcat-tabname 'IT_EKPO'.
  wa_fcat-outputlen '60'.
  wa_fcat-seltext_l 'Units'.
  APPEND wa_fcat TO it_fact.

  wa_key-header01 'EBELN'.
  wa_key-item01 'EBELN'.

*Calling REUSE_ALV_HIERSEQ_LIST_DISPLAY
  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    EXPORTING
      i_callback_program sy-repid
      is_layout          wa_layout
      it_fieldcat        it_fact
      i_tabname_header   'IT_EKKO'
      i_tabname_item     'IT_EKPO'
      is_keyinfo         wa_key
    TABLES
      t_outtab_header    it_ekko
      t_outtab_item      it_ekpo
    EXCEPTIONS
      program_error      1
      OTHERS             2.

input:


output:






Comments

Popular posts from this blog

CDS Views: Table Functions with Example

Passing Dynamic Variables to SO10 TEXT

Adobe Form/PDF Form Introduction