Assuming this is RPGLE
If you want to delete the Spoolfile from insinde the RPG
I think you will want to change the spool file to USROPN
and Open it at the beginning of your process
When you discover it should be deleted
1. Close the file
2. Issue a “DLTSPLF FILE(SpoolFileName) SPLNBR(*LAST) ”
From RPGLE that could be QCMDEXEC.
Spool file is gone — no printing.
In CL just before the call to the rpg, ovrsplf to *Hold
After the program
if good data release spool file
Your CL could pass a parameter to the program – &DelSpl
RPG would modify it to notify you if it should print or be deleted