End Routine ABAP running slow

We have written the following end routine but performance is too slow because of the number of loops.
We have introduced the third loop since we need the records in the specific order to populate ZCUST.  Can someone advise on how we can optimize
Thanks
$$ begin of routine - insert your code only below this line        -
    data: TEMP_RESULT_PACKAGE like RESULT_PACKAGE,
          WA_RESULT_PACKAGE type TYS_TG_1,
          WA type TYS_TG_1.
    TEMP_RESULT_PACKAGE[] = RESULT_PACKAGE[].
    delete adjacent duplicates from RESULT_PACKAGE
                    comparing DIVISION DISTR_CHAN SALESORG CUST_SALES.
    loop at RESULT_PACKAGE into WA_RESULT_PACKAGE.
      clear WA.
      loop at TEMP_RESULT_PACKAGE into WA
                       where DIVISION = WA_RESULT_PACKAGE-DIVISION
                       and   DISTR_CHAN = WA_RESULT_PACKAGE-DISTR_CHAN
                       and   SALESORG = WA_RESULT_PACKAGE-SALESORG
                       and   CUST_SALES = WA_RESULT_PACKAGE-CUST_SALES.
        if not WA-SHIP_TO is initial.
          WA_RESULT_PACKAGE-SHIP_TO = WA-SHIP_TO.
        endif.
        if not WA-CUST_HIE01 is initial.
          WA_RESULT_PACKAGE-CUST_HIE01 = WA-CUST_HIE01.
        endif.
        if not WA-CUST_HIE02 is initial.
        if not WA-BILLTOPRTY is initial.
          WA_RESULT_PACKAGE-BILLTOPRTY = WA-BILLTOPRTY.
        endif.
        if not WA-PAYER is initial.
          WA_RESULT_PACKAGE-PAYER = WA-PAYER.
        endif.
        if not WA-/BIC/OSSLSREP is initial.
          WA_RESULT_PACKAGE-/BIC/ZSREP = WA-/BIC/ZSREP.
        endif.
        if not WA-/BIC/OSBRO is initial.
          WA_RESULT_PACKAGE-/BIC/ZBRO = WA-/BIC/ZBRO.
        endif.
        if not WA-/BIC/OSCTREMP is initial.
          WA_RESULT_PACKAGE-/BIC/ZREMP = WA-/BIC/ZREMP.
        endif.
        if not WA-/BIC/OSOPR is initial.
          WA_RESULT_PACKAGE-/BIC/ZPRI = WA-/BIC/ZPRI.
        endif.
        endloop.
        sort TEMP_RESULT_PACKAGE by DIVISION DISTR_CHAN SALESORG CUST_SALES /BIC/ZBRO /BIC/ZSREP /BIC/ZREMP.
        clear WA.
              loop at TEMP_RESULT_PACKAGE into WA
                       where DIVISION = WA_RESULT_PACKAGE-DIVISION
                       and   DISTR_CHAN = WA_RESULT_PACKAGE-DISTR_CHAN
                       and   SALESORG = WA_RESULT_PACKAGE-SALESORG
                       and   CUST_SALES = WA_RESULT_PACKAGE-CUST_SALES.
        IF NOT WA-/BIC/ZCUST IS INITIAL.
          WA_RESULT_PACKAGE-/bic/ZCUST = WA-/BIC/ZCUST.
        ENDIF.
      endloop.
      modify RESULT_PACKAGE from WA_RESULT_PACKAGE.
      clear WA_RESULT_PACKAGE.
    endloop.

Hi,
I have to suggestions for you:
1. use typed field-symbols for every loop
2. I try to understand, what you are doing: you will at least be sure, that every necessary/key infoobject is filled with the same value from your result_package.
I would try to separate it in two steps:
1) build up your temp_result_package and make your assignments.
2) do only a efficient read-table (sorted/hashed with key DIVISION DISTR_CHAN SALESORG CUST_SALES /BIC/ZBRO /BIC/ZSREP /BIC/ZREMP and field-symbols) on your inside your loop.
3. by using field-symbols, your modify table is obsolete and costs a lot of time.
Kind regards,
Hendrik

