‎2007 Jun 25 10:17 AM
select belnr " to get the data from bkpf for the given compnay code date range and for the particular user
bukrs
budat
gjahr
bstat
budat
from bkpf
into corresponding fields of table ig_bkpf
for all entries in ig_ypctrusr
where bukrs = p1 and
budat in budat and
usnam = ig_ypctrusr-usnam.
select belnr
bukrs
gjahr
dmbtr
prctr
pprct
sgtxt
hkont
from bseg
into corresponding fields of table ig_bseg
for all entries in ig_bkpf
where belnr = ig_bkpf-belnr and
bukrs = ig_bkpf-bukrs and
gjahr = ig_bkpf-gjahr and
prctr in prctr and
pprct in pprct and
hkont = '0000150203'.
i am using this code
now there is no data in ig_bkpf
but when it is selectig data from bseg it is selecting all the data from bseg
can any body tell why this is hapening.
‎2007 Jun 25 10:19 AM
Hi
Write
<b>if not ig_bkpf[] is initial.</b>
select belnr
bukrs
gjahr
dmbtr
prctr
pprct
sgtxt
hkont
from bseg
into corresponding fields of table ig_bseg
for all entries in ig_bkpf
where belnr = ig_bkpf-belnr and
bukrs = ig_bkpf-bukrs and
gjahr = ig_bkpf-gjahr and
prctr in prctr and
pprct in pprct and
hkont = '0000150203'.
<b>endif.
Reward points for useful Answers</b>
Regards
Anji
‎2007 Jun 25 10:19 AM
Hi
Write
<b>if not ig_bkpf[] is initial.</b>
select belnr
bukrs
gjahr
dmbtr
prctr
pprct
sgtxt
hkont
from bseg
into corresponding fields of table ig_bseg
for all entries in ig_bkpf
where belnr = ig_bkpf-belnr and
bukrs = ig_bkpf-bukrs and
gjahr = ig_bkpf-gjahr and
prctr in prctr and
pprct in pprct and
hkont = '0000150203'.
<b>endif.
Reward points for useful Answers</b>
Regards
Anji
‎2007 Jun 25 10:23 AM
hi anji can oyu please tell m,e why this was happening even after the table ig_bkpf is empty why it is selecting all the data from bseg when we are using FOR ALL ENTRIES statement
it should look into bseg only for those records which are in ig_bkpf .
and since it is empty why it is taking al the records from bseg
can you please clear this doubt
‎2007 Jun 25 10:21 AM
hi,
check like this,
if not ig_bkpf[] is initial.
select belnr
bukrs
gjahr
dmbtr
prctr
pprct
sgtxt
hkont
from bseg
into corresponding fields of table ig_bseg
for all entries in ig_bkpf
where belnr = ig_bkpf-belnr and
bukrs = ig_bkpf-bukrs and
gjahr = ig_bkpf-gjahr and
prctr in prctr and
pprct in pprct and
hkont = '0000150203'.
endif.
regards,
seshu.
‎2007 Jun 25 10:22 AM
Hi Ashish,
That is normal.
The rule for using "For all entries" is that on which internal table you are using For all entries that should not be empty so put your second select in The condition
If not it_bseg[] is iinitial.
Put your select here.
Endif.
‎2007 Jun 25 10:22 AM
Hi Ashish ,
This is one very important point we need to consider when we use FOR ALL ENTRIES , if there are no records in the internal table then it will ignore the internalt table in the where clause and consider all other options .
In your case it will get all records which satisfy the condition
prctr in prctr and
pprct in pprct and
hkont = '0000150203'..
So it is always said to check if the internal table has records before we actually process for all entries.
if there are no entries the select statement must not be processed .
Use an IF condition to implement it.
Regards
Arun
‎2007 Jun 25 10:22 AM
Hi Ashish,
Select data from BSEG only if ig_bkpf is not initial.
Use
if ig_bkpf[] is not initial.
select ....from BSEG
endif.
Regards,
Suruchi
‎2007 Jun 25 10:22 AM
while using for all entries statement,first u have to check weather the table is empty or not.if the first itab is initial it will return all records from second table.
use this code.
if not ig_bseg[] is initial.
select statement.
endif.
‎2007 Jun 25 10:23 AM
Hi,
Just remember that whenever you are using FOR ALL ENTRIES,make sure to check whether the internal table is empty or not.
Only when the table is not empty proceed to do the select.
Hope this will solve your problem.
Thanks,
Sandeep.
‎2007 Jun 25 10:24 AM
You need to check that the internal table is not initial before running for all entries.
Else it gives all the data from the table.
regards,
‎2007 Jun 25 10:25 AM
Hi,
Whenever u use FOR ALL ENTRIES for selecting data, then if ITTAB is initial check has to be done .
In ur case,
For the 2nd select query,
If ig_bkpf is not initial.
select belnr
bukrs
gjahr
dmbtr
prctr
pprct
sgtxt
hkont
from bseg
into corresponding fields of table ig_bseg
for all entries in ig_bkpf
where belnr = ig_bkpf-belnr and
bukrs = ig_bkpf-bukrs and
gjahr = ig_bkpf-gjahr and
prctr in prctr and
pprct in pprct and
hkont = '0000150203'.
endif.
Now, this wil select the required records as per ur query.
****reward points if useful.
All the best
‎2007 Jun 25 10:25 AM
Hi ashish,
SELECT query is fetching all the data from BSEG as the internal in FOR ALL ENTRIES is empty.
When this table is empty it assumes to fetch all the data hence....the result.
Just make the necessary changes as shown and your problem will be solved.
select belnr " to get the data from bkpf for the given compnay code date range and for the particular user
bukrs
budat
gjahr
bstat
budat
from bkpf
into corresponding fields of table ig_bkpf
for all entries in ig_ypctrusr
where bukrs = p1 and
budat in budat and
usnam = ig_ypctrusr-usnam.
<b>if not ig_bkpf is initial.</b>
select belnr
bukrs
gjahr
dmbtr
prctr
pprct
sgtxt
hkont
from bseg
into corresponding fields of table ig_bseg
for all entries in ig_bkpf
where belnr = ig_bkpf-belnr and
bukrs = ig_bkpf-bukrs and
gjahr = ig_bkpf-gjahr and
prctr in prctr and
pprct in pprct and
hkont = '0000150203'.
<b>endif.</b>
Thanks and Regards,
Kunjal Patel
‎2007 Jun 25 10:26 AM
HI.
Before use " for all entries itab" we should check first table (ig_bkpf
)should not be initial. if its initial it will go to DUMP.so we need to check initial condition.
If use all entries in your slelect quary it will fecth all records based on first internal table (ig_bkpf) to second internal table (ig_bseg)
Rewards all helpfull ansewrs .
Regrads.
Jay
‎2007 Jun 25 10:27 AM
Hi
Write
if not ig_bkpf[] is initial.
select belnr
bukrs
gjahr
dmbtr
prctr
pprct
sgtxt
hkont
from bseg
into corresponding fields of table ig_bseg
for all entries in ig_bkpf
where belnr = ig_bkpf-belnr and
bukrs = ig_bkpf-bukrs and
gjahr = ig_bkpf-gjahr and
prctr in prctr and
pprct in pprct and
hkont = '0000150203'.
endif.
if your first internal table is not filled then the second internal table will be filled with the records which satisfy the condition mentioned in the selec quaery.