I need to send a mail to the user that the job which is submitted has ended in error, for this how should i retrieve/fetch the email id of the user?
If you have defined the users email in the System Distribution Directory then you can retrieve the email with this RPG code:
chain User_Name qaokl02a;
if %found;
chain (wos1dden : machine) qatmsmtpa;
if %found;
domroute = %xlate(up : lo : domroute);
emailaddress = %trim(smtpuid) + '@' + %trim(domroute);
endif;
endif;