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: 

Tuning performance.

ronaldo_aparecido
Contributor
0 Kudos

Hi Gurus.

I need improve the program performance of INTERFACE coulg you suggest me( or bapi or other way the tuning the performance)?

Suggestions are welcome.

DATA: v_resposta(3) TYPE c,

         v_tabix       TYPE sy-tabix.

   CLEAR:t_vbak1[],

         t_kna1_1[],

         t_adrc1[],

         t_vbap1[],

         t_marc1[].

   SELECT vbeln

          bstnk

          kunnr

          FROM vbak

          INTO TABLE t_vbak1

          WHERE erdat IN s_erdat

            AND vkorg IN s_vkorg

            AND vtweg IN s_vtweg.

   IF sy-subrc = 0.

     SELECT vbeln

            matnr

            FROM vbap

            INTO TABLE t_vbap1

            FOR ALL ENTRIES IN t_vbak1

            WHERE vbeln = t_vbak1-vbeln.

     IF sy-subrc = 0.

       SELECT matnr

              ladgr

              FROM marc

              INTO TABLE t_marc1

              FOR ALL ENTRIES IN t_vbap1

              WHERE matnr = t_vbap1-matnr.

       IF sy-subrc = 0.

         SORT: t_vbak1 BY  vbeln ,

               t_vbap1 BY  vbeln

                           matnr,

               t_marc1 BY  matnr.

         LOOP AT t_vbak1 INTO w_vbak1.

           v_tabix = sy-tabix.

           CLEAR v_resposta.

           LOOP AT t_vbap1 INTO w_vbap1 WHERE vbeln = w_vbak1-vbeln.

             READ TABLE t_marc1 INTO w_marc1 WITH KEY matnr = w_vbap1-matnr BINARY SEARCH.

             IF sy-subrc = 0.

               IF w_marc1-ladgr = '21'.

                 v_resposta = 'SIM'.

               ENDIF.

             ENDIF.

           ENDLOOP.

           IF v_resposta IS INITIAL.

             DELETE t_vbak1[] INDEX v_tabix.

           ENDIF.

         ENDLOOP.

       ENDIF.

     ENDIF.

   ENDIF.



Thanks all



1 ACCEPTED SOLUTION

philipdavy
Contributor
0 Kudos
  • First thing, you can make you use of a  nice single select query with join statement for combining  all the three tables rather than using For All Entries In.
  • I think rest of the logic you could fine tune with the internal table you are getting using the join statement.


Regards,

Philip.

11 REPLIES 11

philipdavy
Contributor
0 Kudos
  • First thing, you can make you use of a  nice single select query with join statement for combining  all the three tables rather than using For All Entries In.
  • I think rest of the logic you could fine tune with the internal table you are getting using the join statement.


Regards,

Philip.

FredericGirod
Active Contributor
0 Kudos

Hi Ronaldo,

(hi Philip !)

so, for my point of view, have a look to the VAPMA table

regards

Fred

asim_isik
Active Participant
0 Kudos

Hi Ronaldo ,

For the loop parts i think you do not need to use first loop i mean this one

LOOP AT t_vbak1 INTO w_vbak1.


Because in the second one you just vbeln from this table and in select parts you re using this code


FOR ALL ENTRIES IN t_vbak1

            WHERE vbeln = t_vbak1-vbeln.


so you doing this in select you can just delete first loop you looping that for nothing.


Should be like this i think.


LOOP AT t_vbap1 INTO w_vbap1.

     READ TABLE t_marc1 INTO w_marc1 WITH KEY matnr = w_vbap1-matnr BINARY SEARCH.

     IF sy-subrc = 0.

          IF w_marc1-ladgr = '21'.

                v_resposta = 'SIM'.

          ENDIF.

      ENDIF.


     IF v_resposta IS INITIAL.

          DELETE t_vbak1 where vbeln eq w_vbap1-vbeln.

     ENDIF.

ENDLOOP.

Former Member
0 Kudos

loop at t_vbak1 into w_vbak1.

CLEAR v_resposta.

loop at t_vbap1 into w_vbap1 from v_index.

if w_vbak1-vbeln <> w_vbap1-vbeln.

v_index = sy-tabix.

exit.

else.

READ TABLE t_marc1 INTO w_marc1 WITH KEY matnr = w_vbap1-matnr BINARY SEARCH.

IF sy-subrc = 0.

IF w_marc1-ladgr = '21'.

v_resposta = 'SIM'.

ENDIF.

ENDIF.

endif.

endloop.

IF v_resposta IS INITIAL.

DELETE t_vbak1[] INDEX v_tabix.

ENDIF.

ENDLOOP.

replace with this code

0 Kudos

Hi Vamshi ,

i think this is slower performance lets say t_vbak1 has 10.000 line and t_vbap1 has 10.000 line by your code it ll loop 10.000 * 10.000 = 100.000.000 times but in ronalde code only same vbeln will loop by using where in loop and in vbak vbeln is only key in vbak vbeln and posnr only key so 10.000 * 1 * posnr is so better performance than this.

0 Kudos

Hi Asim,

try my code it is much faster. u can check in runtime analysis too.

if possible try and let me know.....

Vamshi A

philipdavy
Contributor
0 Kudos
  • May not be the final solution you wanted . But you could build one from this,


TABLES: VBAK.

SELECT-OPTIONS: S_ERDAT FOR VBAK-ERDAT,
                 S_VKORG FOR VBAK-VKORG,
                 S_VTWEG FOR VBAK-VTWEG.

TYPES: BEGIN OF TY_TAB3,
        VBELN TYPE VBAK-VBELN,
        BSTNK TYPE VBAK-BSTNK,
        KUNNR TYPE VBAK-KUNNR,
        MATNR TYPE VBAP-MATNR,
        LADGR TYPE MARC-LADGR,
   END OF TY_TAB3.

DATA:INT_TAB3 TYPE SORTED TABLE OF TY_TAB3 WITH NON-UNIQUE KEY VBELN MATNR.

SELECT VBAK~VBELN
        VBAK~BSTNK
        VBAK~KUNNR
        VBAP~MATNR
        MARC~LADGR
        FROM VBAK JOIN VBAP ON VBAK~VBELN = VBAP~VBELN JOIN MARC ON VBAP~MATNR = MARC~MATNR
        INTO TABLE INT_TAB3
WHERE VBAK~ERDAT IN S_ERDAT
        AND VBAK~VKORG IN S_VKORG
        AND VBAK~VTWEG IN S_VTWEG AND MARC~LADGR = '21'.

Regards,

Philip.

0 Kudos

thanks

how can I measure the time of each select?

0 Kudos

You can trigger SQL trace and find out the duration for each query that ran.

0 Kudos

Hi Ronaldo,

In selecting the data your select statements are enough (Take one temp table of structure vbap1 and delete duplicates of matnr then apply for all entries to marc), there are changes to be done in loops, try my code and let me know...

It will work......

Vamshi A