cancel
Showing results for 
Search instead for 
Did you mean: 

XS job fails to Start

shyam_uthaman
Participant
0 Kudos

Hi All,

I have a XSJS that I need to run :

The XS job file looks like the below:


{

    "description": "Valid description",

    "action": "package_path::file name",

    "schedules": [

       {

          "description": "Valid description",

          "xscron": "* * * * 9 * 59",

          "parameter": {

            

             }

       }

    ]

}

As soon as it is run, it goes into error saying ERROR and that's all the log we get.

This is the first time we are attempting to run a XS job. So I assume we are missing some settings or that there is a problem in the above code.

The XSJS on its own runs fine, only when it is called from the scheduler, it shows an error. The log cleanup tab shows a lot of things as not configured.

Could this be a problem? Please let me know. Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

Hello Shyam,

can you provide the information who you have added the XSJS function to the job definition. In your "pseudo" information you wrote "package_path::file_name", which indicates that you provided only the XSJS file name. But in that case a function has to be provided ("package_path:file_name::function_name).

Best Regards,

Florian

shyam_uthaman
Participant
0 Kudos

Hi Florian,

Sorry for the incomplete information.

Yes- the function name is mentioned.

For some reason, when run from the XS dashboard, it tries to execute the Catch block of the xsjs script and says $.response is undefined.

If I call the function directly in JS, it works perfectly fine but somehow not from the scheduler.

Regards,

Shyam

pfefferf
Active Contributor
0 Kudos

Hello Shyam,

objects like $.reponse and $.request are not available in that situation, cause the xsjs coding is not executed in a kind of web-usage (so the web request/response objects are not there -> the job scheduler does not provide request information and does not handle the response object).

I assume, your test which was executed successfully, is done calling the xsjs in the browser, right?

Regards,

Florian

shyam_uthaman
Participant
0 Kudos

Damn.. Is that so? That creates a lot of problems.

To answer your questions:

Yes. From the browser.

Also tested by calling it from at the end of the JS code function().

What do you recommend in this case?

Thanks,

Shyam

pfefferf
Active Contributor
0 Kudos

W/o knowing what you wanna reach nothing more can be added here to that what was already said.

shyam_uthaman
Participant
0 Kudos

I am sending some data from a table to an external webservice and then catching the output and doing some checks and then inserting it into a table in HANA.

pfefferf
Active Contributor
0 Kudos

And for what you need $.response in that case? You get a specific response object from the http client used for the webservice call.

shyam_uthaman
Participant
0 Kudos

Hi Florian,

You are right. Being new to XS scripting, I made a rookie mistake of putting some error messages in the response.

The jobs are executing fine now. Thanks for the quick responses.

Happy Holiday today.

Shyam

Answers (1)

Answers (1)

former_member182302
Active Contributor
0 Kudos

You would need to encapsulate in a function in XSJS and call it for it to work

Regards,

Krishna Tangudu

shyam_uthaman
Participant
0 Kudos

Hi Krishna,

It's already in a function. Sorry that my earlier placeholder did not illustrate that fact.

Please refer to my reply to Florian for updates on the problem.

Shyam

former_member182302
Active Contributor
0 Kudos

Hi Shyam,

I guess when using .xsjs file you might have set response parameters to check the result in the response. Do remove the response settings from your xsjs file and it should work fine.

if you have mentioned something like this in your script

       $.response.contentType =  "application/xml";

       $.response.setBody(response.body.asString());

       $.response.status = $.net.http.OK;

Try removing them and then execute

Regards,

Krishna Tangudu

shyam_uthaman
Participant
0 Kudos

Thanks Krishna for the reply.

I already fixed the issue with inputs from Florian.

Removed all these statements and now everything works smoothly.