Hi Nitin,
I think we have done a similar implementation .xsjs script, to stamp the user information who is downloading the file from UI.
Created a proc which will insert the user information like User ID in that table.
in XSJS we invoked the function
var sUserId = $.session.getUsername();
var sProcCall = 'CALL "_SYS_BIC"."xxx.xxx.xxx.xxx/SP_XXXX"(User ID)';
var sStmt = oDatabaseConnection.prepareCall(sProcCall);
sStmt.setString(1, sUserId);
Hope this will give you some pointer in building your logic.
Regards,
Chandan