This is your problem. The Designer Script console does not run your script in the gateway process. You need to put your SAP code into a gateway message handler, or better, in a script module called from a message handler. In the designer's script console, use system.util.sendRequest()
to cause your code to run in the gateway process. (And retrieve any return value.)