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

Sy-Subrc & Is Initial Check

Former Member
0 Likes
5,645

Hi,

Do we have to check for sy-subrc & is intial chek before every READ or Select Statement.

At which points can we ignore these checks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,415

hi sneha,

good question...

yes it is necessary to check sy-subrc = 0 after READ statement else it will return a garbage value...

it is a good habbit of checking sy-subrc = 0 after read statement...

In case of check initial statement, it should be check when u are using FOR ALL ENTRIES on particular internal table....bcoz if u don't use check statement before using FOR ALL ENTRIES select query it will result in a performance issue.

hope this would solve your problem..

please reward points in case usefull..

regards,

Prashant

Hi,

Do we have to check for sy-subrc & is intial chek before every READ or Select Statement.

At which points can we ignore these checks.

7 REPLIES 7
Read only

gopi_narendra
Active Contributor
0 Likes
3,415

its a good practice on checking the sy-subrc for each read statement and select statements

checking the sy-subrc shows a good way of programming.

Regards

Gopi

Read only

0 Likes
3,415

for select stamt,

it will eliminate infinite loop.

like

if i_mara is not initial.

select maktx from makt into tabke i_makt

for all entries in i_mara

where matnr = i_mara-matnr.

endif.

Regards

Peram

Read only

Former Member
0 Likes
3,415

if we are using for an entries statement in our select then we need to check for is initial statement and also in case if you are using any selection screen parameters also we need to check is initial statement. Yes for good programming practice we need to check for the sy-subrc statement after the read and select statement.

Regards,

Santosh

Read only

Former Member
0 Likes
3,415

Hi,

IF condition after READ statement is not mandatory. If there is no record retrieved after READ statement & you want to process further then do not give IF statement.

IS INITIAL should be checked if you are using the internal table FOR ALL ENTRIES. before using FOR ALL ENTRIES, you should check whether the internal table is blank.

Best regards,

Prashant

Read only

Former Member
0 Likes
3,415

Hi Sneha,

It should be checked AFTER every read and select statement.

Regards,

Atish

Read only

Former Member
0 Likes
3,416

hi sneha,

good question...

yes it is necessary to check sy-subrc = 0 after READ statement else it will return a garbage value...

it is a good habbit of checking sy-subrc = 0 after read statement...

In case of check initial statement, it should be check when u are using FOR ALL ENTRIES on particular internal table....bcoz if u don't use check statement before using FOR ALL ENTRIES select query it will result in a performance issue.

hope this would solve your problem..

please reward points in case usefull..

regards,

Prashant

Read only

jyotheswar_p2
Active Participant
0 Likes
3,415

hi

it is good if u check sy-subrc value after read and select statement.it will reduces the performence issues.so it always a good habit of checking it.

we should check the itab is initial or not before using the for all entries.y beacause if the itab1 doesnot have any entries in it then itab 2 will be populated for all the values in itab1 irrespective of ur condition.

that is why its always a good habit to check sy-subrc and check intial when required.

hope this clear ur doubt.

regards

jyo