Code optimization - how can I optimize ?

Basically i_mara has 19,000 records and it loops for all recors as coded.
The program is taking much time when i_mch1 has 300,000 records(approximately 40 minutes).
But in case i_mch1 had 18,000 records, it is fast.
Below is the code:
FORM output_itab4_normal .
  FIELD-SYMBOLS : <lwa_makt_maktx> TYPE tt_makt_maktx,
                  <lwa_prfrq>      TYPE tt_prfrq,
                  <lwa_mch1>       TYPE tt_mch1,
                  <lwa_mvke>       TYPE tt_mvke.
  LOOP AT i_mara INTO wa_mara.
    READ TABLE i_mch1 WITH KEY matnr = wa_mara-matnr
               ASSIGNING <lwa_mch1>.
    IF sy-subrc = 0.
*-----For Recurring Inspection, go to marc table.
      READ TABLE  i_prfrq  WITH KEY matnr = wa_mara-matnr
               ASSIGNING <lwa_prfrq>.
      IF sy-subrc = 0.
        wa_final_itab-prfrq = <lwa_prfrq>-prfrq.
        READ TABLE i_mvke WITH KEY matnr = wa_mara-matnr
                  ASSIGNING <lwa_mvke>.
        IF sy-subrc = 0.
          wa_final_itab-mvgr1 = <lwa_mvke>-mvgr1.
        ENDIF.
*-------For material description, go to makt table.
        READ TABLE i_makt_maktx  WITH KEY matnr = wa_mara-matnr
                   ASSIGNING <lwa_makt_maktx>.
        IF sy-subrc = 0.
          wa_final_itab-maktx = <lwa_makt_maktx>-maktx.
        ENDIF.
        wa_final_itab-matnr = wa_mara-matnr.
        wa_final_itab-matkl = wa_mara-matkl.
        wa_final_itab-bismt = wa_mara-bismt.
        wa_final_itab-zzbismt = wa_mara-zzbismt.
        wa_final_itab-mtart = wa_mara-mtart.
        wa_final_itab-mhdhb = wa_mara-mhdhb.
        wa_final_itab-zzshtdaysdom = wa_mara-zzshtdaysdom.
        APPEND wa_final_itab TO i_final_itab.
        CLEAR : wa_final_itab, wa_mara.
      ENDIF.          " IF sy-subrc = 0.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " OUTPUT_ITAB4_NORMAL
Please help me .  Thanks in advance.

Hi,
You can refer to the following likns:
Code optimization
code optimization
Code Optimization
or
you can try this coding too As this avoids any looping and hence improve performance
Create another temporary internal table  ie. i_final_temp.
then do the following:
referesh i_final_temp.
append lines of i_final to i_fianl_temp.
delete i_final_temp where v_box ne 'X'
describe table i_final_temp lines v_counter.
Thank You.
Regards,
Dhanalakshmi L

