‎2006 May 29 10:47 AM
Hi experts
how should i modify this statement
'select single parnr from ihpa into g_parnr' inorder to improve the performance.
can i use 'read' if yes can u plz give me the code for that
regards
siri
‎2006 May 29 10:49 AM
LOOP AT IHPA.
READ TABLE DTABLE WITH KEY PARNR = IHPA-PARNR.
IF SY-SUBRC = 0.
g_parnr = IHPA-PARNR.
ENDIF.
ENDLOOP.
Message was edited by: Rahul Kavuri
‎2006 May 29 10:49 AM
LOOP AT IHPA.
READ TABLE DTABLE WITH KEY PARNR = IHPA-PARNR.
IF SY-SUBRC = 0.
g_parnr = IHPA-PARNR.
ENDIF.
ENDLOOP.
Message was edited by: Rahul Kavuri
‎2006 May 29 11:16 AM
hi thank u
do we need to declare what is dtable in the code bcoz the code u gave is showing syntax error
regards
siri
‎2006 May 29 11:22 AM
Hi Sireesha,
yes you need to declare it and then you need to select it before loop it self. check the above code.
Regards
vijay
‎2006 May 29 11:28 AM
hi vijay
for suppose i want to select the data from IHPA data base table
how should i declare at begining
and how i should use the select statement.
regards
siri
‎2006 May 29 11:39 AM
Hi,
it should be like this..
data: it_ihpa like ihpa occurs 0 with header line.
select * from ihpa into table it_ihpa.
then proceed...
Regards
vijay
‎2006 May 29 10:50 AM
Hi sireesha,
1. READ statement is for reading from
internal table (and not database table)
2. Your select statement is perfectly fine,
3. we can use where condition for this table ihpa,
for fields
OBJNR
PARVW
COUNTER
to improve the performance.
(bcos they are primary key fields of this table)
4. Other wise, there is no scope for improvement
for this simple select statement.
regards,
amit m.
‎2006 May 29 10:50 AM
YOu cannot use a read statemkent to fetch records from database.
change your select single statement to this(Use the key fields in the where clause)
select single parnr from ihpa into g_parnr where OBJNR = p_OBJNR and PARVW = p_PARVW and COUNTER = p_COUNTER.
REgards,
Ravi
‎2006 May 29 10:51 AM
Hii
use identical select statements.
Therefore, SORT the table and use READ TABLE WITH KEY BINARY SEARCH.
USE THE FOLLOWING
sort IT_VBAP BY MATNR .
LOOP AT IT_VBAP.
<b>READ TABLE IT_MAKT KEY MATNR = IT_VBAP-MATNR
TRANSPORTING MAKTX binary search .</b>
IF SY-SUBRC NE 0.
<b>SELECT MATNR MAKTX FROM MAKT
APPENDING TABLE IT_MAKT-MAKTX
WHERE MATNR EQ IT_VBAP-MATNR.</b>
ENDIF.
MOVE: IT_MAKT TO IT_VBAP-MAKTX.
ENDLOOP.
<b>Instead of: </b>
LOOP AT IT_VBAP.
SELECT SINGLE MAKTX INTO IT_VBAP-MAKTX
FROM MAKT
WHERE MATNR EQ IT_VBAP-MATNR.
ENDLOOP.
reward points if helpful .
Regards
Naresh
‎2006 May 29 10:51 AM
Hi,
Using read :
read t_internal_tab with key matnr = wa_mara-matnr binar search....
but it's applicable to internal table only and not reading database table
Plz reward points and close the thread
regards
gunjan
‎2006 May 29 10:54 AM
HI
GOOD
THERE IS NO MISTAKE IN YOUR SELECT STATEMENT AND I DONT THINK IT WILL GIVE YOU A BAD PERFORMANCE.
THANKS
MRUTYUN
‎2006 May 29 10:54 AM
Hi,
Your select single statement seems to be fine because it scans the table only for a single record which satisfies the condition. you can also use select upto 1 rows.
Regards,
Aswin
‎2006 May 29 10:55 AM
if you are using the <b>select single</b> in side<b> loop</b>, then you can use <b>for all entries</b> and then use <b>Read</b> in side loop as suggested by Rahul.
Regards
vijay
‎2006 May 29 11:00 AM
hi,
READ is for reading from internal table.
you cannot use READ for reading from the database table.
Suppose if you want to fetch more than one record from a table then don't use select single instead use select field1 field2 from table1 into table itab variant this will improve your performance...
Cheers,
Abdul Hakim
Mark all useful answers
‎2006 May 29 11:03 AM
Hi ,
First select all ur PARNR into on internale table , then use READ where ever u want
SELET PARNR FROM IHPA INTO TABLE IT_PARNR.then u can use this table whereever u want
SORT IT_PARNR by PARNR.
eg : LOOP AT IT_FINAL.
READ TABLE IT_PARNR WITH KEY PARNR = IT_FINAL-PARNR BINARY SEARCH.
ENDLOOP.