on 08-31-2023 11:46 AM
Hi,
I have the following code, that I am testing for failure, which tries to retrieve a user's personnel number:
I thought the IF statement would be enough for handling errors but I get this error message when I run the code:
I'm struggling to see what to do next. Would any of you smart people have any ideas?
Thanks
Hi Robert,
It seems the Remote Function Module that you are using has an exceptions section. What is happening is this. When an invalid user id is submitted the function module is going to an Exception and that bascially crashes the function module and hence you do not get proper results.
Instead use this function module: "BAPI_USR01DOHR_GETEMPLOYEE". This does not use exception handling and will give you a proper return. See the code below.
var uname = session.info.user;
var oRFC = session.createRFC("BAPI_USR01DOHR_GETEMPLOYEE");
oRFC.setParameter("ID", uname);
oRFC.requestResults(["EMPLOYEENUMBER","RETURN"]);
oRFC.send();
var _EMPLOYEENUMBER = oRFC.getResult("EMPLOYEENUMBER");
var _RETURN = oRFC.getResultObject("RETURN");
session.utils.log('employee number: ' + _EMPLOYEENUMBER);
session.utils.log('return.ID = ' + _RETURN.ID);
session.utils.log('return.MESSAGE = ' + _RETURN.MESSAGE);
if(_EMPLOYEENUMBER === '00000000')
{
session.utils.log('No employee number found for the user');
return;
}
Don't forget to add the Function Module to the allow FM list.
Let me know if you have any issues with this.
Cheers,
Brian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's brilliant, thanks very much Brian!
User | Count |
---|---|
77 | |
9 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.