Similar Messages

  • My ipod broke so a friend gave me their old ipod touch but they cant remember the code.  How can i unlock it and get it to work on my computer?  Please help

    My ipod is broken so a friend gave me their old ipod touch but they cant remember the code.  How can i unlock it and get it to work on my computer?  Please help

    The iPod needs to be restored but it only be restored from the computer it was last synced with
    iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    iPhone and iPod touch: Unable to update or restore

  • I'm locked out my IPOD cause I can't remember my 4 digit code. How can I unlock it?

    I'm locked out my IPOD cause I can't remember my 4 digit code. How can I unlock it?

    Hello only1ant,
    I found an article with some steps you can take if you remember the passcode on your iPod touch:
    iOS: Forgotten passcode or device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • I don't know my iTunes code. How can I get it so that I can make a purchase?

    I don't have my iTunes code.  How can I get it so that I can make a purchase?

    What iTunes code ? If you mean an iTunes gift card code then are iTunes gift cards available in your country and have you bought a gift card ?

  • I scratched the label off on a £25 gift card and it removed the code. How can I get the code for the card?

    I scratched the label off on a £25 gift card and it removed the code. How can I get the code for the card?

    Click here and request assistance. Gift cards are usually if not always final sale because it would be easy enough for someone dishonest to abuse returns or replacements of them.
    (58640)

  • I am trying to download trial CC, but i am receiving error cod 205. how can i fix this problem? few months ago, i used trial CC and deleted it.

    i am trying to download trial CC, but i am receiving error cod 205. how can i fix this problem? few months ago, i used trial CC and deleted it.

    Creative Cloud Help / Error downloading Creative Cloud applications
    http://helpx.adobe.com/creative-cloud/kb/error-downloading-cc-apps.html

  • HT4113 What is a verification code?  How can I discover where and what it is?

    What is a verification code?  How can I discover where and what it is?

    Read through this: http://support.apple.com/kb/ht5570

  • TS3694 Error code 1009 how can I fix it.

    Error code 1009 how can I fix it?

    Sound like you're using Windows, am I correct?
    If so, sounds like a host file complication.
    Do a Google search, lots of solutions.

  • How can i know how to redeem the code? how can i get this code?

    how can i know how to redeem the code? how can i get this code? please i need you help
    <Email Edited by Host>

    You are trying to create a new Apple ID? You don't have one yet? Is that correct?
    If so, then see this article on how to creat your Apple ID - and make up a password for it. Remember to write it down immediately.
    http://support.apple.com/en-us/HT203993

  • I rebooted my Iphone 5S, when I pressed the home button to enter my pass code the resolution must have been reset.  The font size is so large I can not enter my pass code.  How can I resolve this issue?

    I rebooted my Iphone 5S, when I pressed the home button to enter my pass code the resolution must have been reset.  The font size is so large I can not enter my pass code.  How can I resolve this issue?

    Triple click Home.
    After you get into the iPhone, Settings > General > Acessibility and set Zoom to Off.

  • I scratched to hard on my iTunes gift card  and rubbed the code off, how can I redeem my gift card without that code??

    I scratched off my iTunes gift card redeemation code. How can I redeeem it????
    Thanks
    Sheila

    iTunes Store: Invalid, inactive, or illegible codes

  • Hello! I havent received any code after paying for it! Money's been withdrawn from my bank account and all I have now is a transaction code. How can I get the code for Photoshop?

    I havent received any code after paying for it! Money's been withdrawn from my bank account and all I have now is a transaction code. How can I get the code for Photoshop?

    You'll need to call Adobe customer support on the telephone.  There's little we fellow users can do to help you.
    -Noel

  • My iPad updated and wants a security code. I tried the one from my phone and it doesn't work - I never entered a security code. How can I get in now?

    ?My iPad updated and now wants a security code for access and I never gave it one. I tried code I used for my phone and it doesn't work. How can I access now?

    iOS: Device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    How can I unlock my iPad if I forgot the passcode?
    http://tinyurl.com/7ndy8tb
    How to Reset a Forgotten Password for an iOS Device
    http://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Device
    Using iPhone/iPad Recovery Mode
    http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
    Saw this solution on another post about an iPad in a school environment. Might work on your iPad so you won't lose everything.
    ~~~~~~~~~~~~~
    ‘iPad is disabled’ fix without resetting using iTunes
    Today I met my match with an iPad that had a passcode entered too many times, resulting in it displaying the message ‘iPad is disabled – Connect to iTunes’. This was a student iPad and since they use Notability for most of their work there was a chance that her files were not all backed up to the cloud. I really wanted to just re-activate the iPad instead of totally resetting it back to our default image.
    I reached out to my PLN on Twitter and had some help from a few people through retweets and a couple of clarification tweets. I love that so many are willing to help out so quickly. Through this I also learned that I look like Lt. Riker from Star Trek (thanks @FillineMachine).
    Through some trial and error (and a little sheer luck), I was able to reactivate the iPad without loosing any data. Note, this will only work on the computer it last synced with. Here’s how:
    1. Configurator is useless in reactivating a locked iPad. You will only be able to completely reformat the iPad using Configurator. If that’s ok with you, go for it – otherwise don’t waste your time trying to figure it out.
    2. Open iTunes with the iPad disconnected.
    3. Connect the iPad to the computer and wait for it to show up in the devices section in iTunes.
    4. Click on the iPad name when it appears and you will be given the option to restore a backup or setup as a new iPad (since it is locked).
    5. Click ‘Setup as new iPad’ and then click restore.
    6. The iPad will start backing up before it does the full restore and sync. CANCEL THE BACKUP IMMEDIATELY. You do this by clicking the small x in the status window in iTunes.
    7. When the backup cancels, it immediately starts syncing – cancel this as well using the same small x in the iTunes status window.
    8. The first stage in the restore process unlocks the iPad, you are basically just cancelling out the restore process as soon as it reactivates the iPad.
    If done correctly, you will experience no data loss and the result will be a reactivated iPad. I have now tried this with about 5 iPads that were locked identically by students and each time it worked like a charm.
    ~~~~~~~~~~~~~
    Try it and good luck. You have nothing more to lose if it doesn't work for you.
     Cheers, Tom

  • T-code : CRMC_R3_ORG_GENERATE, How can I link to the target system??

    Hi, everyone.
    First of all, Thanks for your reading my message with my heart.
    We are facing the critical problem.
    We want to download the customer master in R3 system to CRM(BBP600), but the problem is that there is no SALES AREA DATA!! (we need the sales office value for some reason.)
    Basically, CRM is linked to R/3(domestic system) and the customer data we want to download is in another R/3(Foreign GmbH system)
    we thought that the reason is there's no DIST,Channel and Division in PPOMA_CRM.
    so, we excuted the transaction, CRMC_R3_ORG_GENERATE to download the sales area organization,
    but the system we saw was not that we hope to link.
    How can we set the destination we hope to link for T-code CRMC_R3_ORG_GENERATE ?!?!
    If somebody know the procedure to connect to R/3(Foreign GmbH system), Please help us
    I really appreciate your help in advance.
    Thanks
    Best rgds,
    Hyo-ki

    Thank you for your reply.
    Before reading your advice, We delete all site ID and created new site ID for Foreign GmbH.
    after that, now we can connect to that system, and we can see the list of R3 sales area data.
    But, when we excuted the 'Creation' button, the system showed us red alert status in the bottom list screen of .CRMC_R3_ORG_GENERATE. T_T
    We already have the dist.channel code list and division code list for R3(domestic) in CRM,
    and another R3(Foreign) has the same codes list for Dist.channel and division.
    for example,
    R3(domestic) has customer code - 200341, and its sales area is 1000 / 20 / 10, and
    R3(Foreign) has the same customer code - 345201, and its sales area is 4100 / 20 / 10.
    so, I think the same codes of dis.channel and division causes that system showed red alert.
    am I correct??
    then, Is there any good strategy to maintain Customer master data (or any master data) in TWO R/3 systems with only one CRM
    using each dist.channel and division(the same code) ?

  • HT1766 I forget the itune backup pass code. How can I retrieve it? thanks

    I forget the pass code for itune backup. How can I retreive it? Thanks

    https://discussions.apple.com/message/19682844#19682844

  • I don't even know my pass code . How can I check it?

    How can I check my pass code?

    If you've forgotten the passcode to unlock your iPad then you will need to reset the iPad (it's not stored anywhere) : http://support.apple.com/kb/HT1212

Maybe you are looking for