BookmarkSubscribeRSS Feed
xiaoys0725
Fluorite | Level 6

Hello, 

 

I am using angularjs to invoke runCode action while I came across the error"table does not exist".

 

Below is my code. 

 

 

var loadT={caslib:'MYCASLIB3',path:'cart.sashdat',casout:{name:'cart',caslib:'MYCASLIB3'}};

var Code={code:"data cart;set cart;run;"};

 

 

$http({
method:'POST',
url:baseURL+'/actions/loadTable',
headers:_headers,
params:loadT
}).then(function(){$http({
method:'POST',
url:baseURL+'/actions/runCode',
headers:_headers,
params:Code
}).then(function callBack(response){console.log(response);});});

 

So you can see that before I invoked the runCode action i have already excecuted loadTable action, I know I loaded table sucessfully otherwisde I cannot get the runCode action executed. I don't know why I still receive an error that " ERROR: The table cart in caslib MYCASLIB3 does not exist." , which means that it did look for cart in the caslib MYCASLIB3, but it does not find it. 

 

Anybody knows why?

 

2 REPLIES 2
kumardeva
SAS Employee
Can you send the log output from your loadTable action?
Also:
1. Is the path you specified accessible from cas?
2. To check the status of an action call you need to check the disposition object in the response. Cas will return if there are programming errors. This is the reason your .then executed.
It would be easier to discuss your use case if we can see the log output.
Cheers...
Deva

Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now:

kumardeva
SAS Employee

Just to complete the thought:

 

if you call cas action via REST (or by scripting) always check the disposition object in the response.

While cas will  return a http code of 200 when you have programming errors it does return useful information in the disposition object and in the log object. You should always check the disposition object before going to the next step - bullet proof your app.

 

A typical code might look like this:

 

if (dispostion.statusCode !==  0  || disposition.severity === ‘Error’) {

   throw  ‘Huston we have a problem’;

} else {

  …do whatever you want…

}

 

And a second thought:

 

If you plan to make a series of REST calls for cas actions, consider switching to scripting on the server using the casl  language via the sccasl.runcasl action. This will save you multiple round trips to the server. You can use the casl language features to script your actions.

 

Cheers...
Deva

PS:  If you are using REST API to access Viya please take a look at https://github.com/sassoftware/restaf for a very useful js library.


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now:

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1932 views
  • 1 like
  • 2 in conversation