2008 Mar 14 8:24 AM
Dear All
Why we can use this sy-subrc
Regards
Suresh
2008 Mar 14 8:26 AM
Hi,
It checks whether expression or statement or condition is successful or not
Return value set by the following ABAP statements. In general, a content of 0 means that the statement was executed without problems.
· ASSIGNsets SY-SUBRC to 0 if assignment to field symbol is possible, otherwise 4.
· ASSIGN dref->* sets SY-SUBRC to 0 if dereferencing is possible, otherwise 4.
· AUTHORITY-CHECK sets SY-SUBRC to 0 if the user has the necessary authorization, otherwise 4, 8, 12, 16, 24, 28, 32, or 36 depending on the cause.
· CALL DIALOG with USING sets SY-SUBRC to 0, if processing was successful, otherwise 0.
· CALL FUNCTION sets SY-SUBRC according to the exception handling.
· CALL METHOD sets SY-SUBRC according to the exception handling.
· CALL SELECTION-SCREEN sets SY-SUBRC to 0 if the user chose Enter or Execute and 4 if the user chose Cancel.
· CALL TRANSACTION with USING sets SY-SUBRC to 0 if processing was successful, otherwise 0.
· CATCH SYSTEM-EXCEPTIONS sets SY-SUBRC if there are runtime errors after the ENDCATCH statement. The value is specified in the program.
· COMMIT WORK sets SY-SUBRC to 0.
· COMMIT WORK AND WAIT sets SY-SUBRC to 0 if update was successful, otherwise 0.
· COMMUNICATION INIT DESTINATION RETURNCODE sets SY-SUBRC as specified.
· CONCATENATE sets SY-SUBRC to 0 if the result fits into target variable, otherwise 4.
· CREATE OBJECT sets SY-SUBRC if the exceptions of the instance constructor are handled.
· CREATE OBJECT in OLE2 sets SY-SUBRC to 0 if an external object was created, otherwise 1,2, 3 with different causes.
· DELETEsets SY-SUBRC to 0 if operation was successful, otherwise 4 or 0 depending on cause.
· DEMAND MESSAGES INTO sets SY-SUBRC to 0 if a message table is empty, otherwise 0.
· DESCRIBE LIST sets SY-SUBRC to 0 if row or list exists, otherwise 4 or 8.
· EXEC SQL - ENDEXEC sets SY-SUBRC to 0 in almost all cases. Only if no set was read with FETCH is SY-SUBRC 4.
· FETCHsets SY-SUBRC to 0 if at least one row was read, otherwise 4.
· GENERATE SUBROUTINE POOL sets SY-SUBRC to 0 if generation was successful, otherwise 8.
· GET CURSOR sets SY-SUBRC to 0 if the cursor is correctly positioned, otherwise 4.
· GET PARAMETER sets SY-SUBRC to 0 if value found in SAP Memory, otherwise 4.
· IMPORTsets SY-SUBRC to 0 if import of data objects was successful, otherwise 4.
· INSERTsets SY-SUBRC to 0 if operation was successful, otherwise 4.
· LOAD REPORT sets SY-SUBRC to 0 if operation was successful, otherwise 4 or 8 depending on cause.
· LOOPsets SY-SUBRC to 0 if loop over extract was passed at least once, otherwise 4.
· LOOP ATsets SY-SUBRC to 0 if loop over internal table was passed at least once, otherwise 4.
· MODIFYsets SY-SUBRC to 0 if operation was successful, otherwise 4.
· MODIFY LINE sets SY-SUBRC to 0 if list row was changed, otherwise 0.
· MODIFYsets SY-SUBRC to 0 if operation was successful, otherwise 4.
· OLE2 automation, bundled commands set SY-SUBRC to 0 if all were successfully executed, otherwise 1, 2, 3, 4 depending on cause.
· OPEN DATASET sets SY-SUBRC to 0 if the file was opened, otherwise 8.
· Open SQL commands set SY-SUBRC to 0 if operation was successful, otherwise 0.
· OVERLAYsets SY-SUBRC to 0 if at least one character is overlayed, otherwise 4.
· READ DATASET sets SY-SUBRC to 0 if the read operation was successful, otherwise 4 or 8 depending on cause.
· READ LINE sets SY-SUBRC to 0 if list row exists, otherwise 0.
· READ TABLE sets SY-SUBRC to 0 if the table row was found, otherwise 2, 4, 8 depending on cause.
· REPLACEsets SY-SUBRC to 0 if search string could be replaced, otherwise 0.
· ROLLBACK WORK always sets SY-SUBRC to 0.
· SCROLLsets SY-SUBRC to 0 if scrolling in list successful, otherwise 4 or 8 depending on cause.
· SEARCHsets SY-SUBRC to 0 if search string was found, otherwise 4.
· SELECTsets SY-SUBRC to 0 if at least one row was read, otherwise 4 or even 8 with SELECT SINGLE FOR UPDATE.
· SET COUNTRY sets SY-SUBRC to 0 if country ID was found in table T005X, otherwise 4.
· SET BITsets SY-SUBRC to 0 if bit was set, otherwise 0.
· SET TITLEBAR sets SY-SUBRC to 0 if title exists, otherwise 4.
· SHIFT UP TO sets SY-SUBRC to 0 if position was found in character string, otherwise 4.
· SPLITsets SY-SUBRC to 0 if size of target fields is sufficient, otherwise 4.
· UPDATEsets SY-SUBRC to 0 if operation successful, otherwise 4.
· WRITE TO sets SY-SUBRC to 0 if assignment successful, otherwise 4.
regards
2008 Mar 14 8:26 AM
Hi,
sy-subrc is used to check if the statement executed previously gives intended output.
It can be used after select query/read statemnt/function module to check if they have performed intended operation.
If not , u can raise exceptions for that.
reward if helpful.
Regards,
Ramya
2008 Mar 14 8:27 AM
to know if a particular statement is success or not ..
(Return Value, Return Value After ABAP Statements)
select * from ...
if sy-subrc = 0. <-- 0 is success .... others means failure ..
endif.
similarly U can also check if Read table using sy-subrc ...
2008 Mar 14 8:28 AM
Hi,
SY-SUBRC is like a system flag.
If we do a database operation,if it succeed then SY-SUBRC will have value 0.Else 4 or 8.
Apart from database operation we can use it for internal table operations,string operation.Function modules etc
Reward if useful
Thanks Arjun
2008 Mar 14 8:28 AM
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.
check the link below:
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/read_t01.htm
2008 Mar 14 8:29 AM
HI
whether the function is performed successfully or not.
for example
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = it_events
exceptions
list_type_wrong = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
in this if the function is executed properly then sy-subrc = 0,otherwise it is not equal to zero.
2008 Mar 14 8:30 AM
hi,
We can use the SY-SUBRC value to check whether our database hits are suceess or not.
if it is a sucess SY-SUBRC is set to 0.
otherwise its 4.
u can even use this for read table and verifying internal tables also.
2008 Mar 14 8:38 AM
Hi,
SY-subrc is the system variable which is used to check whether the data base query is true or not.
for eg:
select vbeln posnr from vbak into it_vbak where vbeln = p_vbeln.
if sy-subrc eq 0.
write : it_vbak-vbeln.
endif.
i.e., if there are records based on vbeln value then display vbeln field.
Regards,
vineela.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |