Full ABAP code listing of main program


*&-------------------------------------------------------------*
*& Report  ZDEMO_SIMPLETREE                                    *
*&                                                             *
*&-------------------------------------------------------------*
*&                                                             *
*& Example of a simple ALV Grid Report                         *
*& ...................................                         *
*&                                                             *
*& The basic requirement for this demo is to display a simple  *
*& tree structure of ekko/ekpo records.                        *
*&                                                             *
*&-------------------------------------------------------------*
*                          Amendment History                   *
*--------------------------------------------------------------*
REPORT  zdemo_simpletree       .
*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_SIMPLE_TREE.
  TYPES: NODE_TABLE_TYPE LIKE STANDARD TABLE OF MTREESNODE
           WITH DEFAULT KEY.
data: NODE_TABLE TYPE NODE_TABLE_TYPE.
*Create container for alv-tree
  CLASS LCL_APPLICATION DEFINITION DEFERRED.
  CLASS CL_GUI_CFW DEFINITION LOAD.
DATA: GD_APPLICATION             TYPE REF TO LCL_APPLICATION.
* Fields on Dynpro 100
  DATA: G_EVENT(30),
        G_NODE_KEY TYPE TV_NODEKEY.
*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_SIMPLETREECL1. "ABAP Classes
*INCLUDE ZDEMO_SIMPLETREEO01. "Screen PBO Modules
*INCLUDE ZDEMO_SIMPLETREEI01. "Screen PAI Modules
*INCLUDE ZDEMO_SIMPLETREEF01. "ABAP Subroutines(FORMS)
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
* ALVtree setup data
  CREATE OBJECT GD_APPLICATION.
  PERFORM data_retrieval.
* Display ALVtree report
  call screen 100.
*&---------------------------------------------------------------------*
*&      Form  DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*       Retrieve data into Internal tables
*----------------------------------------------------------------------*
FORM data_retrieval.
  SELECT ebeln
   UP TO 10 ROWS
    FROM ekko
    INTO corresponding fields of TABLE it_ekko.
  loop at it_ekko into wa_ekko.
    SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
      FROM ekpo
      appending TABLE it_ekpo
     where ebeln eq wa_ekko-ebeln.
  endloop.
ENDFORM.                    " DATA_RETRIEVAL

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
Create ALV tree main program including Data & Event declaration
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
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)