Similar Messages

  • End Routine ABAP to read from Internal table and do calculation.

    Hi All...
    I have completed some coding in a start routine to extract some fields from a DSO containing Master Data (Stock Age) into an internal table (the internal table has been defined in the global declarations area) which will then be read in the end routine.
    (the internal table will be read) at loadtime in the end routine and used in a calculation as described below.
    I.E
    GLOBAL DATA DECLARATION
    Data: ITAB1 TYPE TABLE OF /BIC/DSOTAB
    (DSOTAB has 3 fields PLANT, STYLE, 1STDATE (1STDATE IS A DATE FIELD)
    The start routine has the following code:
    IF ITAB1 IS INITIAL.
    SELECT /BIC/PLANT /BIC/STYLE /BIC/1STDATE
                    FROM /BIC/DSOTAB
                    INTO CORRESPONDING FIELDS OF TABLE ITAB1.
    This is working fine when run under simulation i.e ITAB1 is filled no problem.
    I then need to do a calculation in the end routine.
    1. First I have to find the record in the internal table using the key of PLANT AND STYLE from the RESULT_PACKAGE.
    The code i am using now is as follows....
        READ TABLE ITAB1 TRANSPORTING NO FIELDS WITH KEY
        /BIC/PLANT = <result_fields>-/BIC/PLANT /BIC/STYLE =
        <result_fields>-/BIC/STYLE.
    Once this record has been read I then have to perform the following calculation using the following additional fields
    <result_fields>-/BIC/DYS1ST is a NUMC field in the <result_fields> that will be be filled by the result of the calculation described below.
    <result_fields>-CALDAY is a date field which is already populated in the <result-fields> which is used in the calculation below.
    The Calculation required is a difference in days between two dates
    DYS1ST = CALDAY - 1STRED.
    The code i am using is
    If sy-subrc = 0.
         <result_fields>-/BIC/DYS1ST = <result_fields>-CALDAY -
         i_t_1stred_dso-/BIC/1STRED.
    So the whole section of code inside the LOOP at RESULT PACKAGE looks like this in the end routine
           READ TABLE ITAB1 TRANSPORTING NO FIELDS WITH KEY
        /BIC/PLANT = <result_fields>-/BIC/PLANT /BIC/STYLE =
        <result_fields>-/BIC/STYLE.
    IF sy-subrc = 0.
         <result_fields>-/BIC/DYS1ST = <result_fields>-CALDAY -
         i_t_1stred_dso-/BIC/1STRED.
    Im getting the error
    "ITAB1 " is a table without a header line and therefore has no component called "/BIC/1STRED
    Please can someone advise as to what I need to do to get this fixed please.
    Thanks in advance
    Stevo:)

    Hi,
    You will have to do few changes in your code as below,
    GLOBAL DATA DECLARATION
    Data: ITAB1 TYPE standard TABLE OF /BIC/DSOTAB.
    After that declare a workarea to read the values.
    DATA: i_wa_itab1 type /bic/dsotab.
    (DSOTAB has 3 fields PLANT, STYLE, 1STDATE (1STDATE IS A DATE FIELD)
    The start routine has the following code:
    IF ITAB1 IS INITIAL.
    SELECT /BIC/PLANT /BIC/STYLE /BIC/1STDATE
    FROM /BIC/DSOTAB
    INTO CORRESPONDING FIELDS OF TABLE ITAB1.
    This is working fine when run under simulation i.e ITAB1 is filled no problem.
    I then need to do a calculation in the end routine.
    1. First I have to find the record in the internal table using the key of PLANT AND STYLE from the RESULT_PACKAGE.
    The code i am using now is as follows....
    READ TABLE ITAB1 TRANSPORTING NO FIELDS WITH KEY
    /BIC/PLANT = <result_fields>-/BIC/PLANT /BIC/STYLE =
    <result_fields>-/BIC/STYLE.
    Once this record has been read I then have to perform the following calculation using the following additional fields
    <result_fields>-/BIC/DYS1ST is a NUMC field in the <result_fields> that will be be filled by the result of the calculation described below.
    <result_fields>-CALDAY is a date field which is already populated in the <result-fields> which is used in the calculation below.
    The Calculation required is a difference in days between two dates
    DYS1ST = CALDAY - 1STRED.
    The code i am using is
    If sy-subrc = 0.
    <result_fields>-/BIC/DYS1ST = <result_fields>-CALDAY -
    i_t_1stred_dso-/BIC/1STRED.
    So the whole section of code inside the LOOP at RESULT PACKAGE looks like this in the end routine
    READ TABLE ITAB1 into i_wa_itab1 WITH KEY
    /BIC/PLANT = <result_fields>-/BIC/PLANT /BIC/STYLE =
    <result_fields>-/BIC/STYLE.
    IF sy-subrc = 0.
    <result_fields>-/BIC/DYS1ST = <result_fields>-CALDAY -
    i_wa_itab1-/BIC/1STRED.
    Once you do this changes, your code will work fine.
    Regards,
    Durgesh.

  • Filling Data fields of a DSO in End Routine

    Hi Everyone,
    The data fields of a DSO contains 2 key figures and a characteristic.
    In the End routine of the transformation, i have assigned constant values for the infoobjects in the data field.
    After executing the DTP, if I check in the New Table of the DSO, these constant values are present.  But when I activate the DSO, the values for key figures gets initialised and the values for the characterisitic becomes empty (NULL).
    Is it not possible to assign values for the infoobjects in the data field? If so, why is this limitation?
    Thanks in advance,
    Uma

    Uma,
    To populate any field in the end routine, you have to assign some constant in the transformation first and then re-populate them using the end routine.
    Sometimes if you dont assign any constant in transformation, the values remain initial and even after you write a code fo that field, it is not populated in the end routine.
    All you have to do is assign constant 0 to the key figures you are populating in the end routine and run the DTP again.
    Thanks
    Sachin

  • I recently upgraded to Lion and i find that my computer is running slow and applications are crashing.  For example I have Word 2011 for Mac and it crashes all the time I end up losing my work.  It often happens when I'm in notebook trying to record.

    i recently upgraded to Lion and i find that my computer is running slow and applications are crashing.  For example I have Word 2011 for Mac and it crashes all the time I end up losing my work.  It often happens when I'm in class using notebook and when I press record my computer starts thinking and it freezes.
    Also, I feel that it overheats often and my battery runs out pretty quickly.  I had the macbook (black) and this never happened before.  I'm not sure if I'm doing something wrong or if there is something with my computer.I bought my computer summer 2010, I don't think this should be happening. Please Help......

    This is exactly what keeps happening to mine too.  I was at a conference taking notes, and I was
    using the Notebook template, and doing some audio recording simultaneously.  About 3 hours into the conference (not consistently recording, but on and off with the sessions) my file wouldn't save anymore, saying something like "File cannot be modified while in use with another program" and "Invalid file name" when I would go back into my folder to look for it). I tried installing some updates from Microsoft, and when I restarted, I was at least able to open my old notes again, and so far it looks like the audio was working.  However, today at the conference, the same thing happened again, but I wasn't actively recording any audio (though after I had copy and pasted my second file of notes into the original, I went back to using it after re-naming it). 
    Does the crash happen to you under similar cirucumstances?  The update might help a little, but it is definitely not the solution.  Does anyone have any solutions?  Lion shouldn't be this buggy... I moved to Mac to get away from the garbage of bugs and compatibility issues...

  • Do you have any ideas why Motion 5 would run slow on a computer? I have an Imac with 8Gigs of ram, and plenty of hard drive space, but it still gives me the beach ball when I add a few lights and effects. I'm at the end of my rope.

    Do you have any ideas why Motion 5 would run slow on a computer? I have an Imac with 8Gigs of ram, and plenty of hard drive space, but it still gives me the beach ball when I add a few lights and effects. I'm at the end of my rope.

    You probably don't really need 1080 at 60 for your finished projects but since you're just starting out with Motion, you need to lower your expectations. A long way. 1080 is about 2 million pixels per frame, DV is only about 400,000. That's not just five times as many pixels for the Mac to track; everything in video is exponential.
    Explore the training tutorials available by Mark Spencer. You will get an idea of how his super powerful machine reacts with the software.
    Adding a light roughly doubles the processing time over flat scenes. Two lights increases processing again. Reflections require processing the lights and then calculating the reflections so add another quarter of the time required for flat scenes. Add camera movement, motion blur, and depth of field and you need exponentially more processing time for every frame. The preload of renders into RAM is one of the cooler features of Motion, as comapred to After Effects, but that takes tons of time, to.
    Try working in ye olde DV resolution for a few days. Get to know the software's limitations and what gets imposed by your Macintosh. Step up to 720p/30 and see how things slow down.

  • Primitive APAB editor in start/end routines in transformations

    When editing or viewing ABAP code in BI transformations, for example in a start routine, the editor that opens is very primitive compared to the normal SE38 editor. Some of the limitations include:
    The editor window doesn't cover the whole screen with seemingly no way to increase its size.
    The syntax check doesn't show on which line syntax errors are located.
    There is no option to perform a extended program check.
    There is no way to insert break-points (other than with the ABAP keyword of course)
    These limitations are present regardless of whether i choose the new front-end editor, the old front-end editor or the back-end editor. We're running SAP Netweaver 2004s.
    It is of course possible to create a program in SE38 and copy-paste your start routine code to see the code using the "real" editor, but this is very tiresome and time consuming. Is there a way to make this editor look and behave like the normal editor? I have looked through the setting options an searched SDN without finding a way.

    Hi,
    This is just the settings you need to change to open the start,end, and characteristics routine using the old editor you are comfortable with. No need to go to se38 and check copy the program.
    Go to se38->Utilities->settings->abap editor->editor tab->select the old abap editor.
    To specifically put break point in transformations (start routine..end routine..)..goto transformation (RSA1) and then display the transformation.
    Then goto extra (menu)->generated program. search for start_routine (method now) and put break point in the desired place.
    Then from the DTP enable all 4 break points..in tranformation (this will come when u cange it to debug mode simulation). And u can debug the transformation.
    The new editor is a good handy one. But take some time to get acquented to it. After you may start liking it :).
    Cheers,
    -J

  • Computer running slow, and problems downloading new software

    i have a powerbook g4 and it running slow at times. my dad bought a new one and gave me this one and my powerbook runs half of the speed of his. this is my 1st mac and i am trying to figure it out. my mac tends to freeze up sometimes when i am online. my cursor indicates that it is loading, but it takes a long time to load. most of the times i just force quit safari and try it again. also, when i try to install software off of the net, it ask me to pick a software to use to open it. i have tried almost every software on the computer and i have yet to run the installer. my email account is on hotmail, and my mac will not allow me to go straight to hotmail.com to retrieve emails. hotmail tells me that i have to download new software to be able to retrieve my mail, and that brings me to the above problem with downloading software. my mac runs on mac OS X version 10.3.9 if that is any help to you, thanks

    Welcome! You bring up a lot of issues but most suggest simply a need for some routine file maintenance. One of the best resources is here:
    http://thexlab.com/faqs/faqs.html
    There are a lot of articles; focus on those with titles about maintenance, tuning, and freeing space on the hard drive
    It would be helpful to know a little more about your PB, like the processor speed and the amount of RAM installed. Both are available by selecting "About the Mac..." from the blue Apple menu at the let end of the menubar.

  • Selecting, reading and sum of billing quantity for last 12 months in transformation end routine

    Hi experts,
    i have requirement to write end routine to read a DSO for last 12 months sales quantity for each month and sum value pass to keyfigure
    not interested using bex variable, while data loading from source to target dso in end routine i am trying to read another DSO which is same as my
    target dso where information is stored by fiscal period, year material etc. finally there is  a keyfigure in target whih needs to be filled with sum of 12
    months sales quantity, for each record form sourc to target maximum of 12 records will be in read dso (for 12 months) my routine is like below.
    i am not expert in abap please kindly gothrough and guide me in this
    TYPES: BEGIN OF s_/BIC/AZOSLS00,
    FISCPER  type /BI0/OIFISCPER,
    FISCVARNT  type /BI0/OIFISCVARNT,
    PLANT  type /BI0/OIPLANT,
    STOR_LOC  type /BI0/OISTOR_LOC,
    /BIC/MATERIAL  type /BIC/OIMATERIAL,
    VTYPE  type /BI0/OIVTYPE,
    BILL_QTY  type /BI0/OIBILL_QTY,
    END OF s_/BIC/AZOSLS00.
    DATA: it_/BIC/AZOSLS00 TYPE TABLE OF s_/BIC/AZOSLS00,
    wa_/BIC/AZOSLS00  TYPE s_/BIC/AZOSLS00.
    SELECT
    FISCPER
    FISCVARNT
    PLANT
    STOR_LOC
    /BIC/MATERIAL
    VTYPE
    BILL_QTY
         FROM /BIC/AZOSLS00 INTO TABLE it_/BIC/AZOSLS00
           FOR ALL
          ENTRIES IN RESULT_PACKAGE
           WHERE
    below field is from value of fiscal period (which is fiscal period -999 ex:  for 001.2014 this
    value will be 002.2013 so 12 months including current period)
    FISCPER >=  RESULT_PACKAGE-/BIC/ZFISCPERF
    below is result filed fiscal period (here i dont know which keyword or statement to be used to select
    interval values this between statement giving syntax error that can not be used in where for for all entries
    between RESULT_PACKAGE-FISCPER
            AND
             FISCVARNT = RESULT_PACKAGE-FISCVARNT AND
             PLANT = RESULT_PACKAGE-PLANT AND
             STOR_LOC = RESULT_PACKAGE-STOR_LOC and
          /BIC/MATERIAL = RESULT_PACKAGE-/BIC/MATERIAL .
        SORT it_/BIC/AZOSLS00 BY FISCPER FISCVARNT PLANT STOR_LOC
        /BIC/MATERIAL .
        LOOP AT RESULT_PACKAGE ASSIGNING <result_fields>.
          READ TABLE it_/BIC/AZOSLS00 INTO wa_/BIC/AZOSLS00 WITH KEY
    below dont know what statement i need to use in read statement for interval of fiscal periods
    giving error that >= can not be used
         FISCPER >=  <result_fields>-/BIC/ZFISCPERF
    FISCPER = <result_fields>-FISCPER
             FISCVARNT = <result_fields>-FISCVARNT
             PLANT = <result_fields>-PLANT
             STOR_LOC = <result_fields>-STOR_LOC
          /BIC/MATERIAL = <result_fields>-/BIC/MATERIAL
           BINARY SEARCH.
          BREAK-POINT.
          IF sy-subrc = 0.
    below for each record there will be 12 records in read so sume of 12 records quantity i need to pass to result again dont know what to say here
    sum statement giving error
                <result_fields>-/BIC/ZLSTSLS12 =
                 sum(wa_/BIC/AZOSLS00-BILL_QTY).
              ENDIF.
        ENDLOOP.
    friends please help me in this.
    Thanks
    Chandra.

    Hiii,
    If you only want to store last  12 months data in Target ODS .
    Then Create filter in DTP and write routine in filter for calmonth or fiscal period.
    Refer the below link to create filter routine :
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80b2db87-639b-2e10-a8b9-c1ac0a44a7a6?QuickLink=index&…
    Regards,
    Akshay

  • How to add new records in Start routine or end routine.

    Hi All,
            My requirement is to transfer data from one DSO to anothe DSO. But while transfering a single record frorm DSO1 i want to add 7 records to DSO2 for each record in DSO1 with slight change in data( with a different key). I want to do it in start routine or end routine. How can i do it. If you have any ABAP code for this then please send.
    Regards
    Amlan

    you can use this code, replace the fields where i have marked with <>.
    DATA : WA_RESULT_PACKAGE TYPE DSO2,
           WA_RESULT_PACKAGE1 LIKE WA_RESULT_PACKAGE.
    DATA : IT_RESULT_PACKAGE LIKE TABLE OF WA_RESULT_PACKAGE.
    DATA : DATE1 TYPE SY-DATUM.
    DATA : DAYDIFF TYPE i.
    DATA : RECORD_NO type rsarecord.
    SORT RESULT_PACKAGE BY <KEY FIELDS> "specify the key fields here
    RECORD_NO = 1.
    LOOP AT RESULT_PACKAGE INTO WA_RESULT_PACKAGE.
         IF WA_RESULT_PACKAGE_1-<KEYFIELDS> NE WA_RESULT_PACKAGE-<KEYFIELDS>.
              WA_RESULT_PACKAGE_1 = WA_RESULT_PACKAGE.
              DAYDIFF = WA_RESULT_PACKAGE-ENDDATE - WA_RESULT_PACKAGE-STARTDATE.
                   WHILE DAYDIFF NE 0.
                        DATE1 = WA_RESULT_PACKAGE-STARTDATE + DAYDIFF.
                        MOVE DATE1 TO WA_RESULT_PACKAGE-<KEYFIELDDATE>.
                        MOVE RECORD_NO TO WA_RESULT_PACKAGE-RECORD.
                        APPEND WA_RESULT_PACKAGE INTO IT_RESULT_PACKAGE.
                        DAYDIFF = DAYDIFF - 1.
                        RECORD_NO = RECORD_NO + 1.
                        CLEAR DATE1.
                   ENDWHILE.
              CLEAR DAYDIFF.
         ENDIF.
    ENDLOOP.
    DELETE RESULT_PACKAGE[].
    RESULT_PACKAGE[] = IT_RESULT_PACKAGE[].
    Reg Point 3.
    The Key figures will then show up in the report aggregated.Hope that is fine with you.
    Note:
    Before loading data, in DTP set the semantic key with the key field of the DSO1.This brings all the similar data w.r.t the key fields from the PSA together in a single package.
    rgds, Ghuru

  • Source Field in End Routine of DSO Transformation

    Hi,
    I made a transformation from source DSO to Target DSO.
    There are 7 fields in source & 6 fields in target..All the 6 fields are one to one mapped from the source to Target
    I need to write a simple ABAP Logic in End Routine based on the 7th source field which is not mapped.
    Please let me know the piece of ABAP code or steps where i can get the value of Source table in End routine
    Regards
    Suresh

    Hi Suresh,
                      Check here.........
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e73bfc19-0e01-0010-23bc-ef0ad53f2fab
    http://help.sap.com/saphelp_nw70/helpdata/en/e3/732c42be6fde2ce10000000a1550b0/frameset.htm
    Regards,
    Vijay.

  • End routine help

    Hi Experts,
    I have an CUBE which is loading once in a week(full load). In that cube i have plant and material and some other fields . My requirement is
    1) i have to delete some materials from all the plants from the cube like mat1,mat2,mat3..etc from all the plants
    and
    2)have to delete one material for some plants  like delete Mat8 for Plnt2 ,plnt5 and plnt 7.
    For that i have written some code in End routine....As i am not an ABAPer, I need corrections ..please look in to and advice.
      1)
    data: Wa_Result_Package type tys_TG_1.
        loop at RESULT_PACKAGE into Wa_RESULT_PACKAGE.
      delete Wa_Result_package .
          if Wa_Result_package-/BIC/ZMATERIAL = 'MAT1' or
             Wa_Result_package-/BIC/ZMATERIAL = 'MAT4' or
             Wa_Result_package-/BIC/ZMATERIAL = 'MAT6' or
             Wa_Result_package-/BIC/ZMATERIAL = 'MAT7' or
             Wa_Result_package-/BIC/ZMATERIAL = 'MAT9' .
            modify RESULT_PACKAGE from Wa_RESULT_PACKAGE.
          endif.
        endloop.
      2)
    data: Wa_Result_Package type tys_TG_1.
        loop at RESULT_PACKAGE into Wa_RESULT_PACKAGE.
    delete Wa_Result_package
          if Wa_Result_package-plant = 'PLNT2' and  Wa_Result_package-plant =
          'PLNT4' and  Wa_Result_package-plant = 'PLNT8'.
            then delete Wa_Result_package-/BIC/ZMATERIAL = 'MAT8'.
            modify RESULT_PACKAGE from Wa_RESULT_PACKAGE.
          endif.
        endloop.
    Please Advise,
    KP

    Hi Saveen,
    I modified acc to ur advice..please correct..
    1)
    data: Wa_Result_Package type tys_TG_1.
    loop at RESULT_PACKAGE into Wa_RESULT_PACKAGE.
    delete Result_package .
    where Wa_Result_package-/BIC/ZMATERIAL = 'MAT1' or
    Wa_Result_package-/BIC/ZMATERIAL = 'MAT4' or
    Wa_Result_package-/BIC/ZMATERIAL = 'MAT6' or
    Wa_Result_package-/BIC/ZMATERIAL = 'MAT7' or
    Wa_Result_package-/BIC/ZMATERIAL = 'MAT9' .
    modify RESULT_PACKAGE from Wa_RESULT_PACKAGE.
    endif.
    endloop.
    2)
    data: Wa_Result_Package type tys_TG_1.
    loop at RESULT_PACKAGE into Wa_RESULT_PACKAGE.
    delete Result_package
    where  Wa_Result_package-plant = 'PLNT2' and Wa_Result_package-plant =
    'PLNT4' and Wa_Result_package-plant = 'PLNT8'.
    then delete Wa_Result_package-/BIC/ZMATERIAL = 'MAT8'.
    modify RESULT_PACKAGE from Wa_RESULT_PACKAGE.
    endif.
    endloop
    Regards...KP

  • End routine Works fine but missing some records while updating to cube.

    Hi All
    I have an issue here... My End routine works fine and I even debugged by putting the breakpoint and It fetches data from dso. strangely when I run my DTP the load is successful but I can see some of the records are missing. but there is data in dso and also when i debug the code it fetches the values for particular fields.
    My requirement is I have a cube 'A' and under it DSO1 and  I need six more fields from dso2. Now I made a look up for these six fields in End routine. My routine works fine and so the DTP Is Green. My issue is I cant see these six fields updated for some of the records.
    PLZ put some light on it!!!!!!!!!!!!!!!!!

    Hi Naveen & Jaya
    Thanks for your quick response. Below is my code logic in end routine.
    METHOD end_routine.
    *=== Segments ===
        FIELD-SYMBOLS:
          <RESULT_FIELDS>    TYPE tys_TG_1.
        DATA:
          MONITOR_REC     TYPE rstmonitor.
    $$ begin of routine - insert your code only below this line        -
    ... "insert your code here
    data: lv_result_package like line of RESULT_PACKAGE,
          l_tabix type sy-tabix.
    loop at RESULT_PACKAGE into lv_RESULT_PACKAGE.
       l_tabix = sy-tabix.
    Update lot/decision attributes Lot/Decision ( ZQM_O04 ) DSO
       read table itab_qm_o04 into itab_qm_o04_wa
           with key insp_lot = lv_result_package-insp_lot.
       if sy-subrc = 0.
         lv_result_package-ivaluation = itab_qm_o04_wa-ivaluation.
         lv_result_package-catcode_ud = itab_qm_o04_wa-catcode_ud.
         lv_result_package-catgrp_ud = itab_qm_o04_wa-catgrp_ud.
         lv_result_package-/bic/zcattp_ud = itab_qm_o04_wa-/bic/zcattp_ud.
         lv_result_package-/b41/s_usuddate = itab_qm_o04_wa-/bic/gqmuddat.
         lv_result_package-/b41/s_usudcdate = itab_qm_o04_wa-/bic/gqmudcdt.
       endif.
       modify RESULT_PACKAGE FROM lv_RESULT_PACKAGE INDEX l_tabix.
    endloop.
    Well based on the insp_lot in ZQM_O03( DSO1) the logic above gets the six fields from ZQM_O04(DSO2) and feeds the cube.
    The Insp_lot has multiple records in DSO1 based on specific characteristic and so the cube. This Logic gets all these six fields
    from DSO2 which has single record per insp_lot and feeds the cube which has multiple records on insp_lot based on a specific characteristic. For some reason some of the records are not been updated to cube.
    waiting for your valuable response.....
    Thank You,
    Abhishek Yeachni

  • BI end routine at transformation to populate info object by vlookup attribu

    Hi ,
    I am APO consultant working in Bi routines and I have the follwoing situation and need some guidance in ABAP code (routine) .
    We sales info from markets as flat filea snd lod them into cubes. One of the filed is file is External sales Group: ZEXSGRP. This is an attribute or Sales Group info object ZSLSGRP.
    We get external sales group populated in file when we upload the file into cube -  I  want to use end routine to vlook up the  info infoobject table ZSLSGRP - all the external sales groups and use the matching value to write Sales Group (ZSLSGRP).Example  if ZSLSGRP  is NAM and it attribute is  ZEXSGRP  and has value N0000032. The file gets value N0000032 so the end routine should look all attribute of all infoobject ZSLSGRP and match the value and populate in example above it populates NAM.
    Hope i am clear - can any help with this.
    thaks
    Varma

    Replace your select statement ,
    SELECT *
    FROM /BIC/PZF31SALOFF
    INTO CORRESPONDING FIELDS OF TABLE it_tab4.
    instead of selecting all the fields , pick only the fields which are required.(one good performance improvement)
    SELECT    /BIC/PZF31SALOFF  comp_code
    FROM /BIC/PZF31SALOFF
    INTO CORRESPONDING FIELDS OF TABLE it_tab4.
    Remove the line below , this is not required
    MODIFY it_tab4 FROM wa_tab4.

  • End Routine to populate custom AFS field for Billing Item extractor

    I have the following scenario for Billing 2LIS_13_VDITM datasource
    Doc_No   Item  Material    Item_Categ   AFS_field
    2000        11     XYZ          123
    2000        12     XYZ          123                  US1
    3000        11     PQR          456                 
    3000        12     PQR          456                  CA1
    I need to populate the AFS_field in the first row also for all Doc Nos for certain Item categories (eg 123 & 456). I need to do this on the first transformation from PSA to DSO. I was planning to write a SELECT statement in the Start Routine with the PSA table as the reference as seen below and then write an End Routine calling this reference table. But the PSA table name is different in Dev, QA and Prod so I cannot use this.
    TYPES: BEGIN OF S_AFS,
    VBELN TYPE C LENGTH 10,
    PSTYV TYPE C LENGTH 4,
    MATNR TYPE C LENGTH 18,
    J_4KRCAT TYPE C LENGTH 16,
    J_4KSCAT TYPE C LENGTH 16,
    END OF S_AFS.
    DATA: LT_AFS TYPE STANDARD TABLE OF S_AFS,
          LS_AFS TYPE S_AFS.
    DATA: LT_DATA TYPE tyt_SC_1.
    LT_DATA[] = SOURCE_PACKAGE[].
    SORT LT_DATA DESCENDING BY VBELN MATNR J_4KRCAT.
    DELETE ADJACENT DUPLICATES FROM LT_DATA COMPARING VBELN MATNR.
    SELECT VBELN MATNR J_4KRCAT J_4KSCAT
    INTO CORRESPONDING FIELDS OF TABLE LT_AFS
    FROM /BIC/B0000777001
    FOR ALL ENTRIES IN LT_DATA WHERE VBELN = LT_DATA-VBELN AND MATNR =
    LT_DATA-MATNR.
    SORT LT_AFS BY VBELN MATNR.
    I am not an expert in writing ABAP code. Any suggestions are greatly appreciated and points will be assigned. Thank you.

    Hi
    why do want to select the data from PSA table ?Already your trying to load data from PSA to DSO.
    you want to populate the AFS field value in DSO right?
    1. First you have to add AFS field in ur DSO
    2. Write the Start routine based on ur scenario(select the data based on ur scenario and put into internal table).
    3. wirte AFS field leval  transfer routine(Read the corresponding record based on docu num,item num) pass into RESULT.
    Regards,
    GR

  • Performance: reading huge amount of master data in end routine

    In our 7.0 system, each day a full load runs from DSO X to DSO Y in which from six characteristics from DSO X master data is read to about 15 fields in DSO Y contains about 2mln. records, which are all transferred each day. The master data tables all contain between 2mln. and 4mln. records. Before this load starts, DSO Y is emptied. DSO Y is write optimized.
    At first, we designed this with the standard "master data reads", but this resulted in load times of 4 hours, because all master data is read with single lookups. We redesigned and fill all master data attributes in the end routine, after fillilng internal tables with the master data values corresponding to the data package:
    *   Read 0UCPREMISE into temp table
        SELECT ucpremise ucpremisty ucdele_ind
          FROM /BI0/PUCPREMISE
          INTO CORRESPONDING FIELDS OF TABLE lt_0ucpremise
          FOR ALL ENTRIES IN RESULT_PACKAGE
          WHERE ucpremise EQ RESULT_PACKAGE-ucpremise.
    And when we loop over the data package, we write someting like:
        LOOP AT RESULT_PACKAGE ASSIGNING <fs_rp>.
          READ TABLE lt_0ucpremise INTO ls_0ucpremise
            WITH KEY ucpremise = <fs_rp>-ucpremise
            BINARY SEARCH.
          IF sy-subrc EQ 0.
            <fs_rp>-ucpremisty = ls_0ucpremise-ucpremisty.
            <fs_rp>-ucdele_ind = ls_0ucpremise-ucdele_ind.
          ENDIF.
    *all other MD reads
    ENDLOOP.
    So the above statement is repeated for all master data we need to read from. Now this method is quite faster (1,5 hr). But we want to make it faster. We noticed that reading in the master data in the internal tables still takes a long time, and this has to be repeated for each data package. We want to change this. We have now tried a similar method, but now load all master data in internal tables, without filtering on the data package, and we do this only once.
    *   Read 0UCPREMISE into temp table
        SELECT ucpremise ucpremisty ucdele_ind
          FROM /BI0/PUCPREMISE
          INTO CORRESPONDING FIELDS OF TABLE lt_0ucpremise.
    So when the first data package starts, it fills all master data values, which 95% of them we would need anyway. To accomplish that the following data packages can use the same table and don't need to fill them again, we placed the definition of the internal tables in the global part of the end routine. In the global we also write:
    DATA: lv_data_loaded TYPE C LENGTH 1.
    And in the method we write:
    IF lv_data_loaded IS INITIAL.
      lv_0bpartner_loaded = 'X'.
    * load all internal tables
    lv_data_loaded = 'Y'.
    WHILE lv_0bpartner_loaded NE 'Y'.
      Call FUNCTION 'ENQUEUE_SLEEP'
      EXPORTING
         seconds = 1.
    ENDWHILE.
    LOOP AT RESULT_PACKAGE
    * assign all data
    ENDLOOP.
    This makes sure that another data package that already started, "sleeps" until the first data package is done with filling the internal tables.
    Well this all seems to work: it takes now 10 minutes to load everything to DSO Y. But I'm wondering if I'm missing anything. The system seems to work fine loading all these records in internal tables. But any improvements or critic remarks are very welcome.

    This is a great question, and you've clearly done a good job of investigating this, but there are some additional things you should look at and perhaps a few things you have missed.
    Zephania Wilder wrote:
    At first, we designed this with the standard "master data reads", but this resulted in load times of 4 hours, because all master data is read with single lookups.
    This is not accurate. After SP14, BW does a prefetch and buffers the master data values used in the lookup. Note [1092539|https://service.sap.com/sap/support/notes/1092539] discusses this in detail. The important thing, and most likely the reason you are probably seeing individual master data lookups on the DB, is that you must manually maintain the MD_LOOKUP_MAX_BUFFER_SIZE parameter to be larger than the number of lines of master data (from all characteristics used in lookups) that will be read. If you are seeing one select statement per line, then something is going wrong.
    You might want to go back and test with master data lookups using this setting and see how fast it goes. If memory serves, the BW master data lookup uses an approach very similar to your second example (1,5 hrs), though I think that it first loops through the source package and extracts the lists of required master data keys, which is probably faster than your statement "FOR ALL ENTRIES IN RESULT_PACKAGE" if RESULT_PACKAGE contains very many duplicate keys.
    I'm guessing you'll get down to at least the 1,5 hrs that you saw in your second example, but it is possible that it will get down quite a bit further.
    Zephania Wilder wrote:
    This makes sure that another data package that already started, "sleeps" until the first data package is done with filling the internal tables.
    This sleeping approach is not necessary as only one data package will be running at a time in any given process. I believe that the "global" internal table is not be shared between parallel processes, so if your DTP is running with three parallel processes, then this table will just get filled three times. Within a process, all data packages are processed serially, so all you need to do is check whether or not it has already been filled. Or are you are doing something additional to export the filled lookup table into a shared memory location?
    Actually, you have your global data defined with the statement "DATA: lv_data_loaded TYPE C LENGTH 1.". I'm not completely sure, but I don't think that this data will persist from one data package to the next. Data defined in the global section using "DATA" is global to the package start, end, and field routines, but I believe it is discarded between packages. I think you need to use "CLASS-DATA: lv_data_loaded TYPE C LENGTH 1." to get the variables to persist between packages. Have you checked in the debugger that you are really only filling the table once per request and not once per package in your current setup? << This is incorrect - see next posting for correction.
    Otherwise the third approach is fine as long as you are comfortable managing your process memory allocations and you know the maximum size that your master data tables can have. On the other hand, if your master data tables grow regularly, then you are eventually going to run out of memory and start seeing dumps.
    Hopefully that helps out a little bit. This was a great question. If I'm off-base with my assumptions above and you can provide more information, I would be really interested in looking at it further.
    Edited by: Ethan Jewett on Feb 13, 2011 1:47 PM

Maybe you are looking for

  • Automatic creation of Service PO via Service PR

    Dear Friends, We want to create Service PO automatically via service PR generated in PS module using account assignment category Network and service conditions per plant/ POrg/ vendor combination. What are prerequisities and settings required to crea

  • Mac Pro for Video Editing?

    So I have an awesome Mac Pro computer at work all well equiped with all the bells and wistles for video editing and now I'm looking to upgrade my machine at home which is currently just a macbook pro with a second monitor. My one concern is that the

  • Server Package for Mac Mini

    I am looking to purchase a Mac Mini maybe a 2009 model.  I know that the 2009 models support Mavericks.  Instead of buying an actual Mac Mini server with OS server software, I thought of buying a Mac Mini "desktop" model and buying the Server Package

  • Error While recording using Sapgui

    Hi, In eCATT when i'm trying to record using Sapgui after clicking on Start Recording Button, I'm getting an error "A script is trying to attach to GUI".... Could any one give me the solution for this ASAP.

  • RMAN REOPRT NEED BACKUP

    i do not really understand the 'INCREMENTAL' option of "RMAN REOPRT NEED BACKUP" command. like the one below: RMAN> REPORT NEED BACKUP INCREMENTAL 3 DATABASE; Whats the significance of the word 'INCREMENTAL' . I need help please. thank you