OOPs Report Using Splitter and ALV Tree Combination

ALV Hierarchy Structure
Share on Facebook8Share on LinkedIn20Tweet about this on TwitterShare on Google+0
Please Share!!

For one client requirement, we had to build a report with splitter containers along with tree structure. The combination of these two might sound difficult but actually, these are quite easy to handle. In no time, we built a prototype and it worked perfectly.

Although the design of the below-explained prototype can be enhanced in multiple folds, basic skeleton for programming should remain the same. As we were going along with our development we found some well-discussed topics over the internet which I have tried to fine tune and address through this article.

Objective

The objective of this article is to explain how to use SPLITTER CONTAINER and TREE MODEL (TREE_STRUCTURE) in OOPs ABAP report generation integrating standard events.

And the second and more important objective is to eradicate our fear of using Tree Models and Splitter Containers, once and for all. 🙂

Scope

This article covers the solutions of the following common problems encountered by developers-

  • Full screen utilization of custom container when it is splitted into further sub-containers.
  • Registering custom events with standard events of tree model
  • Width customization of splitter containers.

Overview

The following code has been written to display a report which has 2 containers in the list screen. The left panel container has been designed to hold the tree model and the right container is to display the details of the left panel document upon an event of double clicking. In this example a tree structure has been created with sales orders which have sales contract as a preceding document. These sales orders can be selected by giving certain selection screen criteria. Upon clicking on the leaf node system will display details of the sales order in the right container as an ALV format (please refer fig. 1).

Tree ALV

fig. – 1

Program Construct

Step – I: Declare all required structures and tables
Step –II: Declare reference of various classes
Step – III: Definition of event class
Step – IV: Implementation of Event Class
Step – V:  Selection Screen
Step – VI: Subroutine to fetch basic data for tree model
Step – VII: Screen Design
Step – VIII: Module for object creation of various classes. (In PBO of output screen)
Step – IX: Module for event registration. (In PBO of output Screen)
Step – X: Module for output processing. (In PBO of output Screen)

Step-I: Declare all required structures and tables

Step –II: Declare reference of various classes

Step – III: Definition of event class

Step – IV: Implementation of Event Class

Step – V:  Selection Screen

Step – VI: Subroutine to fetch basic data for tree model

Step – VII: Screen Design

Splitter Container

* The container should be drawn as large as possible. Also, the Lines/columns in the attributes tab of the screen painter are to be filled with the value 240 to get the full-screen splitter container.

OOPs ALV Report

Step – VIII: Module for object creation of various classes. (In PBO of output screen)

Create one module in the flow logic of the screen.

* The width of the splitter container can be adjusted with the SET_COLUMN_WIDTH method. Pass the width as required.

Step – IX: Module for event registration. (In PBO of output Screen)

ALV Tree

Step – X: Module for output processing. (In PBO of output Screen)

OOPs ALV for Hierarchy Tree

Please download the entire code of the ABAP Editor Here.     

Copy or refer the embedded code but do change the design. I would rather suggest develop the entire report with the help of local class or at least apply some modularization concepts. I used multiple PBO modules which are a big ‘no-no’ for any real-time objects.

Tree structures can also be done in many other ways. Plenty of documents is available over the internet. I picked the simplest way of doing that(ironically the class name is ”cl_simple_tree_model”). Splitter containers are well explored but hardly used unless we have such specific requirements. However, this report is nothing but “Old wine in a new bottle“. Hope this destroys our inhibition of using Splitter Containers and Tree Models on the same call and meet the second objective of this tutorial. 🙂

Once you are done with your development, the result of your hard work should look something like below.

OOPs ABAP Tutorial

Selection Screen

Output List Screen

Expanded List

On Double-Click Event

We put a lot of effort in conceptualizing, testing and writing each and every article. If you could pass this link to at least 5 colleagues/friends who you think would benefit from our post, it would be a great favor to our team. We want our articles to reach to as many audiences as possible so that everyone would benefit and our team would remain motivated and our work does not get lost in this huge ocean of the internet.

Please, please share our post in your professional and social media and introduce your friends/colleagues/co-workers to our blog page.

 

Share on Facebook8Share on LinkedIn20Tweet about this on TwitterShare on Google+0
Please Share!!

About the Author

Saswata
I hold a Bachelor's Degree in Information Technology and into SAP technical consulting for approximately 4 years. I have worked with overseas clients for domains like Pharmaceuticals and Forestry Equipment Manufacturers etc. I am presently a consultant in an MNC located in Pune, India. Apart from being a voracious technology learner I spend quality time in reading books, sketching, watching movies and listening music. Find more about him on LinkedIn.

4 Comments on "OOPs Report Using Splitter and ALV Tree Combination"

  1. Wow! Very nicely done. I haven’t needed one of these, but will look for an opportunity now!

    • Dear Steven – Welcome back. Long time .. 🙂

      Even I have not used it. But thanks to Author Saswata, he made it look simpler than I thought. In fact, I am trying to reuse his code and practice it in our sandbox system. Just to get a hang of it.

      Regards,
      Raju.

  2. Praveen Kumar Bindla | June 21, 2017 at 4:01 am | Reply

    Thanks a lot for this ALV tree

Please help us improve. Please Shout Often & Loud!!