BookmarkSubscribeRSS Feed
acordes
Rhodochrosite | Level 12

Building on the article

https://documentation.sas.com/doc/en/jobexeccdc/v_004/jobexecug/n1jj26acxr0ictn1riqgxoxrcehu.htm#p16... 

 

I want to pre-filter a table and use this resulting table in  the XML prompts 

<Metadata>
<DataSources>

carried out by the second job. 

 

The first job works well, but the second job does not create the form thus fails to do any meaningful. 

 

*  Make the utility macros available;

%jesutil()

*  Declare the program variables;

%global make
		type
        J1JOBID
        J2JOBID
        QUERY_VALUE
        SERVICESBASEURL;

*  Initialize the program variables;

%let DSNAME=class;

%let SERVICESBASEURL=%sysfunc(getoption(servicesbaseurl));

*;
*  Specify that the J1 job is executed in the background.  Progress
*  can be monitored using the SAS Job Execution Web Application 
*  Jobs page (/SASJobExecution/jobs).
*;
%let QUERY_VALUE=FORM('_action'='background' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v1' 'make'="&make" 'type'="&type");
/* %let QUERY_VALUE=FORM('_action'='background' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v1' 'sleep'='5' 'make'="&make" 'type'="&type"); */
/* %let QUERY_VALUE=FORM('_action'='form,prompts,execute' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2'); */

*;
*  The macro does not wait for the job to finish execution because _action=background is
*  specified.  You use the value of the J1JOBID macro variable with the
*  %JOBEXEC_WAITFOR macro to wait for the job to complete before executing further
*  statements.
*;

%jobexec_run(baseurl=&SERVICESBASEURL,
             in=&QUERY_VALUE,
             jobid_varname=J1JOBID);

%if (&_JOBRUN_RC eq 0) %then %do;
  %put NOTE: You can view the job execution object at /jobExecution/jobs/&J1JOBID;
%end;
%else %do;
  %put ERROR: Problem running the job. &=_JOBRUN_RC  &=_STATUS_MESSAGE;
%end;

*  Wait for the J1 job to finish before executing more statements;

%jobexec_waitfor(baseurl=&SERVICESBASEURL,
                 jobid=&J1JOBID)

%if (&_JOBRUN_RC eq 0) %then %do;
  %put NOTE: Job finished executing. Final job state is "&_JOBRUN_STATE".;
%end;
%else %do;
  %put ERROR: Problem waiting for the job. &=_JOBRUN_RC  &=_STATUS_MESSAGE  &=_JOBRUN_ERRMSG;
%end;

*  Execute the second job;

/* %let QUERY_VALUE=FORM('_program'='/Users/cordear1/My Folder/jobs/test sequential run v2'); */
/* %let QUERY_VALUE=FORM('_action'='json' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type"); */

%let QUERY_VALUE=FORM('_action'='form,prompts,execute' '_OUTPUT_TYPE'='html' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type");%let QUERY_VALUE=FORM('_action'='json' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type");

*;
*  The macro waits for the job to finish execution because _action=background is not
*  specified.  
*;

%jobexec_run(baseurl=&SERVICESBASEURL,
             in=&QUERY_VALUE,
             jobid_varname=J2JOBID);

%if (&_JOBRUN_RC eq 0) %then %do;
  %put NOTE: You can view the job execution object at /jobExecution/jobs/&J2JOBID;
  %put NOTE: You can view the job output at /SASJobExecution/?_jobexec=/jobExecution/jobs/&J2JOBID;
%end;
%else %do;
  %put ERROR: Problem running the job. &=_JOBRUN_RC  &=_STATUS_MESSAGE;
%end;

 

I suspect that I'm missing the correct definition of the _action or _output_type parameter in the following line.

 

%let QUERY_VALUE=FORM('_action'='form,prompts,execute' '_OUTPUT_TYPE'='html' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type");%let QUERY_VALUE=FORM('_action'='json' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type");

pic0.pngpic1.pngpic2.pngpic3.png

 

 

2 REPLIES 2
DeMer
Obsidian | Level 7

One thing I think for the error message:

 

    "There is no handler defined for the path /SASJobExecution/jobs..."

 

the URL should be /jobExecution/jobs instead of /SASJobExecution/

arthurdpereira
Obsidian | Level 7

Hello @acordes, are you good?

 

So, the problem is that you're overwriting the QUERY_VALUE macro variable twice on the same line:

 

%let QUERY_VALUE=FORM(...); %let QUERY_VALUE=FORM(...);

Only the second assignment actually takes effect. So, if you intended to run the job with both settings (HTML and JSON), only the last one (_action='json') is being used.

 

You should:

  • Use only one %let QUERY_VALUE=FORM(...) statement at a time, depending on the output you want;
  • If you want to run both jobs (HTML and JSON), separate them into two blocks, each with its own %let and %jobexec_run.

You're overwriting the macro variable, so only the last value is used. Split them up, and run each job separately with its own macro assignment.

SAS Job Execution Developer
I love sharing knowledge and helping the community.

Follow me:
GitHub | LinkedIn

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1049 views
  • 0 likes
  • 3 in conversation