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

SQL return codes...

Former Member
0 Likes
865

Hi all,

I'm curious about the return code for a SQl statment embedded in my ABAP program. The help states that any code other than 0 suggests there was an error executing the SQL statement. So...I include the following to test for an error:

IF SY-SUBRC <> 0.

MESSAGE I000(38) WITH 'Error retrieving data from MAKT MARA MARC'(M01).

LEAVE LIST-PROCESSING.

ENDIF.

I notice that if no records are returned my app throws the message and exits. Why? No records returned doesn't necessarily mean an error..it just means the query returned no records. Also...what would be the correct way to handle the error so no recoreds returned doesn't poop on me?

regards,

Mat

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
588

Hi,

then it will return sy-subrc 4 you can write case endcase.

with the different actions to take on each return

grtz

Koen

3 REPLIES 3
Read only

Former Member
0 Likes
589

Hi,

then it will return sy-subrc 4 you can write case endcase.

with the different actions to take on each return

grtz

Koen

Read only

Former Member
0 Likes
588

(double post, sorry)

Koen

Message was edited by: Koen Labie

Read only

Former Member
0 Likes
588

The return code for a SELECT statement just tells you if any records were returned or not. If there is an SQL error, the program will likely dump.

Rob