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

Code optimisation

Former Member
0 Likes
690

Hello folks,

Can someone please advice mehow to make my codes below more efficient? I cant use a hash table due to non unique data. any help and advice is much appriciated.



    Types :
     BEGIN OF ty_0UCCONTRACT,
          FC_OPBEL TYPE /BI0/OIFC_OPBEL,
          FC_BLART TYPE /BI0/OIFC_BLART,
          UCCONTRACT TYPE /BI0/OIUCCONTRACT,
     END OF ty_0UCCONTRACT.

    TYPES:
    BEGIN OF l_s_logsys,
            LOGSYS TYPE RSDLOGSYS,
      END OF l_s_logsys.

    DATA : I_0UCCONTRACT TYPE STANDARD TABLE OF ty_0UCCONTRACT,
           WA_0UCCONTRACT like line of I_0UCCONTRACT.
    DATA: l_t_logsys TYPE l_s_logsys.

    IF NOT RESULT_PACKAGE IS INITIAL.

      SORT RESULT_PACKAGE BY FC_OPBEL.

      SELECT SINGLE  LOGSYS
              INTO CORRESPONDING FIELDS OF l_t_logsys
              FROM /BIC/AZBPI_D0100.

      SELECT FC_OPBEL FC_BLART UCCONTRACT
            FROM /BIC/AZBPI_D0100 INTO TABLE I_0UCCONTRACT
            FOR ALL ENTRIES IN RESULT_PACKAGE
            WHERE FC_OPBEL = RESULT_PACKAGE-FC_OPBEL AND LOGSYS =
            l_t_logsys-logsys.


    ENDIF.


    SORT I_0UCCONTRACT BY FC_OPBEL FC_BLART UCCONTRACT.

    LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
      READ TABLE I_0UCCONTRACT INTO WA_0UCCONTRACT
                                   WITH KEY FC_OPBEL =
                                   <RESULT_FIELDS>-FC_OPBEL.
      IF SY-SUBRC EQ 0.
        <RESULT_FIELDS>-UCCONTRACT = WA_0UCCONTRACT-UCCONTRACT.
        <RESULT_FIELDS>-FC_BLART = WA_0UCCONTRACT-FC_BLART.
      ENDIF.

    ENDLOOP.

3 REPLIES 3
Read only

HermannGahm
Product and Topic Expert
Product and Topic Expert
0 Likes
661

Hi,

SORT I_0UCCONTRACT BY FC_OPBEL FC_BLART UCCONTRACT.
 
    LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
      READ TABLE I_0UCCONTRACT INTO WA_0UCCONTRACT
                                   WITH KEY FC_OPBEL =
                                   <RESULT_FIELDS>-FC_OPBEL.

...

use a binary search for the read on I_0UCCONTRACT (or use a sorted table for it)

Kind regards,

Hermann

Read only

Former Member
0 Likes
661

double posting!

Here is nothing to optimize, the LOOP is nonsense, if no MODIFY is done inside.

Read only

0 Likes
661

Hi Siegfried,

Field symbols have been used in the loop and with that i don't think a Modify statement is required.

Please check again!!

Regards,

Pranav.