BookmarkSubscribeRSS Feed
Mayt
Obsidian | Level 7

Hi everyone

I have a job flow that contains  jobs inside. Some jobs need to run in parallel. I used to execute it by right click--> execute and set time trigger, and the job flow worked fine. 

Mayt_0-1708605633123.png

The problem is right now I want to execute the job flow through API. But can't find any solution.

I've tried one solution like Instead of creating a job flow, I created job definition then put the each-step code in it and used %include to run the each-step code. Then executed it through API. But It can't run in parallel and didn't show if there are errors each step.

My code in job definition is something like this:

/*include file*/
FILENAME first_code FILESRVC FOLDERPATH='code path'  FILENAME='mycode1.sas';
FILENAME sec_code FILESRVC FOLDERPATH='code path'  FILENAME='mycode2.sas';
FILENAME third_code FILESRVC FOLDERPATH='code path'  FILENAME='mycode3.sas';

%include first_code;
%if &SYsrc=0 %then %do;
    %put Return Code for first_code: &SYSRC;
    %include sec_code;
    %if &SYsrc=0 %then %do;
        %put Return Code for sec_code: &SYSRC;
        %end;
     %include third_code;
        %if &SYsrc=0 %then %do;
        %put Return Code for third_code: &SYSRC;
        %end;
      

So if you guys know how to execute the job flow through API, please let me know.

Thank you in advanced.

3 REPLIES 3
ChrisHemedinger
Community Manager

Yes, SAS Viya has a Job Execution API. You can also list Jobs and get status of running Jobs.

 

See examples here:
https://github.com/sassoftware/devsascom-rest-api-samples/blob/master/Compute/jobExecution.md

 

And documentation:
https://developer.sas.com/apis/rest/Compute/#job-execution

 

This Postman collection might also help for testing:
https://github.com/sassoftware/sas-rest-api-postman-collections/tree/master/jobs-crud

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Mayt
Obsidian | Level 7

So I need to call the job flow in job definition, Then execute the job definition right? How can I call the job flow in job definition? Can I just use %include like I did in my code. But I think job flow doesn't have path.

DeMer
Calcite | Level 5

Can you use the job chaining macros that are provided with the Job Execution Webapp?

https://go.documentation.sas.com/doc/en/sasstudiocdc/v_047/pgmsascdc/jobexecug/p0qsxn76pbh5qjn1iob6u...

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 353 views
  • 1 like
  • 3 in conversation