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 = 2

0 Likes
11,574

Dear all,

I have an error when excuting a sql statement in SAP ABAP.

When i debug and find sy-subrc is set to '2'.

Who can tell me what is meaning for 'SY-SUBRC = 2'?

Best Regards,

Steven Liu

Dear all,

I have an error when excuting a sql statement in SAP ABAP.

When i debug and find sy-subrc is set to '2'.

Who can tell me what is meaning for 'SY-SUBRC = 2'?

Best Regards,

Steven Liu

6 REPLIES 6
Read only

Former Member
0 Likes
4,791

Well that depends on the statement you are executing.

Do a F1 help on that statement, in the help documentation you should find the cause of sy-subrc = 2.

Read only

Former Member
0 Likes
4,791

Hi,

sy-subrc returns the value 2 mean, If the system cannot find an entry.

SY-SUBRC = 2 Source code table (internal table) is empty or a blank line range was selected..

regards

Thirumaran k

Read only

Former Member
0 Likes
4,791

Kindly check the additions FROM and TO .(there was some error was there)

regards

Thirumaran k

Read only

Former Member
0 Likes
4,791

Hi Steven Liu,

Please go through the link ,

http://www.sapbrainsonline.com/sapinfo/tutorial.php?artid=410

Regards,

Sreekar.Kadiri

Read only

Former Member
0 Likes
4,791


DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.


DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.


DO 4 TIMES.
  LINE-COL1 = SY-INDEX.
  LINE-COL2 = SY-INDEX **
2.
INSERT LINE INTO TABLE ITAB.
ENDDO.


LINE-COL1 = 2. LINE-COL2 = 3.


READ TABLE ITAB FROM LINE INTO LINE COMPARING COL2.


WRITE: 'SY-SUBRC =', SY-SUBRC.
SKIP.
WRITE: / LINE-COL1,
LINE-COL2.


The output is:


SY-SUBRC =    2


         2        4


The program fills a hashed table with a list of square numbers. The work area
LINE, which is compatible with the line type, is filled with the numbers 2 and
3. The READ statement reads the line of the table in which the key field COL1
has the same value as in the work area and copies it into the work area.
SY-SUBRC is set to 2, because the contents of field COL2 were different.

this might helps...

also try this

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm

Read only

Former Member
0 Likes
4,791

This message was moderated.