Application Development 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 and sy-subrc

Former Member
0 Kudos
2,620

Hi,

What is meaning of sy-subrc values of 4 and 8 when a READ is done?

11 REPLIES 11

Former Member
0 Kudos
393

SY_SUBRC = 0 At least one record was read.

SY_SUBRC = 4 No lines were read.

SY-SUBRC = 8 The search key was not fully qualified

Former Member
0 Kudos
393

Hi,

Reads an entry from an internal table, using either its key or its index. The return code SY-SUBRC specifies whether an entry could be read. If you specify a non-unique key (the table must have a NON-UNIQUE key for this to be valid), the system returns the entry with the lowest index from the set of entries that meet the condition.

SY-SUBRC = 0:

An entry was read.

SY-TABIX is set to the index of the entry.

SY-SUBRC = 2:

An entry was read.

SY-TABIX is set to the index of the entry. This return code can only occur when you use the COMPARING addition. For further detauls, refer to the COMPARING section of the additions

SY-SUBRC = 4:

No entry was read.

The value of SY-TABIX depends on the table type and whether the BINARY SEARCH addition was specified.

If the table is a SORTED TABLE or a table sorted in ascending order of the type STANDARD TABLE with the BINARY SEARCH addition, SY-TABIX refers to the next-highest index.

Otherwise, SY-TABIX is undefined.

SY-SUBRC = 8:

No entry was read.

This return code only occurs with a SORTED TABLE or a STANDARD TABLE with the BINARY SEARCH addition. SY-TABIX is set to the number of all entries plus 1.

The READ TABLE statement also fills the system fields SY-TFILL and SY-TLENG.

reward if helpful

Former Member
0 Kudos
393

Hi,

Most of ABAP commands and class methods will set a value

Sy-subrc to ‘0’ if successful.

Sy-subrc to ‘4’ if Failure.

In case of datasets :-

Sy-subrc to ‘0’ if successful.

Sy-subrc to ‘8’ if Failure.

In case of Functionmodules :-

The sy-subrc can vary from ‘0’ to ‘20’.

Ie

Sy-subrc to ‘0’ if successful.

And gets different sy-subrc values (from ‘1’ to ‘20’) for exceptions.

By depends on exception values u can do different messaging in program.

And at function module code u need to raise the exceptions by raise <nameofexception>

Thanks.

Former Member
0 Kudos
393

SY-SUBRC = 4:

No entry was read.

The value of SY-TABIX depends on the table type and whether the BINARY SEARCH addition was specified.

If the table is a SORTED TABLE or a table sorted in ascending order of the type STANDARD TABLE with the BINARY SEARCH addition, SY-TABIX refers to the next-highest index.

Otherwise, SY-TABIX is undefined.

SY-SUBRC = 8:

No entry was read.

This return code only occurs with a SORTED TABLE or a STANDARD TABLE with the BINARY SEARCH addition. SY-TABIX is set to the number of all entries plus 1.

Former Member
0 Kudos
393

Hi,

IF VALUE IS 0 - CONDITION SATISFIED

IF VALUE IS 4 - CONDITION FAILED

IF VALUE IS 4 - USED FOR FILE ACCESS IF CONDITION IS FAILED

Regards,

V.Balaji

Reward if Usefull...

Former Member
0 Kudos
393

4 Row not found. If the entry was determined with a binary search, then sy-tabix is set to the table index of the entry before which it would have to be inserted with INSERT ... INDEX ..., if you want to keep the sorting order. This is the case if the addition table_key or free_key was specified for a beginning part of the table key of sorted tables, or if the addition BINARY SEARCH was specified explicitly. Otherwise, sy-tabix is undefined.

8 Like sy-subrc equals 4. If the entry was determined with a binary search, and the end of the table was reached, then sy-tabix is set to the number of rows + 1.

Former Member
0 Kudos
393

sy-subrc Relevance

0 Row found. sy-tabix is set to the table index of the entry for index tables, and to the value 0 for hashed-tables.

2 Like sy-subrc equals 0. Differentiates cases that use the addition COMPARING in result.

4 Row not found. If the entry was determined with a binary search, then sy-tabix is set to the table index of the entry before which it would have to be inserted with INSERT ... INDEX ..., if you want to keep the sorting order. This is the case if the addition table_key or free_key was specified for a beginning part of the table key of sorted tables, or if the addition BINARY SEARCH was specified explicitly. Otherwise, sy-tabix is undefined.

8 Like sy-subrc equals 4. If the entry was determined with a binary search, and the end of the table was reached, then sy-tabix is set to the number of rows + 1.

regards,

venkat

Former Member
0 Kudos
393

Hi,

IF VALUE IS 0 - CONDITION SATISFIED

IF VALUE IS 4 - CONDITION FAILED

IF VALUE IS 8 - USED FOR FILE ACCESS IF CONDITION IS FAILED

Regards,

V.Balaji

Reward if Usefull...

dhruv_shah3
Active Contributor
0 Kudos
393

hi,

If this is the case tht means the condition is true and sy-tabix will be set .

SY-SUBRC = 0:

An entry was read.

SY-TABIX is set to the index of the entry.

SY-SUBRC = 2:

An entry was read.

SY-TABIX is set to the index of the entry. This return code can only occur when you use the COMPARING addition. For further detauls, refer to the COMPARING section of the additions

If this is the case the entry it will be checked and tht value while comparing with some other vale is not exactly comparabe thn such situation occurs we should thnk tht the value comparision is not done properly but the some wrong value is present.

______________________--

SY-SUBRC = 8:

No entry was read.

This return code only occurs with a SORTED TABLE or a STANDARD TABLE with the BINARY SEARCH addition. SY-TABIX is set to the number of all entries plus 1.

SY-SUBRC = 4:

No entry was read.

The value of SY-TABIX depends on the table type and whether the BINARY SEARCH addition was specified.

If the table is a SORTED TABLE or a table sorted in ascending order of the type STANDARD TABLE with the BINARY SEARCH addition, SY-TABIX refers to the next-highest index.

Otherwise, SY-TABIX is undefined.

-


READ is done when you have already all data in one internal table and want to compare it with other internal tbale and then display the matching records.

In other terms when a parent child table relationship is there then read table is used ....

HTH

Regards,

Dhruv Shah

Former Member
0 Kudos
393

just put u'r cursor at 'READ' and press F1 u will get whole documentation.

Sameer

ThomasZloch
Active Contributor
0 Kudos
393

just check the ABAP online help for "READ itab" and spare us the copy & paste party.

too late...