Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member194152
Contributor
0 Kudos

Dynamic Node in Web Dynpro ALV

  Dynamic programming is very helpful to provide solution for some critical business requirement in SAP GUI and this legacy is carried forward to the
dynpro era also. Here I worked on a requirement on which output table columns are not fixed. Based on material number in output all other data has been

changed based on classification maintained for that material in material master, so we cannot fix field catalog for this requirement or in web dynpro we
cannot create fixed node and attribute to map the ALV d
ata in interface controller.

So to achieve this following steps need to be taken care :

Step 1 :

Create an internal table which having information of field name and field type(data element) for that material, like :

 

here in this type :

FNAME - Hold the name of the field

FTYPE - Hold Data type for the field

Now based on dynamic condition fill this internal table.

Step 2 :

Create Dynamic Structure and Dynamic Table based on fields fill in above steps:

Here I have created a method which is having field information in table "gt_field_list".This method having 2 exporting parameter which give
reference of dynamically created data type reference of s
tructure and internal table, later you can assign these variable into field symbols for
further processing.

E_STRUCTURE -Will return reference for structure.

E_TABLE           - Will Return standard internal table reference with line type as e_structure.

Step 3

After getting reference of structure and table call above method in get data method and do following coding. After the below coding <f_line1> and <f_tab>
field symbols are ready to use to fill internal final data.

Step 4

 

Create Dynamic node in Web Dynpro Application:

Following code will create a node named "DYNAMIC_NODE" in root node of view.

Here node attributes will be added from dynamic structure "gs_structdescr"  and this structure is of same type describe in step 2   "e_structure".

  

Step 5 :

After creating dynamic node now its turn to get reference of newly created node and bind data for this node to the internal table which we filled in step 3.

Step 6:

After binding the table now its turn to instantiate ALV component which can be done by following steps:

Step 7: Execute application for dynamic node.

Thanks and Regards,

Gagan Choudha