Hello,
"I would like to get the result of this task (error or success) and insert it in a Z dictionary table before it is totally completed."
Why????? You can read the status from workflow (using SAP_WAPI* function modules).
But anyway, if it isn't "totally completed" then how can anyone possibly know if it's going to be error or success?