Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

TRY ... CATCH doesn't work with EXEC SQL?

When I created a native SQL statement, I knew before, that it would take a few tries to get it working. I decided to use exception classes to avoid short dumps, but it didn't work.

Following code causes a short dump because of the dot after :xp_stras in the native SQL SELECT statement:

try.

EXEC SQL PERFORMING list.

SELECT LIFNR, NAME1, STRAS

INTO :xsl

FROM LFA1

WHERE UPPER( NAME1 ) LIKE :xp_name1

AND UPPER( STRAS ) LIKE :xp_stras.

ENDEXEC.

catch CX_SY_NATIVE_SQL_ERROR.

write: /1 'CX_SY_NATIVE_SQL_ERROR'.

catch CX_SY_SQL_ERROR.

write: /1 'CX_SY_SQL_ERROR'.

catch CX_DYNAMIC_CHECK.

write: /1 'CX_DYNAMIC_CHECK'.

catch CX_ROOT.

write: /1 'CX_SY_ROOT'.

endtry.

In ST22 you can see

Name of runtime error: DBIF_DSQL2_SQL_ERROR

Exception:

The name of the exception is empty, in other short dumps you can find there the name of the exception class. Maybe that's the reason for CATCH does'nt work, but I don't understand it.

Online help for EXEC SQL says:

Catchable Exceptions

CXSY_NATIVE_SQL_ERROR_

...

Cause: SQL-Error at the execution of a Native SQL-command.

Runtime Error: DBIF_DSQL2_SQL_ERROR

We have SAP ECC 6.0 with SAP_BASIS rel. 700 lvl. 0013.

If You have an idea why CATCH doesn't work, please tell me!

Regards,

Klaus

Tags:

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question