Framing around PVC pipe
Your pictures are perfect, except you need a Beta before the &quot;A&quot; - which is just a header to go across joists or blocking.   This will give you the stability.
For extra stability you can add a parallel header (Zeta) at the top on the same line as &quot;C&quot; and block Beta and Zeta - don't need a lot of blocking.   That's it.
And because I want you to do it right... I need to know your location... as the cavity for the PVC is more useful in some locations than others.
Based on last picture:

Bottom of top section 2x4 down slightly to fully align with blocking.
Flip top plate so flat part attaches.
Add a parallel 2x4 to top plate against wall.
Add a few blocks between two top plates.

This is about as sturdy as you can get.