2009 Jul 29 10:47 AM
Hi there experts , My Boss always complains coz my selects are not "Efficients" Do you think there is a better way to write the following :
" The key OF TABLE ZOPT10 is :
" MANDT
" PROCESSO
" SEQUENCIA
SELECT SINGLE processo FROM zopt10
INTO wa_oport
WHERE proc_cli = zbt01-processo.
IF sy-subrc = 0.
SELECT * FROM zopt10
INTO ti_zopt10
WHERE processo = wa_oport.
APPEND ti_zopt10.
ENDSELECT.
ENDIF.Thanks . I´m trying to improve my abap skills :).
2009 Jul 29 10:52 AM
Hi ,
Try this ,
SELECT SINGLE processo FROM zopt10
INTO wa_oport
WHERE proc_cli = zbt01-processo.
IF sy-subrc = 0.
SELECT * FROM zopt10
INTO table ti_zopt10
WHERE processo = wa_oport.
ENDIF.
Instead of * use the field names what ever you want , You can use into corresponding fields also
Reagrds,
Vijay
Edited by: vijay kumar pamulapati on Jul 29, 2009 11:53 AM
2009 Jul 29 10:52 AM
Hi ,
Try this ,
SELECT SINGLE processo FROM zopt10
INTO wa_oport
WHERE proc_cli = zbt01-processo.
IF sy-subrc = 0.
SELECT * FROM zopt10
INTO table ti_zopt10
WHERE processo = wa_oport.
ENDIF.
Instead of * use the field names what ever you want , You can use into corresponding fields also
Reagrds,
Vijay
Edited by: vijay kumar pamulapati on Jul 29, 2009 11:53 AM
2009 Jul 29 10:55 AM
Hi,
Instead of using SELECT and ENDSELECT use simple SELECt statement.
Also dont use APPEND statement inside SELECT and ENDSELECT.
Create an internal table (Without Header Line) with a work area and then append the records into the table
Regards,
lakshman.
2009 Jul 29 11:00 AM
Thank you for your answers , but im a little worried ´cause i made two selects in the same table one after another.
2009 Jul 29 11:04 AM
Hi ,
Try this ,
SELECT SINGLE processo FROM zopt10
INTO wa_oport
WHERE proc_cli = zbt01-processo.
IF sy-subrc = 0.
SELECT * FROM zopt10
INTO table ti_zopt10
WHERE processo = wa_oport.
ENDIF.
APPEND LINES OF TI_ZOPT10 [] TO TI_ZOPT10_NEW [].
REFRESH TI_ZOPT10.
Reagrds,
Vijay
Edited by: vijay kumar pamulapati on Jul 29, 2009 12:04 PM
2009 Jul 29 11:19 AM
SELECT processo SEQUENCIA FROM zopt10
INTO table it_zopt10
where proc_cli = zbt01-processo.
.
2009 Jul 29 10:58 AM
The keys which u have mentioned
" The key OF TABLE ZOPT10 is :
" MANDT
" PROCESSO
" SEQUENCIA
But ur select statement looks like
SELECT SINGLE processo FROM zopt10
INTO wa_oport
WHERE proc_cli = zbt01-processo
Seems that ur using only field processo,Therefor question of single record doesnot come into picture...
There may be multiple records.
Regards,
lakshman.
2009 Jul 29 11:10 AM
Yes is true i ll get more than one , but processo will be the same for all them only the other two fields change.
2009 Jul 29 10:59 AM
hi,
Please select all the key fieds when doing select single .Also do not use select and endselect .do not append inside it aswell..
also u are writing same select queryy twice in ur code
select all the fields you want in one query into an internal table and then modify the internal table as your requirement
thanks
2009 Jul 29 11:00 AM
Hi Jose,
My first advice to you is to avoid using Select...End Select .
If you loop the select statement the database will be accessed every time which takes time.
I will suggest you to select all the enteries of the database table into an internal table and then use READ
statement to for further computations .
In this way you have reduced the database query time since all enteries are once saved into internal table .
Regards
Aditi Wason
2009 Jul 29 11:05 AM
Hi,
data: v_oport like zopt10-processo.
SELECT SINGLE processo FROM zopt10
INTO v_oport
WHERE proc_cli = zbt01-processo.
IF sy-subrc = 0.
SELECT * FROM zopt10
INTO ti_zopt10
WHERE processo = v_oport.
ENDIF.
And try to pass as many primary keys as possible in the where conditions of the select query.
Regards,
Vik
2009 Jul 29 11:08 AM
Hi,
could you explain what you are trying to do with this SELECT query.
SELECT SINGLE processo FROM zopt10
INTO wa_oport
WHERE proc_cli = zbt01-processo.Here no need to use wa_oport (if it is a work area) as you are going to get a single value only. You can use a local variable.
Thanks,
Sri.
2009 Jul 29 11:18 AM
Well is not a work area , I didnt know what wa meant i took it from other code .
2009 Jul 29 11:37 AM
Hi Jose,
In your SELECT query there is one thing which will reduce the performance that is using SELECT * . Apart form that using two selct statements will not effect the performance much. If u need to retrieve all the fields as per your requirement then only use SELECT* or else select the required fields.
Regards,
Pavan.