08-20-2013 11:51 AM
Hi
The below statement is correct or not?...or is their way we can write it in a more better way so that it will execute more fast .
structure created is corresponds to internal table means type is same as IT.
SELECT ebeln ebelp matnr werks menge meins netpr pstyp revlv
INTO TABLE it_ekpo
FROM ekpo
WHERE ebeln IN s_ebeln AND
elikz <> 'X' AND
loekz <> 'L' AND "MOD003+
knttp <> 'F' AND
knttp <> 'K' AND
bstyp = 'F' AND
werks IN s_plant.
Please ket me know...
Thanks
08-20-2013 12:13 PM
Hello.
Fetch data using primary key/secondary index and do your processing in internal table.
SELECT ebeln ebelp loekz matnr werks menge meins netpr elikz pstyp knttp bstyp revlv
INTO TABLE it_ekpo FROM ekpo
WHERE ebeln IN s_ebeln.
delete it_ekpo where elikz = 'X'
OR loekz = 'L'
OR knttp = 'F'
OR knttp = 'K'
OR bstyp <> 'F'
OR werks NOT IN s_plant.
Regards.
08-20-2013 12:31 PM
Wrong answer.
You are reading more data from database (more columns and more rows) and have additional processing in ABAP. Why should this statement use primary / secondary index better than the original one?
Regards, Randolf
08-20-2013 12:48 PM
As you know, DB is a resource that should be used wisely since it is accessed by numerous transactions concurrently
If we give conditions for non-key fields, we are putting unnecessary load to the DB server.
Let the load be handled by the respective application server (Internal table processing).
So it is better to fetch the data using primary key/secondary key and do the processing in the internal table.
08-20-2013 12:31 PM
Hi KSRCM,
The solution you have provided is right and actually depends on the number of records. Also, if u delete the entries after fetching records, it would be fine if not more records are to be deleted after fetching. Also, check for the secondary index for the table and align the sequence accordingly.
Regards,
Shahir Mirza
08-20-2013 12:33 PM
Hi KSRCM,
For table EKPO there is a Secondary Index (1) which matches your Where clause, So you can retrieve the data using that Secondary Index.
Thanks & Regard,
-Vijay
08-20-2013 12:35 PM
Hi KSRCM SRCM,
I suggest you to proceed with the select statement including the key fields (if your current scenario permits to do so) and with where conditions. You can avoid processing the internal table after the select to exclude the unwanted records, it must be done with the select query itself.
Regards,
Anson