10-08-2008 2:12 PM
I am using this query:
SELECT vguid qausp
INTO TABLE tb_qualif
FROM vlcadddata
FOR ALL ENTRIES IN tb_distmode1
WHERE vguid = tb_distmode1-vguid
AND aqual = 'ASPT'.
Now if the internal table contains no data tb_distmode1 then the query is giving wrong result. In fact it is ignoring the part 'FOR ALL ENTRIES IN tb_distmode1'.
Ideally my requirement is not to fetch any data if the table is empty. So can anyone suggest any suitable way so that I can get the desired result without using IF...ENDIF.
10-08-2008 2:17 PM
This is because when the table which is used in for all entries is empty, all the database records are selected.
Solution :
Before the select query check if the table tb_distmode1 has any entries . Only then make the select query to execute.
describe table tb_distmode1 lines sy-tfill.
if sy-tfill GE 1.
SELECT vguid qausp
INTO TABLE tb_qualif
FROM vlcadddata
FOR ALL ENTRIES IN tb_distmode1
WHERE vguid = tb_distmode1-vguid
AND aqual = 'ASPT'.
endif.
I dont think there is any other way to achive your requirement.
regards,
Advait.
Edited by: Advait Gode on Oct 8, 2008 3:17 PM
10-08-2008 2:17 PM
This is because when the table which is used in for all entries is empty, all the database records are selected.
Solution :
Before the select query check if the table tb_distmode1 has any entries . Only then make the select query to execute.
describe table tb_distmode1 lines sy-tfill.
if sy-tfill GE 1.
SELECT vguid qausp
INTO TABLE tb_qualif
FROM vlcadddata
FOR ALL ENTRIES IN tb_distmode1
WHERE vguid = tb_distmode1-vguid
AND aqual = 'ASPT'.
endif.
I dont think there is any other way to achive your requirement.
regards,
Advait.
Edited by: Advait Gode on Oct 8, 2008 3:17 PM
10-08-2008 2:19 PM
just check if the internal table is not empty:
IF tb_distmode1[] IS NOT INITIAL.
SELECT ...
ENDIF.
10-08-2008 2:19 PM
Hi
Write code like this
if tb_distmode1[] is not initial.
SELECT vguid qausp
INTO TABLE tb_qualif
FROM vlcadddata
FOR ALL ENTRIES IN tb_distmode1
WHERE vguid = tb_distmode1-vguid
AND aqual = 'ASPT'.
endif.
10-08-2008 2:20 PM
Hi,
Modify the select query as stated below.
if tb_distmode1 is not initial.
SELECT vguid qausp
INTO TABLE tb_qualif
FROM vlcadddata
FOR ALL ENTRIES IN tb_distmode1
WHERE vguid = tb_distmode1-vguid
AND aqual = 'ASPT'.
endif.
thanks & regards
Kishore M
10-08-2008 2:20 PM
Hi,
Use 'IF NOT ITAB IS INITIAL' before using for all entries.
this is mandatory.
Regards,
Sudheer Kumar
10-08-2008 2:22 PM
Hi,
Yes if the internal tab in empty all the records are fetched ignoring the for all entries.
So before you select you check the intial of the internal tab.
If itab is not initial.
select.........
endif.
Rhea.
10-08-2008 2:38 PM
Hi
you have to check if the first internal table is empty or not before using the for all entries its mandatory condition.
if itab is not initial.
select stmt...
endif.
regards
10-08-2008 2:45 PM
You can also use the CHECK statement.
CHECK tb_distmode1[] is not initial.
SELECT vguid qausp
INTO TABLE tb_qualif
FROM vlcadddata
FOR ALL ENTRIES IN tb_distmode1
WHERE vguid = tb_distmode1-vguid
AND aqual = 'ASPT'.
But please note that if the table is initial, then the entire code after the CHECK statement will not be executed
regards,
Advait.
Edited by: Advait Gode on Oct 8, 2008 3:45 PM
10-08-2008 2:46 PM