‎2007 Oct 13 7:15 AM
hi,
if sy-subrc = 4,if sy-subrc = 8 like that we can write in progam.then which type of message its disply?
‎2007 Oct 13 7:27 AM
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.
‎2007 Oct 13 7:51 AM
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...
‎2007 Oct 13 4:22 PM
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.
‎2007 Oct 13 10:08 PM
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