04-27-2017 05:44 AM
I'm altering a job in Data Integration Studio that has a user written transformation.
I want the transformation to be ignored in case it returns an error and the job to end successfuly. Any idea how to do this?
04-29-2017 05:41 AM - edited 04-29-2017 05:46 AM
I'd consider this bad design. If the user written code throws an error for conditions where it shouldn't then amend your user written code to deal nicely and in a controlled manner with such conditions.
The consequence of just ignoring/reseting an error condition: You'll miss the cases where it's an error condition which is caused by something where you actually want the job to end with errors.
I strongly recommend that you amend your user written code and if you don't know how then post the code here and ask the questions.
If you really want to go for ignoring/reseting an error condition then look into S
I'm not sure though that you really can suppress/reset all error codes (some stuff is readonly). You almost certainly would have to implement all such checks at the end of your current user written code and before any DIS generated error handling at the end of each transformation comes into play. But again: I strongly recommend that you amend your user written code instead of trying to work around the existing code.
05-02-2017 04:43 AM
05-02-2017 05:37 AM
Your user written code encounters a condition (email server down) where you don't want the error passed down to the calling process. That's a shortcoming of your code as implemented. Amend your code so that it deals nicely with such a condition.
I can think of two approaches.
1. (preferred) use FUNCTIONS (not statement) filename() and fopen(). This let's you check return codes without getting the error passed down to SAS if something is not available.
2. generate the "send email" code and batch submit it as a separate process out of your SAS program (with options noxwait and noxsync). The batch submitted process will still end with error if the mail server is not available but your calling process shouldn't receive this error code. You'd still have the 2nd job ending with error which in a production environment with job monitoring is something "ugly". The advantage of approach 2 would be: It always works as intended even if the mail server should go down in the middle of the process where you write the email out of SAS.
I can't easily test any of above options right now - but they should both work. May be someone else comes up with an even better approach.
05-02-2017 07:20 AM
05-02-2017 07:33 AM - edited 05-02-2017 07:43 AM
Yep, that works for now but it's imho a brute force approach which fights the symptoms and not the cause. You're now also going to suppress other error conditions you didn't think about.
05-02-2017 09:24 AM
"it's imho a brute force approach which fights the symptoms and not the cause."
@Patrick I agree it's a brute force approach because I don't know a lot of error handling in SAS and I don't know the functions you mentioned.
But I created a separate job just for sending the email, and since sending the email isn't an essential part of the process, I guarantee that the chain of events isn't stopped by any problems related to sending the email and this way I still get the error report.
I wasn't the one writting the code for sending the email, but here it is in case you or anyone has a idea for a more clean solution:
%macro envia_email; %let datetime_var = %sysfunc(time(),hhmm.); %let RC2=%eval(&SYSERR); %let RC1=%eval(&SYSRC); %IF &RC1=0 AND &RC2=0 %then %DO; FILENAME Mailbox EMAIL TO=(&VAR_GALILEU_EMAIL_LIST.) Subject="PTC | &VAR_GLOBAL_AMBIENTE. | PDS da cadeia &VAR_ODATE_CHAR. " attach=(&File content_type="application/xlsx"); DATA _NULL_; FILE Mailbox; PUT "Segue em anexo o ficheiro do PDS."; PUT " "; PUT " "; PUT "Não responda a este email"; PUT "----------------------------------Auto-reply-----------------------------------------------"; RUN; %END; %mend envia_email; %envia_email;