Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Catch DBSQL_TABLE_UNKNOWN

2,237

We have a secondary database connected, using tc DBCO. Read access is set up and works fine.

We use some dynamic SELECT on different table names, where P_DBCON is the secondary database.

Example

*- Secondary database

TRY.
SELECT COUNT( * ) FROM (lv_tabname)
CONNECTION (p_dbcon).
CATCH cx_sy_dynamic_osql_semantics.
MESSAGE ….
ENDTRY.

Problems occur, if an invalid table-name is specified in LV_TABNAME. The system does note raise a catchable exception CX_SY_DYNAMIC_OSQL_SEMANTICS. Instead it creates a runtime error DBSQL_TABLE_UNKNOWN.

  • Is there a way to determine, whether table LV_TABNAME exists in the secondary db? Note that there is no metadata (e.g. a table DD02L) to access to find out.
  • Or is there any way to catch this scenario, so it won’t result in a dump?

Thank you in advance, Ulrich

5 REPLIES 5
Read only

Sandra_Rossi
Active Contributor
1,648

Are you sure that ABAP doesn't catch that, did you try with CATCH cx_root? Check SAP notes or contact SAP support to make sure that it's not just a bug.

By the way, the ABAP documentation says:

The database tables or views specified in the current ABAP SQL statement 
must be active in ABAP Dictionary in the current AS ABAP regardless of the
specified database connection. In a secondary database, an identically 
named and usable object with a suitable structure must exist for each 
database table or view specified in the current ABAP SQL statement. If not,
an exception is raised.
Read only

0 Likes
1,648

Hi Sandra,

yes, I tried to Catch w/ different exception classes, starting from CX_SY_DYNAMIC_OSQL_SEMANTICS (which Catchs on a primary db) and going up the class-tree to CX_ROOT. It still dumps 😕

The requirements named in the ABAP documentation are fulfilled: The secondary db is a subset of the primary db.

Read only

0 Likes
1,648

Please use COMMENT, the button ANSWER is reserved to propose a solution.

Read only

former_member747610
Discoverer
0 Likes
1,648

Hi Ulrich,

Were you able to resolve? I am encountering same issue and I too have tried with CATCH but nothing is being captured.

Read only

ThorstenHoefer
Active Contributor
0 Likes
1,648

For dynamic sql, it is always a good choice to use class cl_abap_dyn_prg.

You can check the table name with the function

DDIF_NAMETAB_GET or DD_GET_NAMETAB_HEADER

In case your database system for your connection is HANA,

you can check the table name with the systemview tables:

select * from tables

Regards

Thorsten