how to shut down Nat RPC server internally-Nat315,EntireX711

need to allow a Nat RPC server task to shut itself down gracefully after it finishes it’s conversation. Deregister and shutdown with quiesce would be best.
EntireX is 7.1.1 and Natural is 3.1.5 on z/OS.
This is a short-term work-around until the cobol and assembler modules that are called from the Natural sub-program are cleaned up ( repeated loading of tables into memory causing an abend at end-of-memory - really old batch modules ).

You can use the NATRPC03 exit - it is called after each RPC call (before it returns data). From there, use CMTASK to start a new Natural thread - the STACK for that thread will call USR2073N until it receives 00070007 (server not registered) response. See library SYSEXTP for examples of calling CMTASK under the ASYN* examples.

Your Natural environment will need to be configured for NTASKS if you are running in batch. You can use NTASKS=1, but since CMTASK will behave as if you specified NTASKS=2, you need to ensure that you can operate with NTASKS=2 (or more) correctly (eg use reentrant ADALNKR, not ADAUSER and use shared nucleus).