Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

An abap statement, which i have found in exsiting code is comewhat not clear and i believe it is written in a wat which is time consuming..

former_member391265
Participant
0 Kudos

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

6 REPLIES 6

karun_prabhu
Active Contributor
0 Kudos

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.

0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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

VijayaKrishnaG
Active Contributor
0 Kudos

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

ansonabraham
Participant
0 Kudos

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