Delete Datapackage in start routine

hello Gurus
I need to load data for 204 and 205 costcenters but i need to delete records in between costelements 611000 - 613999.
so i have writen the code . plz suggest the corrections in the code.
data: lt_dp type standard table of data_package_structure,
wa_dp type data_package_structure.
LOOP AT DATA_PACKAGE.
Move-Corresponding DATA_PACKAGE to wa_dp.
Append wa_dp to lt_dp.
endloop.
case DATA_PACKAGE-COSTCENTER.
when'0000000204'.
Delete lt_dp where COSTELMNT GE '0000611000' and COSTELMNT LE
'0000613999'.
when'0000000205'.
Delete lt_dp where COSTELMNT GE '0000611000' and COSTELMNT LE
'0000613999'.
when'0000000206'.
Delete lt_dp where COSTELMNT GE '0000611000' and COSTELMNT LE
'0000613999'.
when'0000000217'.
Delete lt_dp where COSTELMNT GE '0000611000' and COSTELMNT LE
'0000613999'.
DATA_PACKAGE[] = lt_dp[].
endcase.

You can follow one of the following approach. :
1) delete DATA_PACKAGE where  COSTCENTER = 0000000204 and
COSTELMNT between  '0000611000' and '0000613999' .
2)
loop at data_package where COSTCENTER = 0000000204  or COSTCENTER = 0000000205 or COSTCENTER =  0000000205 or COSTCENTER =  0000000217.
IF   COSTELMNT GE '0000611000'    and COSTELMNT LE
'0000613999'.
delete data_package index sy-tabix.
endif
endloop.
Regards,
Abhishek

