Skip to Content
Author's profile photo Former Member

Dynamic ALV grid in WebDynPro Abap


Purpose of this document: it describes a way to create a simple Web DynPro application that contains an ALV grid with dynamic columns (and thus also dynamic data). This explanation is based on a simple example coming from the HR world.

Business example

The web application will show all the competences/qualifications of the team members of a manager. As columns, we’ll have a list of persons; and as rows, the competences required to work in the manager’s team. Depending on the manager, the number of team members will change, so the number of columns is dynamic (that is: computed by the application during runtime).


Part 1: get data

The main component controller will contain, as it should, the business logic to get the data. The basic data will then be shared between elements of the component via the context: the node “GLOBAL_DATA” will be used for this purpose. We will find a copy/mirror version of this node (and all its data) in the main view for example.  Context mapping will be used to share/expose the “GLOBAL_DATA” context node.


  • (a)  Read SAP data
  • (b)  Bind data to the context of the component
  • (c)  Share part of the component controller context to subcomponent contexts (context mapping)

Part 2: create dynamic structure

  So the idea is to create during the runtime, this kind of structure:


How to do that? Via the RTTI (Run-time type information) objects provided by the abap stack! Especially the classes CL_ABAP_DATADESCR and CL_ABAP_STRUCTDESCR will be used. The dynamic structure will be firstly represented /materialized via the object of type CL_ABAP_STRUCTDESCR.


Part 3: create dynamic context (based on dynamic structure)

To create a new context node based on a structure, the procedure is quite simple: the RTTI class holding the structure definition will be passed to a dedicated method of the context node information object.


Remark: the dynamic context node will be create on context of the view

Part 4: append data to the context

To add data to the context, we will do it the usual way: create an internal table with the same structure as the context node that will hold the data.

To create the internal table, we need also to do it dynamically using …

  1. RTTI classes to create a compatible table type and an “instance/variable” of it
  2. “CREATE DATA” statement to create data row based on  a dynamic structure
  3. Add that data row object to the internal table

STEP 01:


STEP 02:



Finally : bind internal table to the context.



Part 5: ALV life cycle

Once the data ready on the context, the binding to the (ALV) grid is quite usual… so, in the method “wddomodifyview” of the view containing the ALV view:


That’s all folks! All the plumbing stuff has been explained… it’s your turn to write this kind of application!

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.