Hello,
"I am developing a program to close the work items/ exceptions which we used to get in our sap inboxes."
Why are you doing this?
My approach would be to stop sending the workitems in the first place, if they are unnecessary.
If they are necessary then it's the users that should be completing them, not some ABAP program.
But anyway, you could also look at logically deleting the workflow instead, if they're completely unwanted.
regards
Rick Bakker