‎2008 Mar 21 5:55 AM
hi,
why this is taking too much time for execution.
Select BUKRS BELNR GJAHR BSCHL MwSKZ SHKZG WRBTR From BSEG Into
table iT_BSEG where
FOR ALL ENTRIES IN iT_BKPF
Where BUKRS = iT_BKPF-BUKRS and
GJAHR = it_bkpf-GJAHR and
BELNR = iT_BKPF-BELNR and
mwskz eq taxcode and
lifnr eq vendor.
can any one help me?
thanks
Santosini
‎2008 Mar 21 6:37 AM
Hi Santosh,
You had put the two where clause in the select statment query
and what is the tax code and vendor in your query. If they are local variables then you will try this :
Select BUKRS BELNR GJAHR BSCHL MwSKZ SHKZG WRBTR From BSEG Into
table iT_BSEG
FOR ALL ENTRIES IN iT_BKPF
Where BUKRS = iT_BKPF-BUKRS and
GJAHR = it_bkpf-GJAHR and
BELNR = iT_BKPF-BELNR and
mwskz eq taxcode and
lifnr eq vendor
Please Reward if helpfull
Thanks
Anuj Garg
‎2008 Mar 21 6:37 AM
Hi Santosh,
You had put the two where clause in the select statment query
and what is the tax code and vendor in your query. If they are local variables then you will try this :
Select BUKRS BELNR GJAHR BSCHL MwSKZ SHKZG WRBTR From BSEG Into
table iT_BSEG
FOR ALL ENTRIES IN iT_BKPF
Where BUKRS = iT_BKPF-BUKRS and
GJAHR = it_bkpf-GJAHR and
BELNR = iT_BKPF-BELNR and
mwskz eq taxcode and
lifnr eq vendor
Please Reward if helpfull
Thanks
Anuj Garg
‎2008 Mar 21 6:52 AM
Hi,
Before using for all entries you have the check the data existency in internal table.
IF NOT iT_BKPF[] IS INITIAL.
Select BUKRS BELNR GJAHR
BSCHL MwSKZ SHKZG
WRBTR From BSEG
Into table iT_BSEG
FOR ALL ENTRIES IN iT_BKPF
Where BUKRS = iT_BKPF-BUKRS and
GJAHR = it_bkpf-GJAHR and
BELNR = iT_BKPF-BELNR and
mwskz eq taxcode and
lifnr eq vendor.
ENDIF.
‎2008 Mar 21 7:07 AM
hi ,
but why its taking a long time to fetch data.
how i will reduce the execution time.
thanks
‎2008 Mar 21 10:22 AM
Hi,
Remove the two where clause.
Sort the internbal table iT_BSEG with the bukrs gjahr belnr before data retreival.
Reward if helpful
Regards
Sourabh
‎2008 Mar 21 10:59 AM
You should Consider this too
The order fields in the select statement should be same as the oreder of fields in the database table.
Select BUKRS BELNR GJAHR BSCHL SHKZG MwSKZ WRBTR From BSEG Into
table iT_BSEG where
FOR ALL ENTRIES IN iT_BKPF
Where BUKRS = iT_BKPF-BUKRS and
GJAHR = it_bkpf-GJAHR and
BELNR = iT_BKPF-BELNR and
mwskz eq taxcode and
lifnr eq vendor.
‎2008 Mar 21 11:56 AM
Hi,
Initially, you populate the internal table "iT_BKPF" with necessary info and then, sort it and delete adjacent rows from it and keep it ready....
Then, write the Select query as under:
Select
BUKRS BELNR GJAHR BSCHL MWSKZ SHKZG WRBTR From BSEG Into
table IT_BSEG
FOR ALL ENTRIES IN IT_BKPF
Where
BUKRS = IT_BKPF-BUKRS
and
GJAHR = it_bkpf-GJAHR
and
BELNR = iT_BKPF-BELNR
and
mwskz eq taxcode
and
lifnr eq vendor.
some more ideas:
-> try to arrange the fields in the Select in proper order as they were place in the DB table...
-> if this also does not solve the purpose, try creating Secondary index on the some of the fields ( which were not there in the primary key fields ).
then, check if the performance has improved or not...
Thanks,
Vishnu.
‎2008 Mar 21 7:26 PM
hi santosh.......
ur taking two itabs. and populating the values into 1st table and then ur using SELECT statemet.by these two times the db tables hs to be read.....
u do one thing......
select te data directly from db table....
that is
SELECT........
FROM <DB TABLE > (NOT ITAB)
TRY THIS....
if u get answer plz reply me
bye tc
‎2008 Mar 24 6:59 AM
Hi,
It is taking more time because it_bkpf has huge number of data, may be above 20 thousand entries for a single bukrs e.g. 1000.
Please restrict the selection for it_bkpf if possible.
you can also code to avoid duplicates in it_bkpf.
SORT it_bkpf BY bukrs belnr gjahr.
DELETE ADJACENT DUPLICATES FROM it_bkpf.
SELECT bukrs belnr gjahr bschl mwskz shkzg wrbtr lifnr FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs
AND belnr = it_bkpf-belnr
AND gjahr = it_bkpf-gjahr
AND mwskz EQ taxcode
AND lifnr EQ vendor.
BSEG also has huge data, so care to be taken while firing query on it.
If you are able to restrict for it_bkpf then your problem will be resolved.
Please reward if useful.
Regards,
Ramesh.
‎2008 Mar 24 3:38 PM
Hi ,
u are very new in programming !
plz do, first declare the structure , then internal table , use without header line , then work area , then validate the fields , then use for all entries methord , it is very long process , u r proference will not low . because it is the best methord to join in application level, u r using wrong way , so do it proper way . Do it in production level programming way.
thanks and regards,
Mr. Subash.