‎2020 Mar 17 4:05 PM
Hello
in sap s4 hana i used a simple statement read table , this statement not return record and sy-subrc is 4 , and after that i use clear statement but the sy-subrc is 4 and not set to zero.
thank you in advance
Read Table it1
Into wa1
WITH KEY GUID = x_GUID.
...
if sy-subrc ne 0 .
clear wa1.
endif.
‎2020 Mar 17 5:22 PM
The reason is that the clear Statement does not change sy-subrc at all. So it stays at the same value as before.
This is probably one of the reasons why most of the new commands do not rely on sy-subrc any more but uses exceptions instead.
‎2020 Mar 17 4:28 PM
Probably that the data types of GUID/X_GUID are different, or their values have a different length, or trailing space if their types are string. If you don't find out the reason, please attach the screenshots from the debugger (types, hex values, etc.).
Anyway, probability is 99.9999% that it's not a bug in SAP.
‎2020 Mar 17 5:22 PM
The reason is that the clear Statement does not change sy-subrc at all. So it stays at the same value as before.
This is probably one of the reasons why most of the new commands do not rely on sy-subrc any more but uses exceptions instead.
‎2020 Mar 18 6:52 AM
thank you michael.biber2
that is right , i thought after clear statement the sy-subrc set to zero .
‎2020 Mar 17 5:49 PM
Is your question about SY-SUBRC not set to 0 after CLEAR? If yes please forget my first comment and refer to Michael answer.
‎2020 Mar 17 5:55 PM
Probably, if you want to clear sy-subrc - try using FREE wa1
Clear - may clear the database object fields as well.
‎2020 Mar 18 5:19 AM
madjied.khanevadegi,
SY-SUBRC is system field that will provide a return value for every ABAP statement executed as part of the program. The CLEAR is not among those commands that can change SY-SUBRC value.
The Value of the SY-SUBRC field will not be changed until another valid statement gets executed that will change the SY-SUBRC value, This is common for all system fields.
However you can clear the value of SY-SUBRC at any instant of the program.
The values and different commands in ABAP that alter SY-SUBRC is given below:
Regards!
‎2020 Mar 18 5:53 AM
The first sentence of your answer is confusing "SY-SUBRC ... provide a return value for every ABAP statement".
If you say instead, "only a few ABAP statements set SY-SUBRC", that would be better.
‎2020 Mar 18 6:21 AM
That's true, SY-SUBRC is not a good friend, most of the developper used a variable because most of the time we didn't know when it will be updated. SELECT / READ ...
‎2020 Mar 18 7:02 AM
‎2020 Mar 18 7:12 AM
As a good developper; I never read documentation, even in real life 🙂