System abend

S047: Program not APF authorized

An S047 abend means a program running without APF authorization issued a supervisor call that only authorized programs may use. Usually the program came from a library that isn't APF-authorized, or one unauthorized library in STEPLIB took authorization away from the whole step.

Also written as 047, abend 047, system abend 047, S047 APF, SYSTEM=047.

What it means

Some z/OS services are restricted to authorized programs, because they can change storage keys and get around security checks. A program gets that authority through APF, the authorized program facility. When a program without it issues one of those supervisor calls (SVCs), z/OS ends the step with system completion code 047. There is no reason code.

A job step runs APF-authorized only if the program that starts the step was link-edited with the authorization code AC(1) and was loaded from an APF-authorized library. When the step has a STEPLIB or JOBLIB, every library in that concatenation must be authorized. One unauthorized library anywhere in it is enough to make modules loaded from the concatenation unauthorized.

Libraries in the link list are treated as authorized by default. That's why a program can work when it comes from the link list and fail with S047 when someone runs a copy of it from a private library.

Common causes

  • The program was loaded from a library that isn't in the APF list, often a test or personal load library in STEPLIB.
  • STEPLIB or JOBLIB concatenates an unauthorized library with authorized ones. Putting a test library in front of a production STEPLIB is a common way to cause this.
  • The program was link-edited without AC(1), so it never runs authorized, even from an APF library. A relink with different binder options can drop the attribute.
  • The library is in the APF list by volume serial and has since been moved to another volume. The APF entry now points at a volume where the library no longer lives.
  • Under TSO, the command or program isn't in the AUTHCMD or AUTHPGM list in the IKJTSOxx parmlib member, so TSO runs it unauthorized.

How to find the problem

  1. The IEA995I symptom dump names the load module that made the restricted call.
  2. In a dump, look at the two bytes just before the PSW address. They are usually the SVC instruction, X'0A' followed by the SVC number in hex, which tells you which service was refused.
  3. List the APF libraries with the operator command D PROG,APF, or ask a systems programmer to. Compare that list with every library in the step's STEPLIB or JOBLIB.
  4. Check the program's authorization code. The ISPF member list of a load library has an AC column, and an AMBLIST or binder listing shows it too.
  5. If it fails only under TSO, compare the command name with the AUTHCMD and AUTHPGM entries in IKJTSOxx. The TSO PARMLIB LIST command shows the settings in use.

How to fix it

  • Run the program from its authorized production library, not from a private copy.
  • Remove unauthorized libraries from STEPLIB or JOBLIB. If you need a test library there, ask for it to be added to the APF list on the test system.
  • If the program must run authorized, link-edit it with AC(1) and put it in an APF-authorized library.
  • If the library moved, have a systems programmer correct the APF entry with SETPROG APF and in the PROGxx member, so the change survives an IPL. SMS-managed libraries can be listed without a volume, which avoids this problem.
  • For TSO, ask for the command to be added to AUTHCMD or AUTHPGM in IKJTSOxx. A changed member can be activated without an IPL.

What it looks like

IEA995I SYMPTOM DUMP OUTPUT
  SYSTEM COMPLETION CODE=047
     ACTIVE LOAD MODULE           ADDRESS=0001A000  OFFSET=000000F6
     NAME=GLUTIL04
IEF450I GLMAINT1 STEP010 - ABEND=S047 U0000 REASON=00000000

Questions

Why does my program work in production but get S047 in test?

Production runs it from an APF-authorized library or the link list. In test, a private library in STEPLIB usually isn't authorized, and that removes authorization from modules loaded through it.

Can I mark my own load library as APF-authorized?

Only a systems programmer can, and most sites control it tightly. Code in an APF library can bypass security, so adding a library to the list is a change that security teams review.

Does S047 have a reason code?

No. To see which service was refused, look at the SVC instruction just before the PSW address in the dump. The byte after X'0A' is the SVC number.