‎2008 Nov 24 1:11 PM
Hi guis,
In loop select statement is there .
He was maintaining loop in one internal table and populating another internal table in select and
endselect programe.
Here i am facing the performance probles please provide the code for this one.
loop at t_hdr.
select buzei buzid koart shkzg mwskz dmbtr hwbas sgtxt vbund kostl
aufnr anln1 anln2 hkont kunnr lifnr matnr werks ebeln ebelp
zekkn rewrt prctr txjcd projk
into (t_item-buzei, t_item-buzid, t_item-koart, t_item-shkzg,
t_item-mwskz, t_item-dmbtr, t_item-hwbas, t_item-sgtxt,
t_item-vbund, t_item-kostl, t_item-aufnr, t_item-anln1,
t_item-anln2, t_item-hkont, t_item-kunnr, t_item-lifnr,
t_item-matnr, t_item-werks, t_item-ebeln, t_item-ebelp,
t_item-zekkn, t_item-rewrt, t_item-prctr, t_item-txjcd,
t_item-projk)
from bseg
where bukrs = t_hdr-bukrs
and belnr = t_hdr-belnr
and gjahr = t_hdr-gjahr
and hkont in s_hkont
and mwskz in s_mwskz
and kostl in s_kostl
and prctr in s_prctr
and werks in s_werks.
Skip record if not in selection screen range for state
check t_item-txjcd(2) in s_state.
if t_item-shkzg = c_debit. "S
endif.
if t_item-shkzg = c_credit. "H
t_item-dmbtr = t_item-dmbtr * ( -1 ).
t_item-rewrt = t_item-rewrt * ( -1 ).
t_item-hwbas = t_item-hwbas * ( -1 ).
endif.
**&MWB 04/08/2005 ... add additional US Bayer Tax dept requested fields
clear: t_item-basetax, t_item-accrtax, t_item-vendtax,
t_item-taxrate, t_item-invbase, t_item-invtax.
**&MWB ... end insert 04/08/2005
clear t_item-hwbas.
*
move-corresponding t_hdr to t_item.
append t_item.
clear t_item.
endselect.
endloop.
Thanks and regards
santhosh
‎2008 Nov 24 2:56 PM
Hi you can do the following:
select buzei buzid koart shkzg mwskz dmbtr hwbas sgtxt vbund kostl
aufnr anln1 anln2 hkont kunnr lifnr matnr werks ebeln ebelp
zekkn rewrt prctr txjcd projk
into table t_item
from bseg
for all entries in t_hdr
where bukrs = t_hdr-bukrs
and belnr = t_hdr-belnr
and gjahr = t_hdr-gjahr
and hkont in s_hkont
and mwskz in s_mwskz
and kostl in s_kostl
and prctr in s_prctr
and werks in s_werks.
loop at t_item.
Skip record if not in selection screen range for state
check t_item-txjcd(2) in s_state.
if t_item-shkzg = c_debit. "S
endif.
if t_item-shkzg = c_credit. "H
t_item-dmbtr = t_item-dmbtr * ( -1 ).
t_item-rewrt = t_item-rewrt * ( -1 ).
t_item-hwbas = t_item-hwbas * ( -1 ).
endif.
modify t_item index sy-tabix.
clear: t_item-basetax, t_item-accrtax, t_item-vendtax,
t_item-taxrate, t_item-invbase, t_item-invtax.
clear t_item-hwbas.
endloop.
Edited by: Srinivas Manchikalapati on Nov 26, 2008 5:41 AM
‎2008 Nov 25 2:58 PM
Hi Santosh,
Try to use READ using index instead of looping the internal table:
Data:
w_line type i,
w_int type i.
Describe table itab lines w_line.
Do w_line times.
w_int = w_int + 1.
Read table itab index w_int.
........
Enddo.With luck,
Pritam.
‎2008 Nov 26 3:54 AM
Hi,
try like this, Use for all entries statement in select statement and then read it with in the loop.
select buzei buzid koart shkzg mwskz dmbtr hwbas sgtxt vbund kostl
aufnr anln1 anln2 hkont kunnr lifnr matnr werks ebeln ebelp
zekkn rewrt prctr txjcd projk
into table t_item
from bseg
for all entries in t_hdr
where bukrs = t_hdr-bukrs
and belnr = t_hdr-belnr
and gjahr = t_hdr-gjahr
and hkont in s_hkont
and mwskz in s_mwskz
and kostl in s_kostl
and prctr in s_prctr
and werks in s_werks.
Loop at t_item .
Read table t_hdr with index.
write ur code what ever you want inside this.
Endloop.
let me know if there are any issues.
Regards,
Kusuma.
‎2008 Nov 26 8:12 AM
Hi Santhosh,
Select all the records outside the loop and write read statement inside the loop.
select buzei buzid koart shkzg mwskz dmbtr hwbas sgtxt vbund kostl
aufnr anln1 anln2 hkont kunnr lifnr matnr werks ebeln ebelp
zekkn rewrt prctr txjcd projk from bseg into table t_item for all entries in t_hdr
where bukrs = t_hdr-bukrs
and belnr = t_hdr-belnr
and gjahr = t_hdr-gjahr
and hkont in s_hkont
and mwskz in s_mwskz
and kostl in s_kostl
and prctr in s_prctr
and werks in s_werks.
Loop at t_hdr into wa_hdr.
READ TABLE t_item into w_item with key bukrs = wa_hdr-bukrs
belnr = wa_hdr-belnr
and gjahr = wa_hdr-gjahr.
if sy-subrc = 0.
<ur code>
endif.
endloop.
‎2008 Nov 26 10:15 AM
Hi,
Try to use for all entries for the first select query instead of select in loop.
step 1: Select all the records outside the loop and write read statement inside the loop.
select buzei buzid koart shkzg mwskz dmbtr hwbas sgtxt vbund kostl
aufnr anln1 anln2 hkont kunnr lifnr matnr werks ebeln ebelp
zekkn rewrt prctr txjcd projk from bseg into table t_item
FOR ALL ENTRIES IN t_hdr
where bukrs = t_hdr-bukrs
and belnr = t_hdr-belnr
and gjahr = t_hdr-gjahr
and hkont in s_hkont
and mwskz in s_mwskz
and kostl in s_kostl
and prctr in s_prctr
and werks in s_werks.
step 2 : Now looping at this internal table do the validations at the and modify the internal table with the new values or
Inside the loop read the entries of the table into workarea with key values and then modify using the table key .
loop at t_item.
*Skip record if not in selection screen range for state
check t_item-txjcd(2) in s_state.
if t_item-shkzg = c_debit. "S
endif.
if t_item-shkzg = c_credit. "H
t_item-dmbtr = t_item-dmbtr * ( -1 ).
t_item-rewrt = t_item-rewrt * ( -1 ).
t_item-hwbas = t_item-hwbas * ( -1 ).
endif.
modify t_item index sy-tabix.
clear: t_item-basetax, t_item-accrtax, t_item-vendtax,
t_item-taxrate, t_item-invbase, t_item-invtax.
clear t_item-hwbas.
endloop.