Hello Jan,
I'd like to elaborate more on Anja's reply, and describe the grouping option in the WebDynpro table. I'm not 100% sure it solves your problem but wanted to make sure, since it's a simple thing to try.
You could add a new field to a Grid View, and set it's value and visibility as follows:
Then define grouping for the Grid View using the new invisible field:
In the run-time you see the grouping and expand or collapse them:
Thanks,
Udi