The Goal
I'm trying to format software requirements in a tabular-like arrangement where every requirement has different properties/subheadings like it's Function, Description, ...
Every requirement and every subheading should get a LaTeX \label{} that can be referenced with some command in other places.
I want to number requirements and show them as e. g. R1 while displaying subheadings as e. g. R2/Description. The number is no problem, I added a custom environment that increments counters, but my problem is to get the subheading text for display.
Example how I want to use it:
\begin{requirement}{labelA}{Title of A}
\rFunction{The function of \SomeRefCmd{rec:labelA}, referencing \{rec:labelA:Description}}
\rDescription{The description}
% ...
\end{requirement}
(It took me an afternoon to work this solution out so I'm documenting it here for me and others with the same problem. Rest of this text is in the answer)