Application Development and Automation 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: 
Read only

What is the difference between this 2 programms?

Former Member
0 Likes
619

     Hello guys, i just started learning ABAP so i made this 2 programms which are displaying information from the sflight table after asking for a

parameter. The both achieve the same task, but there must be a difference. Maybe in performance? Thanks verry much.

                                                                                            Program nr.1 :

   

              REPORT  ZTABLE7.

                 types: BEGIN OF ZPFLI_STRUCTURE,
                                     carrid TYPE  spfli-carrid,
                                     cityfrom type spfli-cityfrom.

                 types end of ZPFLI_STRUCTURE.

                 data: lt_join type table of ZPFLI_STRUCTURE,
                                                wa_join like line of lt_join.
                 parameters: p_par type ZPFLI_STRUCTURE-CARRID.
                select * from spfli into corresponding fields of table lt_join.

                                       loop at lt_join into wa_join.
                                                                 new-line.
                                           if p_par = wa_join-carrid.
                                                                   write:
                                                     wa_join-cityfrom.
                                       endif.
                                       endloop.


                                                                                            Program nr.2:

         

                                            REPORT  ZTABLE


                parameters p_carrid type sflight-carrid.
                data fly type spfli.

              select * from spfli into fly
              where carrid = p_carrid.
              new-line.
              write: fly-cityfrom, fly-cityto.
              endselect.

1 ACCEPTED SOLUTION
Read only

jlivio90
Active Participant
0 Likes
568

Exactly, the big difference between these code is the performance, in the first one you are selecting all records of table (this obviously is a really bad behavior ) and after you've created a logic to find out which record of internal table the program is going to show for user..

The second, you're selecting using a clausule where and passing an especific value.

If you want to analise this before you transport to production enviroment, using transactions like ST12, SE30, ST05 or STAD and if you want to learn more about, search for the topic openSQL.

Regards,

Janderson Livio

2 REPLIES 2
Read only

Florian
SAP Champion
SAP Champion
0 Likes
568

Hi Andrei,

have a look in this Wiki:

ABAP Performance and Tuning - ABAP Development - SCN Wiki

If you want to learn more about it, there is a lot good content out there.

So if you don't know how to discover it, here is a second link for you:

~Florian

Read only

jlivio90
Active Participant
0 Likes
569

Exactly, the big difference between these code is the performance, in the first one you are selecting all records of table (this obviously is a really bad behavior ) and after you've created a logic to find out which record of internal table the program is going to show for user..

The second, you're selecting using a clausule where and passing an especific value.

If you want to analise this before you transport to production enviroment, using transactions like ST12, SE30, ST05 or STAD and if you want to learn more about, search for the topic openSQL.

Regards,

Janderson Livio