2006 Jul 27 6:21 PM
Hi
I have 4 records in i_kostl999
and after the select statement i get kostl and zgrp into i_abc of only 2 records because for the other two records doesn't exist in zxxx,but my problem is that the sy-subrc is still equal to zero.
select kostl zgrp into table i_abc from zxxx
for all entries in i_kostl999
where kostl = i_kostl999-auf.
if sy-subrc ne 0.
message e398(00) with 'No reservation items found '.
endif.
2006 Jul 27 6:26 PM
Hi Kajol,
1) Its always a good practise to check table contents of internal table when you are using FOR ALL ENTRIES option.
2) If the internal table is empty then it will take all entries from the database.
3) SY-SUBRC will be zero if it satisfies for at least one entry from interna table with database condition
4) Try as follows
<b>IF I_KOSTL999[] IS NOT INITIAL.</b>
select kostl zgrp into table i_abc from zxxx
for all entries in i_kostl999
where kostl = i_kostl999-auf.
if sy-subrc ne 0.
message e398(00) with 'No reservation items found '.
endif.
<b>ENIDF.</b>
Thanks,
Vinay
Hi
I have 4 records in i_kostl999
and after the select statement i get kostl and zgrp into i_abc of only 2 records because for the other two records doesn't exist in zxxx,but my problem is that the sy-subrc is still equal to zero.
select kostl zgrp into table i_abc from zxxx
for all entries in i_kostl999
where kostl = i_kostl999-auf.
if sy-subrc ne 0.
message e398(00) with 'No reservation items found '.
endif.
2006 Jul 27 6:26 PM
Hi Kajol,
1) Its always a good practise to check table contents of internal table when you are using FOR ALL ENTRIES option.
2) If the internal table is empty then it will take all entries from the database.
3) SY-SUBRC will be zero if it satisfies for at least one entry from interna table with database condition
4) Try as follows
<b>IF I_KOSTL999[] IS NOT INITIAL.</b>
select kostl zgrp into table i_abc from zxxx
for all entries in i_kostl999
where kostl = i_kostl999-auf.
if sy-subrc ne 0.
message e398(00) with 'No reservation items found '.
endif.
<b>ENIDF.</b>
Thanks,
Vinay
2006 Jul 27 6:35 PM
Hi MY PROBLEM IS NOT THAT.
the sy-subrc is zero even its retrieving data for only 2 records inspite of saying for alll entries.
I am supposed to get data for 4 records otherwise sy-subrc should be not equal to zero right?
Thanks
2006 Jul 27 6:40 PM
No Kajol sy-subrc will be zero if it is fetching atleast for one entry. After select select statment u can check for Sy-dbcnt if it is not equal to 4, u can through a error message.
2006 Jul 27 6:43 PM
hi kajol,
if i_kostl999 does not have any records then it will return sy-subrc ne 0.
but out of 4 records only 2 r there in the table zxxx which match with that of the i_kostl999.so sy-subrc = 0 as it is able to fetch 2 records.
2006 Jul 27 7:02 PM
Hi Kajol,
1) SY-SUBRC will be zero if it get at least one record which satifies the condition.
2) If it does not fetch any record for your ALL ENTRIES than your SY-SUBRC will be non-zero.
3) No doubt that your SELECT statement is considering all entries in internal table i_kostl999.
4) But, you have a WHERE condition in your query which satifies ONLY 2 ENTRIES from I_KOSTL999.
5) So you are getting only 2 records.
6) select kostl zgrp into table i_abc from zxxx
for all entries in i_kostl999
<b>where kostl = i_kostl999-auf.</b>
Note: Plz reward all helpful answers
Thanks,
Vinay
2006 Jul 27 6:28 PM
Kajol,
Yes sy-subrc will be 0, because the select statment has found minimum one record.
Check for sy-dbcnt, it might be helpful.
Or use can use the read statment.
Regards,
Prakash.
2006 Jul 27 6:36 PM
Hi kajol,
Unless no records are selected in to the table ,sy-subrc will be equal to zero.
if u want to compare the 2 tables,
use describe table lines v_lines and check if they are equal.
regards,
keerthi.
2006 Jul 27 7:17 PM
Kajol
Try this way to suit your requirement.
data: l_lines type i.
check not i_kostl999[] is initial.
describe table i_kostl999 lines l_lines.
select kostl zgrp into table i_abc from zxxx
for all entries in i_kostl999
where kostl = i_kostl999-auf.
if sy-subrc ne 0 or sy-dbcnt ne l_lines.
message e398(00) with 'No reservation items found '.
endif.
Note: Award for useful replies.
Regards
Eswar
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |