BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rgreen33
Pyrite | Level 9

I have a job created in SAS DI Studio.  I have setup two actions for the job under Status Handling (Send Email on Success; Send Email on Error).  The email is working fine.  However, I am ALWAYS getting the SUCCESS email...never getting an error.  I have intentionally introduced an error into my code for testing this...but I am still getting the SUCCESS email.  My DI Studio job is essentially a single "User Written" node that is ETL'ing data to LASRLIB.  As you can see from the sreenshot below, my job is actually ending in an Error.  However, in the example below, I still get a Success email.  I have double checked my Status Handling setup.  I even attempted to remove the Success email, leaving only the Error email...and in this case, I get NO email.  What am I missing here?  I am new to SAS, so I am guessing that it is something obvious Smiley Very Happy.

 

Capture.JPG

 

Thanks,

Ricky

1 ACCEPTED SOLUTION

Accepted Solutions
rgreen33
Pyrite | Level 9

Well, I figured out what I am missing.  Essentially, since I am using User Written code, I must include the necessary code to set TRANS_RC (the actual macro code does not need to be included in the User Written code).  All that is needed is the necessary calls to set TRANS_RC.  This can be accomplished via the following calls (stratigically placed after certain statements within the code - the line that you use is also based on the statement that is being checked):

 

     %RCSET(&syserr);

     %RCSET(&syslibrc);

     %RCSET(&sqlrc);

 

Thanks,

Ricky

View solution in original post

3 REPLIES 3
rgreen33
Pyrite | Level 9

Just to add a little more detail to my original question.  I also attempt to move this Status Handling from the job level down to the tranformation level.  Since the User Written transformation does not have the tab for Status Handling, I added a "Return Code Check" to my diagram.  I removed the Status Handling at the job level and added an action for Success and Error on the Return Code Check transformation.  Unfortunately, I am still seeing the same results.  No matter what I try, I get the Success email.  I've got to be missing something here.

 

Thanks,

Ricky

rgreen33
Pyrite | Level 9

OK...after doing some more research and testing, I see that my &trans_rc is always returning 0...thus, the reason that I am always getting Success.  So, if someone could, please tell me if I am on the right track here.  Since I am using User Written code, I am thinking that I need to take care of &trans_rc myself.  I can see in the default code that trans_rc is being set to 0...but then never set again.  So, I am thinking that I need to do something like the following:

 

%macro RCSET(error);
%if (&error gt &TRANS_RC) %then
%let TRANS_RC=&error;
%if (&error gt &JOB_RC) %then
%let JOB_RC=&error;
%mend RCSET;

 

and then call this macro after my differnt statements.  Am I on the right track here?

 

Thanks,

Ricky

rgreen33
Pyrite | Level 9

Well, I figured out what I am missing.  Essentially, since I am using User Written code, I must include the necessary code to set TRANS_RC (the actual macro code does not need to be included in the User Written code).  All that is needed is the necessary calls to set TRANS_RC.  This can be accomplished via the following calls (stratigically placed after certain statements within the code - the line that you use is also based on the statement that is being checked):

 

     %RCSET(&syserr);

     %RCSET(&syslibrc);

     %RCSET(&sqlrc);

 

Thanks,

Ricky

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1680 views
  • 0 likes
  • 1 in conversation