‎2020 Jul 13 10:55 AM
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.
Thank you in advance, Ulrich
‎2020 Jul 13 12:12 PM
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.
‎2020 Jul 14 7:45 AM
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.
‎2020 Jul 14 9:36 AM
Please use COMMENT, the button ANSWER is reserved to propose a solution.
‎2022 Jun 28 8:37 PM
Hi Ulrich,
Were you able to resolve? I am encountering same issue and I too have tried with CATCH but nothing is being captured.
‎2022 Jun 29 7:02 AM
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 tablesRegards
Thorsten