Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
At the very least, your program must be Assembled/Linked as AMODE/RMODE 24, because you're using DCB's.
After the CLOSE of both files, you're not restoring the caller's R13 from the 18-word savearea (L 13,4(,13)). Also, the RETURN Macro is incomplete, as it needs to specify RETURN (14,12),RC=(15). It's always a good idea (and it can't hurt) to set R15 to a value (such as F'0') and return it to the Caller. If the Caller is COBOL, then this would be the RETURN-CODE Special-Register. I think PL/I's counterpart is PLIRETC, but I'm not 100% certain.
I would advise you to use R3 instead of R12 as the base-register, because if the caller is Language Environment compliant, R12 always contains the address of the CEECAA and if you ever change the sub-program to be LE compliant, you'll need this address.
The ABEND information in SYSOUT should give you the address in the sub-program that caused the S0C1 (an invalid OP CODE), which is easy enough to find in the listing.
What could be happening is after the RETURN (which needs to be fixed), execution falls through and hits a DS/DC expansion in the DCB because an LTORG should not be generated (don't see any literals).