on 03-28-2017 11:35 PM
Hi all,
We have some code to do an outbound http call and write te response to a table when we call it manually this works fine. However when I try to automate this in via an xsjob, I keep getting the message: $.response is undefined.
Any help would be greatly appreciated.
Kind regards,
Scott Wery
--partial code below
var destination_package= "remiqz.ETL";
var destination_name= "Exchange_Rate";
function run(){
try {
//Coding for exchange rates import
var dest= $.net.http.readDestination(destination_package, destination_name);
var client= new $.net.http.Client();
var req= new $.web.WebRequest($.net.http.GET, "?base=EUR&symbols=USD,GBP");
client.request(req, dest);
var response = client.getResponse();
$.response.contentType= "application/json";
$.response.setBody(response.body.asString());
$.response.status= $.net.http.OK;
Objects like $.response or $.request are not available in background processing. They are only available in case you call the xsjs script via a client (like a browser).
The question is what you wanna really reach. I don't think, that you wanna set the response for a specific client call in background processing.
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Florian,
Thanks for clarifying again 🙂 The goal here is:
Automatically read a web-service to obtain an exchange rate and store this in HANA.
We currently do not have an SAP ERP installed to read exchange rate tables, so this is why we are looking into a webservice.
Any pointers in how to solve are much appreciated
kind regards, Scott
Ok, to store the data you do not need to return the response you received from client.getResponse() via the $.response object, cause you have no client.
The simplest way would be to use the $.hdb db interface to store the data in your target table.
Maybe it is also an option you to use SAP Landscape Transformation to replicate the required tables to your HANA instance. From my point of view this would be the better solution for that scenario compared to the usage of a web service call.
Then I do not get your situation.
You have created an xsjs script which calls a web service returning some exchange rate information. This script is scheduled via an xsjob. The result is stored in a table.
Why and for what you need the $.response in your script and what you wanna reach in addition to the storage of the data in your db?
You should try to run you XSJS app as XS service
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.