‎2006 Jun 09 8:23 AM
select count(*) belnr gjahr
from rseg
into (z_count , rseg-belnr , rseg-gjahr)
where ebeln = <ls_itab>-ebeln
and ebelp = <ls_itab>-ebelp
and lfbnr = <ls_itab>-lblni
group by belnr gjahr.
if sy-subrc = 0.
<ls_itab>-zgjahr = rseg-gjahr.
<ls_itab>-zbelnr = rseg-belnr.
endif.
endselect.
what is wrong with this???
i heard that <b>ENDSELECT</b> not good for performance what can i do to not use it in this select.
‎2006 Jun 09 8:27 AM
Create a table with the three field and then change the select statement to
select count(*) belnr gjahr
from rseg appending
into table count_tab
where ebeln = <ls_itab>-ebeln
and ebelp = <ls_itab>-ebelp
and lfbnr = <ls_itab>-lblni
group by belnr gjahr.
Regards,
Ravi
‎2006 Jun 09 8:28 AM
select count(*) belnr gjahr
from rseg
into (z_count , <b>rseg-belnr , rseg-gjahr</b>)
where ebeln = <ls_itab>-ebeln
and ebelp = <ls_itab>-ebelp
and lfbnr = <ls_itab>-lblni
group by belnr gjahr.
if sy-subrc = 0.
<ls_itab>-zgjahr = <b>rseg-gjahr</b>.
<ls_itab>-zbelnr = <b>rseg-belnr</b>.
endif.
endselect.
1)u select the value from rseg and into rseg both in same table.
make a internal table type rseg where u store seelcted value.
2)if u use any airthmatic function( count , sum...) than u have to use select end select.
3) to avoid select end select.ur requirment is to calulate total number of data use <b>SY-DBCNT</b>
‎2006 Jun 09 8:34 AM
Do you want to modify <ls_itab>? Then do this:
select ebeln ebelp lblni belnr gjahr
from rseg
into table itab
FOR ALL ENTRIES IN <ls_itab>
where ebeln = <ls_itab>-ebeln
and ebelp = <ls_itab>-ebelp
and lfbnr = <ls_itab>-lblni.
if sy-subrc = 0.
SORT itab BY ebeln ebelp lblni.
LOOP AT <ls_itab>.
l_tabix = sy-tabix.
READ TABLE itab WITH KEY ebeln = <ls_itab>-ebeln
ebelp = <ls_itab>-ebelp
lblni = <ls_itab>-lblni.
IF sy-subrc = 0.
<ls_itab>-zgjahr = itab-gjahr.
<ls_itab>-zbelnr = itab-belnr.
MODIFY <ls_itab> INDEX l_tabix
TRANSPORTING gjahr belnr.
ENDIF.
ENDLOOP.
endif.
‎2006 Jun 09 8:28 AM
Hi Tal,
Declare one internal table with required fields ...
Then
select count(*) belnr gjahr
from rseg
into <b>table internal table</b>
where ebeln = <ls_itab>-ebeln
and ebelp = <ls_itab>-ebelp
and lfbnr = <ls_itab>-lblni
group by belnr gjahr.
Now loop the inernal table and then then check the conditions using Read and if sy-subrc = 0 then delte that record from internal table..
Regards,
Sridhar
‎2006 Jun 09 8:29 AM
Liat,
In fact better to avoid SELECT -ENDSELECT. But in your case, since you are using COUNT SELECT -ENDSELECT is needed.
SELECT -ENDSELECT is having the posibility of hiting the database multiple times which reduced the performances.
Cheers,
Thomas.
‎2006 Jun 09 8:32 AM
hi,
use <b>for all entries</b> instead of select and endselect.
select count(*) belnr gjahr
from rseg
into table itab
for all entries in <ls_itab>
where ebeln = <ls_itab>-ebeln
and ebelp = <ls_itab>-ebelp
and lfbnr = <ls_itab>-lblni
group by belnr gjahr.Regards
vijay
‎2006 Jun 09 8:50 AM
i made this
select belnr gjahr
from rseg
into table itab
for all entries in <ls_itab>
where ebeln = <ls_itab>-ebeln
and ebelp = <ls_itab>-ebelp
and lfbnr = <ls_itab>-lblni.
and i get
unable to interept <ls_itab>
‎2006 Jun 09 9:36 AM
Hi Tal,
I think the fields in ls_itab are not matching with the selct fields...u have to select the common fields in both tables...
Check this Link which can definitely help u...
<b>http://www.sapdevelopment.co.uk/tips/tips_select.htm</b>
Just compare with u r requirement and u will solve it...
Regards,
sridhar
Message was edited by: sridhar reddy kondam
‎2006 Jun 09 7:15 PM
How is <ls_itab> defined in your code? Earlier I thought it was already defined min your program as an internal table looking at you code, something like this:
FIELD-SYMBOL: <ls_itab> TYPE STANDARD TABLE.
But now seems it is not the case. What is <ls_itab> then?
‎2006 Jun 11 9:16 AM
‎2006 Jun 11 5:12 PM
I didnot understand. If you want to have the field symbol of structure like itab1, then why do you need field symbol at all? you could have itab1 itself instead. We generally use field symbol where its structure will be determined at the run time.