I have an ETL job stream on the mainframe, the first JCL step is a SAS program that performs the Extract and Transform, and the subsequent Load steps are dependent on the SAS return code. We configured the Load steps to tolerate a maximum SAS return code of 4.
The Extract step is made up of a number (around 50) of SQL/DB2 queries executed in loop via PROC SQL in "pass-through" mode (CONNECT TO DB2). The return code of each SQL/DB2 query is retrieved (&SQLXRC, &SQLXMSG) and stored in a table. We already know that it's possible that an SQL is incorrect and returns a NOT OK code. If DB2 returns an OK code, the extracted data is then transformed and written to a flat file. If not, no big deal, skip to the next SQL.
The problem observed is that SAS abends whenever any one of the SQL's returns a NOT OK code, even if the 49 others returned OK. Weird thing is, when one of these incorrect SQL is encountered, the loop keeps on going, all return codes retrieved and stored, data transformed, etc. Everything looks good but at the very end, SAS abends. That's a serious problem as the subsequent Load steps don't execute.
Is there a SAS option to tell SAS to consider this remote DB2 query return code as "minor", and not abend?
We identified 3 solutions, all unpractical:
- OPTION NOERRORABEND: job does not abend but forces a return code=8, which could hide a real SAS problem
- execute SQL/DB2 queries in distinct JCL steps: makes retrieving and storing return codes and controlling job flow difficult
- pre-test SQL/DB2 queries: users can submit their own SQL, and their environment could be different than prod
Are there any other approaches? e.g. execute the SQL/DB2 queries via external calls to obscure modules: CALL MODULE_SQL_DB2(SQL, RC), etc.
Thanks to all.