Before I try to make the code below runnable as a standalone program, maybe
someone can suggest what's going on here. I have a program (an API) that may
write to SYSPRINT (if there's an error, and it hasn't been passed a buffer to
return the error message to the caller) using the following sequence.
Essentially it's just doing an OPEN, PUT, CLOSE. And that works as expected.
BUT it seems to eat storage. That is, if I run a program that calls the API
repeatedly and invalidly, it writes the errors to SYSPRINT, but gets an S878
reason code 10 after 1900-odd iterations. I've tinkered, commenting out the
PUT: no change. So it's not the actual PUT that's irritating it. If I comment
out the CLOSE, it gets the S878 after fewer iterations, which sort of makes
sense: it's leaving the file open. But why is it running out at all? The DD is
just SYSPRINT DD SYSOUT=*, and REGION=0K. I feel like I'm missing something
basic and obvious here (not the first time).
Any suggestions gratefully accepted!
* Message is in WORKMSG on arrival here
STORAGE OBTAIN,LENGTH=XDCBL,LOC=BELOW Get 24-bit DCB buffer
LR R4,R1 Move pointer to our 24-bit DCB
MVC 0(XDCBL,R4),XDCB Copy the DCB down below the line
MVC WORKDWRD(XOPENL),XOPEN Copy the OPEN macro model
OPEN ((4),(OUTPUT)),MODE=31,MF=(E,WORKDWRD) Open for write
LTR R15,R15 Did that work??
JNZ WRITTEN No, skip write, release DCB buffer
PUT (4),WORKMSG Write the message
MVC WORKDWRD(XCLOSEL),XCLOSE Copy in CLOSE template
CLOSE ((4)),MODE=31,MF=(E,WORKDWRD) And do the CLOSE
WRITTEN DS 0H
STORAGE RELEASE,LENGTH=XDCBL,ADDR=(R4) Release DCB buffer
***MUCH LATER***
XDCB DCB DDNAME=SYSPRINT,DSORG=PS,MACRF=PM,RECFM=FBA, *
LRECL=133,BLKSIZE=3990
XDCBL EQU *-XDCB Length of our DCB so we can copy it
XOPEN OPEN (*-*,(OUTPUT)),MODE=31,MF=L
XOPENL EQU *-XOPEN
XCLOSE CLOSE (*-*),MODE=31,MF=L
XCLOSEL EQU *-XCLOSE