It is uncommon to want to do this. If you are SVC-entered or PC-entered, you should know (because at some point you set up the definition). If you are branch-entered when it might be either primary or AR, you would usually save status via BAKR, then switch unconditionally to whichever mode you want to run in and then when you want to determine what mode your caller was in you would use ESTA with the option to extract the PSW from the linkage stack and look at the result (doing the same sort of test that was mentioned if you had done EPSW).
It is typically much far more convenient to run in a known state and then, if you need to do something based on your called state, switch conditionally to that, and then switch back to the known state. Peter Relson z/OS Core Technology Design
