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:<ol>
<li>Create your program as USRPRF(*OWNER).</li><li>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.</li>
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 <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/sec1.htm”>Security-related APIs</a> 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.