I suppose that you mean to enable or disable complete nodes, not modules in a rack.
I think that in theory you could use PNIODIAG to detect the nodes that are connected.
But how can you know if a node is not connected that it is because it has intentionally been removed, or because there is an error in the node or the cabling ?
I think you have to let an operator specify which nodes are installed on an HMI. Then you can use SFC12 D_ACT_DP to disable or enable individual nodes. I do that, and it is quite easy.
As for enabling/disabling modules in a rack, then S7-400 has a "Configuration in Run" (aka "CiR") that can do this for modules in an S7-400 rack. Have never tried it though.