User exit u71a2 returns the port number of the current process, and places it in the output buffer.
See Also
Port Number, Proc Processor User Exits, who Command