08-08-2006 4:45 PM
hello,
is this performance wise correct,
LOOP BSEG INTO WA.
AT NEW BUZEI.
SELECT SINGLE * FROM TABLE INTO VARIABLE WHERE ....
SELECT SINGLE * FROM TABLE INTO VARIABLE WHERE ....
SELECT SINGLE * FROM TABLE INTO VARIABLE WHERE ....
WRITE:/ value, wa-value.
ENDAT.
ENDLOOP.
Message was edited by: shehryar dahar
08-08-2006 4:51 PM
Performance cannot be measured like this. You have to give the exact code. If your table is a small table and you are hitting an index all the time, then I don't see why it will be a problem. But if your table has a lot of data and your WHERE clause is resulting in a sequential search, then yes, performance will be hit badly.
Please give us the exact code, without which this discussion will be with a lot suppositions.
08-08-2006 4:46 PM
hi Dahar,
Use read table statement before select single statement ...
Regards,
Santosh
08-08-2006 4:48 PM
08-08-2006 4:49 PM
hi,
here is an example of that..
READ TABLE it_owners WITH KEY ba_ba_no = it_detail-own_no
ba_seq_no = it_detail-own_seq_no.
also make sure that your internal table in whicb you are collecting have in an order as they are in DB table ...
<b>Please close all your previous threads even this once if it answered by marking all the helpful answers...</b>
Regards,
Santosh
08-08-2006 5:20 PM
hi Santosh,
How to get the value after using the read statement and secondly i was told to use read statements instead of select single ??
08-08-2006 4:46 PM
hi the code should be like this:: and in where condition which fields you are using... if these fileds after buzei in internaltable then u have to use <b>Read statement</b>.
<b>AT NEW table-BUZEI.</b>
read table itab with key buzei = some value.
SELECT SINGLE * FROM TABLE INTO VARIABLE WHERE ....
SELECT SINGLE * FROM TABLE INTO VARIABLE WHERE ....
SELECT SINGLE * FROM TABLE INTO VARIABLE WHERE ....
WRITE:/ value.
ENDAT.
Message was edited by: Ashok Parupalli
Message was edited by: Ashok Parupalli
08-08-2006 4:47 PM
08-08-2006 4:47 PM
Well, first off, if you are selecting * you need to select into a table structure; or
Select Single Fieldname From Table Into Variable Where
08-08-2006 4:47 PM
Unless unaviodable it is preferable not to use SELECTs inside a loop.. you would be better off dumping the required data into itabs & reading them inside the loop instead.
~ Suresh
08-08-2006 4:50 PM
hello,
priya.. yes, i have sorted the bseg with belnr and koart.
suresh.. can you demonstrate with an example ?
08-08-2006 4:48 PM
Hi,
Avoid using selects within a loop.
it affects ur performance.
regards,
keerthi.
08-08-2006 4:50 PM
NOt correct.
Get the selects outside the loop and use for all entries instead.
inside the loop, you have to use read statements
SELECT * FROM TABLE INTO table it_table1
for all entries in it_bseg
WHERE
ERE ....
> LOOP at it_BSEG INTO WA.
>
> AT NEW BUZEI.
>
> read table it_table1 with key ere =
> read table it_table1 with key ere =>
> read table it_table1 with key ere =
>
> WRITE:/ value, wa-value.
>
> ENDAT.
>
> ENDLOOP.
>
Regards,
Ravi
08-08-2006 4:53 PM
Hi Ravi,
but i have to read from different tables inside the ' AT NEW BUZEI' ?
08-08-2006 5:04 PM
Ravi,
how do i get/display values after using the READ statements. ??
08-08-2006 4:51 PM
Performance cannot be measured like this. You have to give the exact code. If your table is a small table and you are hitting an index all the time, then I don't see why it will be a problem. But if your table has a lot of data and your WHERE clause is resulting in a sequential search, then yes, performance will be hit badly.
Please give us the exact code, without which this discussion will be with a lot suppositions.
08-08-2006 5:02 PM
Hello Advani,
i am writing this from home. Its sumthing like this,
[code]
select * from bkpf into t_bkpf where bldat in s_bldat and blart = 'KZ'.
select * from bseg into wa_bseg where belnr = t_bkpf-belnr.
append wa_bseg into t_bseg.
endselect.
endselect.
clear wa_bseg.
sort t_bseg belnr koart.
LOOP AT t_bseg into waa_bseg.
AT NEW BUZEI.
IF waa_bseg-koart EQ 'K'.
SELECT SINGLE * FROM LFA1 into t_lfa1 where lifnr = waa_bseg-lifnr.
ELSEIF waa_bseg-koart EQ 'D'.
SELECT SINGLE * FROM KNA1 into t_kna1 where kunnr = waa_bseg-kunnr.
ENDIF.
WRITE:/ t_lfa1-name1.
WRITE:/ t_kna1-name1.
WRITE:/ waa_bseg-belnr.
ENDAT.
ENDLOOP.
itz approximately the same code snippet.
08-08-2006 5:16 PM
Just as I thought!!. There will not be any performance issue with the LOOP itself as you are hitting the tables with the primary key. Your performance will be bad because of the select statements before that (from BKPF and BSEG). Change that. See if you can pass BUKRS to BKPF select and then change the code as follows:
DATA: BEGIN OF t_bseg OCCURS 0.
INCLUDE STRUCTURE bseg.
DATA: END OF t_bseg.
DATA: BEGIN OF t_bkpf OCCURS 0,
bukrs LIKE bkpf-bukrs,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
bldat LIKE bkpf-bldat.
DATA: END OF t_bkpf.
SELECT-OPTIONS: s_bldat FOR t_bkpf-bldat.
SELECT bukrs belnr
gjahr bldat FROM bkpf
INTO TABLE t_bkpf
WHERE blart EQ 'KZ'.
CHECK sy-subrc = 0.
DELETE t_bkpf WHERE NOT bldat IN s_bldat.
SELECT * FROM bseg
INTO TABLE t_bseg FOR ALL ENTRIES IN t_bkpf
WHERE belnr = t_bkpf-belnr.
08-08-2006 5:20 PM
If you can add BUKRS in the WHERE clause for BKPF and BSEG selects in my previous code, it will be even more faster.
Also consider going to BSIK, BSAK and BSID and BSAD tables if you are interested only in customer and vendor accounts.
08-08-2006 5:23 PM
Hello Adavi,
thanks for the correction. So, the 'AT NEW BUZEI' part is correct ?
08-08-2006 5:28 PM
Yes. Just make sure that the work area WA_BSEG is filled in for KUNNR and LIFNR in AT NEW BUZEI. If not, you will have to read that record once again.
08-08-2006 5:34 PM
sorry, didnt get it . ?!
'WA_BSEG is filled in for KUNNR and LIFNR ' ??
08-08-2006 5:42 PM
In debugging see if the value of WA_BSEG-KUNNR and WA_BSEG-LIFNR are getting reset to '*' instead of actual values.
Within the loop if you are using control break statements such as AT NEW, AT LAST etc., only the values of the fields that are before are available within that AT ... ENDAT block. So in your case, values for BUKRS BELNR GJAHR and BUZEI will be there within the AT ... ENDAT block, but all others will be reset to '*'s. Outside the block, you will again see all the values.
08-08-2006 5:48 PM
hello Adavi,
yeah, they are coming . i have used,
LOOP AT T_BSEG into WA_BSEG.
waa_bseg = wa_bseg.
// using waa_bseg instead of wa_bseg.
ENDLOOP.
one more thing, wa_bseg will be of the type,
wa_bseg LIKE LINE OF t_bseg. <- right way ?
i can loop at like the,
LOOP AT t_bseg into wa_bseg.
08-08-2006 6:07 PM
thanks all,
i have check the other ways n return to reward the answers...
08-08-2006 6:10 PM
08-08-2006 7:42 PM
> hello Adavi,
>
> yeah, they are coming . i have used,
>
> LOOP AT T_BSEG into WA_BSEG.
>
> waa_bseg = wa_bseg.
>
> // using waa_bseg instead of wa_bseg.
>
> ENDLOOP.
>
>
> one more thing, wa_bseg will be of the type,
>
> wa_bseg LIKE LINE OF t_bseg. <- right way ?
>
> i can loop at like the,
>
> LOOP AT t_bseg into wa_bseg.
That is correct
08-08-2006 4:59 PM