cancel
Showing results for 
Search instead for 
Did you mean: 

Native SQL throwing 'CX_SY_NATIVE_SQL_ERROR' exception

Former Member
0 Kudos

Hi All,

I have written a native sql query in my report and it s working fine in development query.

But in case of training environment it is throwing 'CX_SY_NATIVE_SQL_ERROR' exception:

EXEC SQL.

   OPEN C1 FOR

   SELECT *

     FROM  <table name>

     WHERE ( UPPER(<field name>) like :lv_facilitydesc

     or <field name> like :lv_facilitydesc )

     and <field name> = :lv_delivery_office

     AND <field name>= :SY-MANDT

ENDEXEC.

DO.

   count = count + 1.

   EXEC SQL.

     FETCH NEXT C1 INTO :ls_data               // This is the statement which is throwing exception

   ENDEXEC.

   IF sy-subrc <> 0.

     EXIT.

   ENDIF.

   APPEND ls_data TO lt_data.

ENDDO.


Please help.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member198180
Active Participant
0 Kudos

Hi Richa,

The class CX_SY_NATIVE_SQL_ERROR has been released internally in SAP version 4.6C.

May be you can not use that one as reference.

Generally, if you see TRY...CATCH statement to handle error has been promoted by SAP from version 6.0 onwards.

please check the note SAP Note 1063473.

Thanks&Regards

Kalpana

former_member202253
Participant
0 Kudos

Hello Richa,

Could you please check "ls_data" columns, as per the code( Select * ) you are trying to fetch all columns from table. If "select *" is case then all the column should match with "LS_DATA".

If columns are not matching with LS_DATA then select only those column which are available in LS_DATA.

Hope this will help you.

Thanks & Regards,

Nikhil

Former Member
0 Kudos

Hi Kalpana,

Please elaborate your answer.

And the note you have mentioned does not seem relevant to my query.

Thanks & Regards

Richa

Former Member
0 Kudos

Hi Nikhil,

I have already checked this and made sure this is not the problem in my case.

Please suggest.

Thanks & Regards

Richa