Create ALV tree main program including Data & Event declaration

The following ABAP code and information is part of the example ALV tree report demo and creates the program outline and all data declarations. Simply follow the below instructions and copy and paste the ABAP code into the appropriate program.

 *&-------------------------------------------------------------*
*& Report  ZDEMO_ALVTREE                                       *
*&                                                             *
*&-------------------------------------------------------------*
*&                                                             *
*& Example of a simple ALV Grid Report                         *
*& ...................................                         *
*&                                                             *
*& The basic requirement for this demo is to display a number  *
*& of fields from the EKPO and EKKO table in a tree structure. *
*&                                                             *
*&-------------------------------------------------------------*
*                          Amendment History                   *
*--------------------------------------------------------------*
report  zdemo_alvgrid                 .
*Data Declaration
*----------------
tables:     ekko.
type-pools: slis.                                 "ALV Declarations
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.
data: it_ekko     type standard table of t_ekko initial size 0,
      it_ekpo     type standard table of t_ekko initial size 0,
      it_emptytab type standard table of t_ekko initial size 0,
      wa_ekko     type t_ekko,
      wa_ekpo     type t_ekko.
data: ok_code like sy-ucomm,           "OK-Code
      save_ok like sy-ucomm.
*ALV data declarations
data: fieldcatalog  type lvc_t_fcat with header line.
data: gd_fieldcat   type lvc_t_fcat,
      gd_tab_group  type slis_t_sp_group_alv,
      gd_layout     type slis_layout_alv.
*ALVtree data declarations
class cl_gui_column_tree definition load.
class cl_gui_cfw definition load.
data: gd_tree             type ref to cl_gui_alv_tree,
      gd_hierarchy_header type treev_hhdr,
      gd_report_title     type slis_t_listheader,
      gd_logo             type sdydo_value,
      gd_variant          type disvariant.
*Create container for alv-tree
data: gd_tree_container_name(30) type c,
      gd_custom_container        type ref to cl_gui_custom_container.
************************************************************************
*Includes
*include zdemo_alvtreeo01. "Screen PBO Modules
*include zdemo_alvtreei01. "Screen PAI Modules
*include zdemo_alvtreef01. "ABAP Subroutines(FORMS)
************************************************************************
*Start-of-selection.
start-of-selection.
* Display ALVtree report
  call screen 100.

Return to the full list of instructions on how to create an example ALV tree report and find all steps required to create the fully working demo.


Related Articles

Activate user interaction within SAP ALV tree
Add button to SAP ALV tree toolbar using ABAP code
ABAP ALV Tree tutorial to create a fully working ALVTree Control SAP dynpro program
Create ALV Tree Custom control and add to sap dynpro screen
Final ABAP code for the ALV Tree PBO(..O01) and FORM(..F01) includes
Create SAP ALV Tree Container in ABAP dynpro screen container
Create Container and Object
SAP ALV Tree fieldcatalog creation
Set SAP ALV tree table for first display and user interaction
Build SAP ALV tree Hierarchy
Build SAP ALV tree Hierarchy Header
Add alv tree already exists check to pbo module
Create all includes required for the ALV tree report
Full ABAP code listing of main ALV tree program
Module creation screen
Create SAP ALV Tree object within ABAP dynpro screen container/H1>
Create ok code to store ALV tree user interaction
Example Output from ALV tree display
Create screen control
Create Screen along with PBO and PAI modules
Create Pf-status(screen menu functionality)
Refresh ALVtree
Build Report Header(Title)
ALVtree toolbar processing
Implement user defined buttons to ALVtree toolbar
ALVtree user interaction processing
Implement ALVtree user interaction processing
Setup ALVtree variant
Main Steps to create ALV simple Tree(Using Objects)
Create Add Custom control to screen
Final code for the PBO(..O01) and FORM(..F01) includes
Create Container and Object
Create and register events for user interaction
Create ALVtree Hierarchy
Add already exists check!
Create Includes for ALVtree report
Full ABAP code listing of main program
Create Container and Object
Create screen control
Example Output from ALV simple tree display
Create screen control
Create Screen along with PBO and PAI modules
Create Pf-status(screen menu functionality)