Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8695

Re: loop and abap code help

$
0
0

Hi Muhammad,

 

Always debug your code step by step and check if you want to know if your code is working properly or not. And also follow some coding practices like:

  •    After read statement always check for sy-subrc.
  •    After appending the work area value to the internal table, you should clear the work area value so that the next iteration will not get the previous value again.

LOOP AT it_a3 INTO wt_a3.

   READ TABLE it_kp INTO wt_kp WITH KEY knumh = wt_a3-knumh.

  IF sy-subrc = 0.

     wt_t-code = wt_a3-mwskz.

     wt_t-tax = wt_kp-kbetr.

     wt_t-value = wt_kp-kbetr / 10.

     APPEND wt_t TO it_t.

     CLEAR wt_t.

   ENDIF.

ENDLOOP.


Also for better performance you can use binary search in the read operation after sorting the concerned internal table.


Viewing all articles
Browse latest Browse all 8695

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>