Right - so you're not after runtime information, you're after static information. That's an important distinction to make.
Simple answer: scan/read the ABAP code into an internal table and write a program to analyse it. I'm sure you can figure out the logic - it's not exactly difficult. You could even create your own function module to do it.