authorities are pretty straight forward; the major issue is that the IFS does not support adopted authority. So, be sure that the user ID running the job has the proper authorities. To determine authorities, use WRKLNK.
Your program can delete your streamfile, but it needs to obtain the authority to do so. The easiest way is perhaps:
- Create your program as USRPRF(*OWNER).
- Have it owned by a profile with enough authority to switch CurrentUser to a user profile that can delete the streamfile and then to switch CurrentUser back to the job user.
Unfortunately, the program cannot adopt its owner authority to delete the streamfile because, as mentioned, program adopted authority is ineffective in the /root file system. However, the Get Profile Handle (QSYGETPH or QsyGetProfileHandle), Set Profile Handle (QWTSETP, QsySetToProfileHandle) and Release Profile Handle (QSYRLSPH, QsyReleaseProfileHandle) APIs can be used to switch the job to run temporarily as a profile that has sufficient authority for your needs. These are fairly easy Security-related APIs that can make such tasks possible.
Your program owner supplies needed authority to execute the APIs and your temporary CurrentUser has the authority for the streamfile work.