Use the automatic SYSDBRC macro variable
to capture DB2 return codes when using the DB2 engine. The macro
variable is set to the last DB2 return code that was encountered only
when execution takes place through
SAS/ACCESS Interface to DB2 under
z/OS. If you reference SYSDBRC before engine processing takes place,
you receive this message:
WARNING: Apparent symbolic reference SYSDBRC not resolved.
Use SYSDBRC for conditional
post-processing. Below is an example of how to abend a job. The table
DB2TEST is dropped from DB2 after the view descriptor is created,
resulting in a -204 code.
data test;
x=1;
y=2;
proc dbload dbms=db2 data=test;
table=db2test;
in 'database test';
load;
run;
proc access dbms=db2;
create work.temp.access;
table=user1.db2test;
create work.temp.view;
select all;
run;
proc sql;
execute(drop table db2test)by db2;
quit;
proc print data=temp;
run;
data _null_;
if "&sysdbrc" not in ('0','100') then
do;
put 'The DB2 Return Code is: ' "&sysdbrc";
abort abend;
end;
run;
Because the abend prevents
the log from being captured, you can capture the SAS log by using
the SAS system option, ALTLOG.