Similar Messages

  • Deleting records in start routine

    Dear Experts,
    We have infoObject ZCADRE which stotes list of all trainees. Cube ZCUBE_01 contains transactional data
    of all the employees. Now, there is a transformation between cube ZCUBE_01 and cube ZCUBE_02.
    Requirement is cube ZCUBE_C02 will be loaded with transactional data of only those employees who are
    present in infoobject ZCADRE.
    So, basically we need to write codes for selective deletion in the start routine.
    ZCADRE has following records:-
    ZCADRE     BATCH
    ======     =====
    1111       2005
    2222       2008
    3333       2007
    ZCUBE_01 has following records:-
    employee     actiontype     calday          actcnt
    1111          Z1          01.03.2011     1
    2222          Z1          01.04.2011     1
    3333          Z2          01.06.2011     1
    4444          Z3          01.02.2011     1
    5555          Z1          01.04.2011     1
    6666          Z2          01.03.2011     1     
    After the data loading from cube ZCUBE_01 to ZCUBE_02, ZCUBE_02 should have the following records:-
    employee     actiontype     calday          actcnt
    1111          Z1          01.03.2011     1
    2222          Z1          01.04.2011     1
    3333          Z2          01.06.2011     1               
    Please suggest codes for the same.
    Your help will be appreciated.
    Regards,
    Prakash

    Thanks Rahul, for your quick response. The logic for codes that you have suggested is giving following error:-
    E:In the OO context either an INTO or an ASSIGNING specification or the
    addition "TRANSPORTING NO FIELDS" must be used. addition "TRANSPORTING
    NO FIELDS" must be used.  and "  E:Tables with headers are no longer supported in the OO context.
    I was using following codes:-
    =============================================================================
    DATA: wa_zcadre TYPE standard table of /bic/pzcadre with header line, idx type sy-tabix.
    SELECT * FROM /bic/pzcadre INTO table wa_zcadre.
    sort wa_zcadre by zcadre.
    LOOP AT SOURCE_PACKAGE.
    idx = sy-tabix.
    read table wa_zcadre with key zcadre = SOURCE_PACKAGE-employee binary search.
    if sy-subrc <> 0.
    DELETE SOURCE_PACKAGE index idx.
    ENDIF.
    ENDLOOP.
    ===============================================================================================
    Following codes solved my problem:-
    ===============================================================================================
    DATA: idx type sy-tabix.
    DATA: wa_source_package type tys_sc_1.
    DATA: ZCADRE TYPE /BIC/PZCADRE-/BIC/ZCADRE.
    LOOP AT SOURCE_PACKAGE into wa_SOURCE_PACKAGE.
    CLEAR : ZCADRE.
    SELECT SINGLE /BIC/ZCADRE FROM /BIC/PZCADRE INTO ZCADRE WHERE
      /BIC/ZCADRE = WA_SOURCE_PACKAGE-EMPLOYEE.
    idx = sy-tabix.
    if sy-subrc <> 0.
    DELETE SOURCE_PACKAGE index idx.
    endif
    ENDLOOP.
    ===========================================================================================
    Regards,
    Prakash

  • Need Start routine logic

    Hi,
    Can anyone please let me know the code in start routine for the below.
    I want to delete the unwanted datapackage in start routine for the below condition.
    For  system PCR
    For purch.org Z300, only those purchase orders shall be loaded to further layers which have the text "FCM" in the field Incoterms2 (ZPURINC2), the other purchase orders of this purch org and this system can be deleted.
    thankyou........
    Regards...
    Balaji

    Hi,
    Delete Source_package where SYSTEM = 'PCR' and PURCH.ORG = 'Z300' and ZPURINC2 NE 'FCM'.
    Check the definition of source_package in the start routine screen and use the exact infoobjects while defining the Delete statement
    Regards
    Githen

  • Deleting  rows with missing values in field in start routine of update rule

    Hello experts,
    how can I delet rows with missing values in a specific field in the start routine of update rules?
    I think ABAP code should look something like this:
    delete ...  from DATA_PACKAGE where Z_NO = ''.
    thanks in advance for any suggestions!
    hiza

    Write:
    delete data_package where field = value.
    Hope it helps.
    Regards

  • ABAP code in start routine (delete no in)

    In my start routine, I would like to delete some data package whose employee id is not in the selection list.
    but there are some ABAP grammer error in the where condition. Can somebody help this? I tried to read the document for 'WHERE - IN seltab', but still I could not give the right code.
    <p>
      employeeid_itab type table of string.
      select /bic/zpe_employeeid into table employeeid_itab from /bic/pzpe_employeeid.
      DELETE SOURCE_PACKAGE where ZEMP_employee_ID NOT IN employeeid_itab.
    It seems that internal table employeeid_itab could not be directly used after the IN keyword.
    how can I do this?
    Edited by: Ben Li on Feb 22, 2008 2:09 PM

    Hi Oscar,
          Actually I had tried this before, using the code like the following,
          <p>
    Types: EmployeeID(7) type  c.
    <p>
    data: sel_itab type  range of EmployeeID.
    <p>
    select /bic/zpe_employeeid into table sel_itab from /bic/pzpe_employeeid.
    <p>
    delete SOURCE_PACKAGE where zemp_employee_id  not in sel_itab.
    <p>
         The grammer check is OK, but when I debug it, I found that there are records in sel_itab, but all the records just have one charactor, actually, my employeeID have 7 charactors in database. So it does not work, I think I miss something in define  of the range table. Can you please figure out? Thanks a lot.

  • Start Routine logic to delete records which do not satisfy a condition

    Hello,
    Iam trying to code a start routine to delete the records from the source_package if a certain set of conditions are not met.
    It is failing at the last statement.
    Pls help.
    Thanks
    Jagadish
    code is as follows..
    LOOP AT SOURCE_PACKAGE assigning <SOURCE_FIELDS>.
    IF not (
    ( <SOURCE_FIELDS>-/BIC/ZCLSD_DT BETWEEN <SOURCE_FIELDS>-/BIC/ZWEEKOF
    AND <SOURCE_FIELDS>-/BIC/ZNONWKOF )
      AND
      ( <SOURCE_FIELDS>-/BIC/ZCLSD_DT IS  INITIAL )
    DELETE SOURCE_PACKAGE FROM <SOURCE_FIELDS>.
    (is failing at the delete statement.)
    ENDIF.
    ENDLOOP.

    Thanks Pratap,
    I used an internal table to load the records and used a delete statement out side the LOOP.
    By using a Work Area assignment instead of the Source_fields, The delete statement is giving me an error saying "Conversion of Numeric Value to type Object is not valid".
    Here is the code I have modified...
       TYPES: BEGIN OF LINE,
                WO(6) type c,
              END OF LINE.
       DATA: WA TYPE LINE,
             ITAB TYPE TABLE OF LINE.
    LOOP AT SOURCE_PACKAGE assigning <SOURCE_FIELDS>.
    IF NOT (
    ( <SOURCE_FIELDS>-/BIC/ZCLSD_DT BETWEEN <SOURCE_FIELDS>-/BIC/ZWEEKOF
        AND <SOURCE_FIELDS>-/BIC/ZNONWKOF
      AND
      <SOURCE_FIELDS>-/BIC/ZAPRD_DT IS NOT initial )
    Append <SOURCE_FIELDS>-/BIC/ZWO_NBR to itab.
    ENDIF.
    ENDLOOP.
    loop at itab into WA.
    DELETE SOURCE_PACKAGE where /bic/ZWO_NBR = WA-wo.
    endloop.

  • BI 7 Delete in Start routine

    Hi,
    I want to write start routine in BI 7 transformation to delete records.
    Can somobody please tell me eaxct command to delete records.
    Thanks
    Shilpa

    Hi
    go to start routine and write in the global area
    delete data_package where field name equal to (=,eq) or not equal to (ne) value.
    lets say field name is X and value ab.and i want to delte records where x = ab
    then the delete statement will be
    delete data_package where x = 'ab'.
    but if asked to delte x = ab, zb,cv and so on
    delete data_package where x = 'ab',
                        and   x = 'zb',
                        and   x = 'cv'.  
    only if the value is alphanumeric or jst alphabets it comes betwnn single quotes ' '.
    else if its number value it comes directly widut single quotes
    equal to can be wrten in two ways = and eq and
    not equal is ne.
    there will be a fullstop at the end of the delete statement
    hope it helps asign points if aplicable
    thanks
    puneet
    Message was edited by:
            Puneet Chawla

  • Start routine: DELETE VARIABLE DOES NOT EXIST

    Dear Friends,
    I have written the below code in the start routine.
    LOOP AT DATA_PACKAGE.
    IF DATA_PACKAGE-/BIC/ZSREGIO <> AMR.
    DELETE DATA_PACKAGE.
    ENDIF.
    ENDLOOP.
    when i check for syntax errors, it gives message Delete variable does not exist.
    Need your earliest help.
    Kind Regards
    Paddy

    hi Paddy,
    seems we forget quote
    DELETE DATA_PACKAGE WHERE /BIC/ZSREGIO <> 'AMR'.
    where did you put the code ?
    there is 'insert your code here ...', put your code after that line.
    if you are using BI 7.0, use source_package :
          MONITOR_REC     TYPE rstmonitor.
    $$ begin of routine - insert your code only below this line        -
    ... "insert your code here
    DELETE SOURCE_PACKAGE WHERE /BIC/ZSREGIO <> 'AMR'.
    hope this helps.

  • How-to retrieve deleted start routine

    Hi!
    I have written a start routine in an update rule for a data mart. This update rule was overwritten while the export data source of the related info cube was created again (during this the system automatically creates and activates a new update rule). My start routine within this update rule is lost.
    Since this was happening in the development system I found the name (D8FOPYTRYTBF836EXIMLM2MGA) of the routine in the related transport order.
    Does anyone know how to show this routine/object/program in an editor or how to rescue the code of the routine? Is there a possibility by any means (SE38 dont work)?
    Any help highly appreciated and rewarded.
    Best Regards,
    Volker

    try to search in  RSAABAP , RSAROUT and RSUPDROUT tables..
    If you don't find.. you can transport that request to quality system(retrive the code and delete this request from transport buffer.. no need to transport prod!) and again create another request with new changes and transport to Q and then to Prod

  • Start routine code for deleting records in different language

    Hello,
    can someone please specify the exact code to be used in start routine, and whre exactly it needs to be pasted?
    this code is needed for master data notifaction type which is loaded for both languages German and English.
    german records are to be avoided.
    thanks,

    Ciao Claudio,
    this issue about languages selection is an old situation...
    The problem is that language selection is not possible, even if you have this field checked for selection !!!
    Look at OSS Note 324684...
    "If a field of a DataSource - typically with field name 'LANGU' or 'SPRAS' - is assigned to InfoObject '0langu', the field is not provided in the selection fields although the field actually can be selected. In this case, all languages of the language vector active in the BW System are requested by the source system but the language selection cannot be defined in the Scheduler.
    A precondition is that the language field of the DataSource in the source system is maintained as selection field. This setting is done in Transaction RSA6 (or RSO2 for customer developments)."
    Bye,
    Roberto

  • ABAP assistance - start routine logic in update rule

    I have used an existing update rule and have based my logic around the same.  The purpose of the rule is to look up customer master data and get a subset of customer numbers from the transaction records so that the values for customer number from the transactional data will not be updated if it does not match with existing master data customer numbers.
    The loads are full and we drop the data before we load.
    I have listed the logic below (the number at the front is to be considered as the line number) and a list of open questions that I have thereafter:
    Start routine logic:
    1  DATA: l_index LIKE sy-tabix.
    2  DATA: BEGIN OF ls_customer,
    3        customer TYPE /BI0/OICUSTOMER,
    4        objver TYPE RSOBJVERS,
    5     END OF ls_customer,
    6      lt_customer LIKE TABLE OF ls_customer.
    7  REFRESH: lt_customer.
    8  LOOP AT DATA_PACKAGE.
    all customers from data package
    9    ls_customer-custno = DATA_PACKAGE-custid.
    10  ls_customer-objver = 'A'
    11    APPEND ls_customer TO lt_customer.
    12   ENDLOOP.
    12  SORT lt_customer.
    13  DELETE ADJACENT DUPLICATES FROM lt_customer.
    14   IF NOT lt_customer[] IS INITIAL.
    15    SELECT /BI0/OICUSTOMER RSOBJVERS
    16      FROM /BI0/PCUSTOMER
    17      INTO CORRESPONDING FIELDS OF TABLE lt_customer
    18      FOR ALL ENTRIES IN lt_customer
    19      WHERE ls_customer-custno = DATA_PACKAGE-custid
    20      AND ls_customer-objver = 'A'
    21    SORT lt_customer BY customer ASCENDING                    
    22  ENDIF.
    Questions
    Line
    1 - what is the purpose of this line? What is it that is being declared
    2 - in some code I have seen this line with OCCURS 0 at the end what does this mean with and without the term?
    4 - I am using the Data Element name is this correct or should I use the field name?
    3 - 5 here I declare an internal structure/table is that correct?
    6 - here I declare a work area based on the internal table is that correct?
    7 - What would happen if I avoided using the REFRESH statement?
    8 - 12 - Is this syntactically correct, I am trying to get a set of data which is the customer numbers which match the master data customers and the master data record is án active version and than appendíng to the work area?
    13 - My understanding is this will reduce the number of records in the work area is this correct and needed?
    14 - 22 I am trying to identify my required set of data but feel I am repeating myself, could someone advise?
    Finally what logic would I actually need to write in the key figure object, could I use something like:
    Result = lt_customer.
    Thanks
    Edited by: Niten Shah on Jun 30, 2008 8:06 PM

    1. This line is not required
    2. OCCURS 0 is the OLD way of defining an internal table with that structure.  As it is, it just defines a flat structure.
    3. Data element is usually best
    3-5 Yes
    6. No.  Here you are declaring a table of the type of the flat structure.  Just as the ABAP says!
    7. Nothing.  But by putting this in, you ensure that you know the state of the table (empty) before you start looping through the data package
    8-12. You can tell if it is syntactically correct by pressing Ctrl-F2 when in the editor.  Looks ok.
    13. Ensures your list of customers contains no duplicated.  The code up to this point is building a list of all the unique customers in the data package.
    14-22. Goes to the database and brings back ONLY those customers which are found in the master data.  Looks ok.
    This is a start routine (that's why you've got a data package).  You don't use result.  You should update the datapackage.  But this you haven't done.  Double click on the table name /BIC/PCUSTOMER to get the correct field names.
    So you have to loop through the data package again, and check if the customer in the datapackage is lt_customer.  If it is, fine, otherwise you blank it and report an error, or set an error message or whatever.
    I wouldn't do it like this.  I'd do something like this:
    STATICS: st_customer TYPE HASHED TABLE OF TYPE /bi0/oicustomer
                                  WITH UNIQUE KEY TABLE_LINE.
    * st_customer retains its value between calls, so only populate if empty
    * In one run of the infopackage, this will mean you do only one read of
    * the master data, so very efficient.
    IF st_customer IS INITIAL.
      SELECT customer FROM /BI0/PCUSTOMER
                              INTO TABLE st_customer
                              WHERE objvers EQ 'A'. " Only active values
    ENDIF.
    * Go through data package
    LOOP AT DATA_PACKAGE.
    * Check whether the customer exists.
      READ TABLE st_customer TRANSPORTING NO FIELDS
                  WITH TABLE KEY table_line = DATA_PACKAGE-custid.
      CHECK sy-subrc IS NOT INITIAL.
    * If you get here, the customer isn't valid.  So I'm just setting it blank
      CLEAR DATA_PACKAGE-custid.
      MODIFY DATA_PACKAGE. " Updates the datapackage record
    ENDLOOP.
    Even this is not fully optimised, but it's not bad.
    I strongly suggest that you get yourself sent on the basic ABAP programming course if you're going to do a lot of this.  Otherwise, read the ABAP documentation in the help.sap.com, and, from the editor, get the cursor on each ABAP keyword and press F1 to read the ABAP help.
    matt

  • Can any one explain me abt start routine and transfer routine with example?

    Hi all,
    Can anyone explaing me the use of start routine and update routines with an real time example.
    regds
    hari

    Hi
    Start routine is at a datapackage level and u generally use select statement and delete state ment
    transfer routine is at a data source level.
    for ex i have an 3 ODS (X,Y,Z) and one DS D and one Infosoure I and a cube C
    flow is DS -
    >IS-->ODS's(X,Y,Z)---> and cube C from ODS X, ODS Y,ODS Z
    Transfer Routine:If u write any routine in IS it will be applicable to all the the ODS's when u load data becuase it is at the DS level
    start routine: now if u write a start routine betwn ODS X and  a cube it will be applicable only for the Update rule betwn ODS X and a cube it wont affect the Update rules betwn OD Y and cube or ODS Z and the cube becuase start routine is at a datapackage level
    Transfer routine is in the IS
    hope this is helpful asssingn points if applicable
    thanks
    puneet

  • How to determine InfoCube name within the update rule start routine?

    We are attempting to delete all the records where all key figure values are zeroes. We have about 15% of such records and we really don't need them.
    We have yearly InfoCubes. We copy the InfoCube and update rules at the end of every year. So, we don't want to hard code any field names within the update rules.
    If I could determine the target InfoCube name within the update rule start routine, I can find out all the key figures dynamically. But, I don't see a way of finding out the InfoCube name.
    If you would share any ideas, I would really appreciate.
    Thanks.
    Sudhi Karkada.

    Hi Sudhi,
    I dont know if this is what you are looking for.
    if you want to delete a record from being inserted when all the Key figure values are ZERO then you can use a Update Routine for some characteristic in the below way
    If looking for the InfoCube:
    if COMM_STRUCTURE-KF1 = 0 and COMM_STRUCTURE-KF2 AND....
      RETURNCODE = 4.
    else
      RESULT = COMM_STRUCTURE-ChanracteristicObject.
    endif.
    If it is to an ODS / InfoCube in the start routine.
      DELETE DATAPACKAGE where KF1=0 and kf2=0 and .....
    Hope it helps.
    Regards,
    Praveen.
    ENDLOOP.
    Message was edited by: Praveen

  • How do you identify the Logical system in start routine of a transformation

    My scenario is this.  I have five r3 systems that I am extracting from.   In the start routine of the transformation from the r3 data source to my data store I  am going to delete data and I need to know the source system id.    How do I identify the logical system or source system id in the transformation.  Is there a system field that contains this information.    I do not want to hard code the source system id in the routine.

    hi
    have a lool at tables rsreqdone and rsbkrequest with a join you should be able to determine the source.
    regards
    Boujema
    How to give points: Mark your thread as a question while creating it. In the answers you get, you can assign the points by clicking on the stars to the left. You also get a point yourself for rewarding (one per thread).
    Edited by: Boujema Bouhazama on May 9, 2008 12:04 AM

  • 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

Maybe you are looking for