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 SAPSQL_INVALID_FIELDNAME error

Former Member
0 Likes
601

Hi,

Is it possible to cacht SAPSQL_INVALID_FIELDNAME error ?

When Im trying :

CATCH SYSTEM-EXCEPTIONS SAPSQL_INVALID_FIELDNAME = 1.

[...]

ENDCATCH.

I got an error that there is no such exception 😕

thx for help

4 REPLIES 4
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
530

It is not possible to catch this exception. The program will have to be modified to prevent the occurrence of this exception.

Read only

0 Likes
530

I cant doit in that way - I need to allow enter 'WHERE' caluse of SQL query by a user, so after that I need to determine if that query including where part is correct... cathing exception seem to be the easiest way.. 😕

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
530

If you are in the release 6.10 or higher, try using TRY... CATCH technique and catch the exceptions of CX_SY_SQL_ERROR class. Here is an example from ABAP Help:

PARAMETERS: column TYPE c LENGTH 8, 
            value  TYPE c LENGTH 30. 

DATA spfli_wa TYPE spfli. 

DATA cond_syntax TYPE string. 

CONCATENATE column '= value' 
            INTO cond_syntax SEPARATED BY space. 

TRY. 
    SELECT SINGLE * 
           FROM spfli 
           INTO spfli_wa 
           WHERE (cond_syntax). 
  CATCH cx_sy_dynamic_osql_error. 
    MESSAGE `Wrong WHERE condition!` TYPE 'I'. 
ENDTRY.

Read only

Former Member
0 Likes
530

Hi ,,

According to your code it is not possible to catch the exception.

Regards,

Muneesh Gitta.