Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

need idea to improve performance

hi friends,

i need idea how to improve performance for this code :


 LOOP AT fl_tab INTO wa_fl_tab.

      AT NEW pernr.


        READ TABLE check_flex INTO wa_check_flex WITH KEY schkz  = 'FLEX'       pernr = wa_fl_tab-pernr .

        IF wa_check_flex-begda > so_date-low.

          so_date1-low = wa_check_flex-begda.          
          so_date1-high = so_date-high.
          so_date1-sign = 'I'.
          so_date1-option = 'BT'.

          APPEND so_date1. 

          SELECT *
          FROM catsdb
          INTO CORRESPONDING FIELDS OF TABLE cats_tab           
        FOR ALL ENTRIES IN fl_tab
          WHERE pernr = wa_fl_tab-pernr
          AND  workdate IN so_date1 .

        ELSE.


          SELECT *
          FROM catsdb
          INTO CORRESPONDING FIELDS OF TABLE cats_tab 
*         FOR ALL ENTRIES IN fl_tab
          WHERE pernr = wa_fl_tab-pernr
          AND  workdate IN so_date .

        ENDIF.


        LOOP AT cats_tab ."Collect hours

          MOVE: cats_tab-pernr  TO cats_tab_col-pernr,
                cats_tab-catshours TO cats_tab_col-catshours,
                cats_tab-status TO cats_tab_col-status.

          COLLECT cats_tab_col .

        ENDLOOP.


        LOOP AT fl_tab ASSIGNING <fl_tab>.

          READ TABLE cats_tab_col ASSIGNING <cats_tab_col> WITH KEY pernr = <fl_tab>-pernr.
          IF sy-subrc = 0.
            <cats_tab_col>-teken_hr = <fl_tab>-mostd.

          ENDIF.

        ENDLOOP.

      ENDAT.

    ENDLOOP.


Regards

Former Member
replied

Hi,

Please try this ...

RANGES: r_pernr1 for catsdb-pernr,
        r_pernr2 for catsdb-pernr.

LOOP AT fl_tab INTO wa_fl_tab.

  AT NEW pernr.
 
    READ TABLE check_flex INTO wa_check_flex 
               WITH KEY schkz  = 'FLEX'       
                        pernr  = wa_fl_tab-pernr .
 
    IF wa_check_flex-begda > so_date-low.
 
      so_date1-low = wa_check_flex-begda.          
      so_date1-high = so_date-high.
      so_date1-sign = 'I'.
      so_date1-option = 'BT'.
      APPEND so_date1. 

      r_pernr1-sign = 'I'.
      r_pernr1-option = 'EQ'.
      r_pernr1 = wa_fl_tab-pernr.
      APPEND r_pernr1.         
          
    ELSE.
   
      r_pernr2-sign = 'I'.
      r_pernr2-option = 'EQ'.
      r_pernr2 = wa_fl_tab-pernr.
      APPEND r_pernr2. 
 
    ENDIF.   
  ENDAT.
ENDLOOP.       
       
SELECT *
FROM catsdb
INTO CORRESPONDING FIELDS OF TABLE cats_tab           
WHERE pernr in r_pernr1
  AND  workdate IN so_date1.
 
 
SELECT *
FROM catsdb
APPENDING CORRESPONDING FIELDS OF TABLE cats_tab 
WHERE pernr IN r_pernr2.
  AND workdate IN so_date.

LOOP AT cats_tab.        "Collect hours

  MOVE: cats_tab-pernr     TO cats_tab_col-pernr,
        cats_tab-catshours TO cats_tab_col-catshours,
        cats_tab-status    TO cats_tab_col-status.
 
  COLLECT cats_tab_col.
ENDLOOP.

...

Regards,

Ferry Lianto

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question