‎2006 Aug 24 2:17 PM
hi all,
iam wrote the code like this but its taking too much time to get the out put, if anybody suggest me which way i ca get good performance.
SELECT KUNNR NAME1 INTO (ITAB-KUNNR,ITAB-NAME1) FROM KNA1
WHERE KUNNR IN S_KUNNR.
SELECT BELNR ZTERM WRBTR AUGDT INTO (ITAB-BELNR,ITAB-ZTERM,ITAB-WRBTR,
ITAB-AUGDT)
FROM BSEG WHERE
KUNNR EQ ITAB-KUNNR
AND BUKRS EQ P_BUKRS
AND AUGDT EQ '00000000'.
SELECT BLDAT INTO (ITAB-BLDAT) FROM BKPF WHERE
BUKRS = P_BUKRS AND BELNR EQ ITAB-BELNR.
ENDSELECT.
ENDSELECT.
ENDSELECT.
‎2006 Aug 24 2:20 PM
Hi,
Remove nested selects instead use all entries.
Follow below hints to imropve performance
1) Remove corresponding from select satement
2) Remove * from select
3) Select field in sequence as defined in database
4) Avoid unnecessary selects
i.e check for internal table not initial
5) Use all entries and sort table by key fields
6) Remove selects ferom loop and use binary search
7) Try to use secondary index when you don't have
full key.
😎 Modify internal table use transporting option
9) Avoid nested loop . Use read table and loop at itab
from sy-tabix statement.
10) free intrenal table memory wnen table is not
required for further processing.
11)
Follow below logic.
FORM SUB_SELECTION_AUFKTAB.
if not it_plant[] is initial.
it_plant1[] = it_plant[].
sort it_plant1 by werks.
delete adjacent duplicates from it_plant1 comparing werks
SELECT AUFNR KTEXT USER4 OBJNR INTO CORRESPONDING FIELDS OF TABLE I_AUFKTAB
FROM AUFK
FOR ALL ENTRIES IN it_plant1
WHERE AUFNR IN S_AUFNR AND
KTEXT IN S_KTEXT AND
WERKS IN S_WERKS AND
AUART IN S_AUART AND
USER4 IN S_USER4 AND
werks eq it_plant1-werks.
free it_plant1.
Endif.
Regards
Amole
‎2006 Aug 24 2:20 PM
Hi,
Remove nested selects instead use all entries.
Follow below hints to imropve performance
1) Remove corresponding from select satement
2) Remove * from select
3) Select field in sequence as defined in database
4) Avoid unnecessary selects
i.e check for internal table not initial
5) Use all entries and sort table by key fields
6) Remove selects ferom loop and use binary search
7) Try to use secondary index when you don't have
full key.
😎 Modify internal table use transporting option
9) Avoid nested loop . Use read table and loop at itab
from sy-tabix statement.
10) free intrenal table memory wnen table is not
required for further processing.
11)
Follow below logic.
FORM SUB_SELECTION_AUFKTAB.
if not it_plant[] is initial.
it_plant1[] = it_plant[].
sort it_plant1 by werks.
delete adjacent duplicates from it_plant1 comparing werks
SELECT AUFNR KTEXT USER4 OBJNR INTO CORRESPONDING FIELDS OF TABLE I_AUFKTAB
FROM AUFK
FOR ALL ENTRIES IN it_plant1
WHERE AUFNR IN S_AUFNR AND
KTEXT IN S_KTEXT AND
WERKS IN S_WERKS AND
AUART IN S_AUART AND
USER4 IN S_USER4 AND
werks eq it_plant1-werks.
free it_plant1.
Endif.
Regards
Amole
‎2006 Aug 24 2:21 PM
You should use join instead of nested selects. to best construct your query please refer to Menu in ABAP Editor Go to Enviornment>Examples>Performance. Then from the left coloumn choose SQL Interface --> Select Over more than one table.
You can find solution of your problem there with some good other examples as well.
Cheers.
‎2006 Aug 24 2:22 PM
Hello,
If you want to take customer related data from BSEG and BKPF.. then better to use the table BSID and BSAD.
As you are only taking initial AUGDT. SO, use table BSID only.
Like,
select kunnr blenr zterm wrbtr augdt bldat
into table it_bsid
from bsid
where bukrs = p_bukrs
and kunnr in s_kunnr.
*check for entries in the it_bsid.
select name1 from kna1
into it_kna1
for all entries in it_bsid
where kunnr = it_bsid.
modify your name1 of it_bsid from it_kunnr.
Regards,
Naimesh
‎2006 Aug 24 2:23 PM
SELECT BBELNR BZTERM BWRBTR BAUGDT bkunnr kname1
c~bldat
INTO corresponding fields of table itab
FROM BSEG as B inner join kna1 as k on bkunnr = kkunnr
inner join bkpf as c on bbelnr = cbelnr and bbukrs = cbukrs
WHERE KUNNR in s_kunnr
AND BUKRS EQ P_BUKRS
AND AUGDT EQ '00000000'.
‎2006 Aug 24 2:23 PM
hi Pravee,
1. First of all try avoiding nested select statement ...
2. Use loop endloop statements inside loop try using read statement
3. avoid using select .. endselect statement ..
Regards,
Santosh
‎2006 Aug 24 2:26 PM
SELECT KUNNR NAME1 INTO table ITAB1
FROM KNA1
WHERE KUNNR IN S_KUNNR.
if not itab1[] is initial.
SELECT kunnr BELNR ZTERM WRBTR AUGDT INTO table ITAB2
FROM BSEG
for all entries in itab1
WHERE
KUNNR EQ ITAB1-KUNNR
AND BUKRS EQ P_BUKRS
AND AUGDT EQ '00000000'.
SELECT BELNR BLDAT INTO ITAB3 FROM BKPF
for all entries in itab1
WHERE
BUKRS = P_BUKRS AND BELNR EQ ITAB1-BELNR.
endif.
loop at itab1.
read table itab2 with key kunnr = itab1-kunnr.
if sy-subrc = 0.
itab1-belnr = itab2-belnr.
itab1-zterm = itab2-zterm.
itab1-wrbtr = itab2-wrbtr.
itab1-augdt = itab2-augdt.
endif.
read table itab3 with key belnr = itab1-belnr.
if sy-subrc = 0.
itab1-bldat = itab3-bldat.
endif.
modify itab1 index sy-tabix.
endloop.
Regards,
Ravi
‎2006 Aug 24 2:36 PM
Hi,
try this code
tables:kna1,bseg,bkpf.
data:begin of itab1 occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-name1,
end of itab1.
data:begin of itab2 occurs 0,
belnr like bseg-belnr,
zterm like bseg-zterm,
wrbtr like bseg-wrbtr,
augdt like bseg-augdt,
kunnr like bseg-kunnr,
bukrs like bseg-bukrs,
end of itab2.
data:begin of itab3 occurs 0,
bldat like bkpf-bldat,
bukrs like bkpf-bukrs,
belnr like bkpf-belnr,
end of itab3.
parameters:p_bukrs like bkpf-bukrs.
select-options:s_kunnr for kna1-kunnr.
select kunnr name1 from kna1
into table itab1
where kunnr in s_kunnr.
select belnr zterm wrbtr augdt from bseg
into corresponding fields of table itab2
for all entries in itab1
where kunnr = itab1-kunnr and
bukrs = p_bukrs and
augdt = '00000000'.
select bldat from bkpf
into corresponding fields of table itab3
for all entries in itab2
where bukrs = p_bukrs and
belnr = itab2-belnr.
regards,
sowjanya