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.
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).
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.
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.
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
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 …
STEP 01:
STEP 02:
STEP 03: APPEND <FS_ROW> TO <FS_TABLE>
Finally : bind internal table to the context.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
36 | |
8 | |
7 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |