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

abap

Former Member
0 Likes
573

hi,

if sy-subrc = 4,if sy-subrc = 8 like that we can write in progam.then which type of message its disply?

4 REPLIES 4
Read only

Former Member
0 Likes
552

Hi,

Sy-subrc = 0 -


Success

Sy-subrc = 4 -


Failure(known reason)

Sy-subrc = 8 -


Internal error(Unknown reason).

SELECT * FROM MARA

into table i_mara

where matnr = '00000123445'.

If a record exists in MARA table for the above material no., then sy-subrc value would be 0 i.e. Successful

If a record doesnt exist in MARA table for above material no., then sy-subrc value would be 4 i.e. Retrieval not successful.

The Return Code is set as follows:

SY-SUBRC = 0:

The result table contains at least one record.

SY-SUBRC = 4:

The result table is empty.

SY-SUBRC = 8:

Applies only to SELECT SINGLE FOR UPDATE: You did not specify all of the primary key fields in the WHERE condition. The result table is empty.

Thanks.

Reward If Helpful.

Read only

former_member195698
Active Contributor
0 Likes
552

You can set the value of sy-subrc manually in your program.

Regarding the Message to be displayed... you can raise any message based on the value of sy-subrc...

Read only

Former Member
0 Likes
552

Hi,

Sy-subrc is a sy in your program.stem field which is usually used to check the success of a particular statement like the loop,select etc....

The values of sy-subrc other than zero states that the statement could not be executed successfully but the value zero states it executed successfully.

Based on the values of sy-subrc you can write the code like the error messages.

ex:

if sy-subrc eq 0.

display an error message by using the message number and the message class.

Sample code:

CASE sy-subrc.

WHEN 0.

LOOP AT gi_recievers.

IF gi_recievers-receiver = space.

name = gi_recievers-rec_id.

ELSE.

name = gi_recievers-receiver.

ENDIF.

IF gi_recievers-retrn_code = 0.

WRITE: / name, ': succesfully sent'.

ELSE.

WRITE: / name, ': error occured'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'Too many receivers specified !'.

WHEN 2.

WRITE: / 'No receiver got the document !'.

WHEN 4.

WRITE: / 'Missing send authority !'.

WHEN OTHERS.

WRITE: / 'Unexpected error occurred !'.

ENDCASE.

ENDIF.

ENDIF.

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.

Read only

Clemenss
Active Contributor
0 Likes
552

Hi GANAPATHI,

it depends on the context. A READ TABLE will give SY_SUBRC 8 if the table is empty, 4 if the record was not found. Use F1 help on ABAP statement to see what subrc has what meaning.

The use your head (or ask your boss) to decide how to handle it.

Regards

Clemens