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

Similar Messages

  • Create records in start routine - BI 7.0

    Hi SDN,
    we have a special business szenario: we have to create additional data records between DataSource and DSO.
    Our DSO has the key fields DocNo, PosNo and 0Calmonth. In some cases in delta init we have to create additional records.
    I found some intresting threads on SDN how to do that:
    Insert records in DATA_PACKAGE?
    Re: Update Rule - to duplicate records in a data package
    But we are using BI 7.0 and ABAP OO.
    How is it possible to create additional records in start routine using BI 7.0? Have anybody done this and have good hints or examples how to do this?
    I will assign full points for a solution.
    Regards
    Andreas

    Hi,
    @Jialiang.qiu:
    I have tried that... This concept is not working in BI 7.0.
    @vamsi talluri:
    I would like to set in some cases the field AEDAT into VDATU in deltainit. This records I want to append to Source Package.
    This is the code I have tested but unfortunately it dumps...
    DATA : LS_SOURCE_PACKAGE TYPE _TY_S_SC_1,
        P_CALM_AE TYPE  /BI0/OIST_UP_DTE,
        P_CALM_VD TYPE  /BI0/OIST_UP_DTE.
        LOOP AT SOURCE_PACKAGE INTO LS_SOURCE_PACKAGE.
          P_CALM_AE = LS_SOURCE_PACKAGE-AEDAT+4(2).
          P_CALM_VD = LS_SOURCE_PACKAGE-VDATU+4(2).
          IF P_CALM_AE <> P_CALM_VD
            AND NOT LS_SOURCE_PACKAGE-AEDAT IS INITIAL
            AND LS_SOURCE_PACKAGE-ABSTA = 'C'.
            LS_SOURCE_PACKAGE-VDATU = LS_SOURCE_PACKAGE-AEDAT.
          ENDIF.
          APPEND LS_SOURCE_PACKAGE TO SOURCE_PACKAGE.
        ENDLOOP.
    Regards
    Andreas

  • 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

  • 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

  • ABAP HELP in Start routine

    Hello everybody,
    I have written a code to delete some records in start routine, we are using BI 7.0.
    here is the code,
    TYPES: BEGIN OF tys_SC_3,
    TCTUSERNM TYPE /BI0/OITCTUSERNM,
    END  OF tys_SC_3.
    DATA zz_s_SC_3 type sorted table of tys_SC_3 with unique key TCTUSERNM.
    DATA zz_s_SC_4 like line of zz_s_SC_3.
    select TCTUSERNM from /B12/ARIAO0100 into table zz_s_SC_3
    where TCTIOBJNM = '0TCAIPROV' and TCTLOW = '/MRG/RIMAC_01'.
    DELETE SOURCE_PACKAGE where TCTUSERNM NOT IN zz_s_SC_3.
    When I am running this code,I am getting an error
    "E:"ZZ_S_SC_3" does not have the structure of a selection table."
    can anybody out there help me out,
    Thank you,
    Karthik

    Hi,
    you need to define zz_s_SC_3 as:
    data: zz_s_SC_3 type standard table of rsrange.
    do the select as:
    select TCTUSERNM as low from /B12/ARIAO0100 into table zz_s_SC_3
    modify zz_s_sc_3 to set the fields sign and option to 'I' and 'EQ' for all records then it will work.
    Siggi

  • 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.

  • 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 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.

  • Filtering records using a start routine inside the update rules for a dmart

    Hi
    I am using a start routine inside the update rules. I want to filter out all records that have 0 in all three fields. My problem is that it not only filters these records, but also filter records with negative values, which I do not want. Only 1 field has a negative value, the other 2 have 0.
    I have tried:
    DELETE DATA_PACKAGE where  /BIC/ZBILLCONS = 0 and /BIC/ZBREVPRIM = 0  and /BIC/ZBREVSUBO = 0 .
      DELETE DATA_PACKAGE where ( /BIC/ZBILLCONS = 0 and /BIC/ZBREVPRIM = 0  and /BIC/ZBREVSUBO = 0 ).
    also tried:
    delete DATA_PACKAGE where /BIC/ZBILLCONS IS INITIAL and
    /BIC/ZBREVPRIM IS INITIAL and  /BIC/ZBREVSUBO IS INITIAL.
    The records are going to 1 cube and 1 ODS, I only have the start routine in 1 update rule. I  view the filtering in the PSA.
    Has anyone ran into this before?

    Try
    delete data_package where /BIC/ZBILLCONS = '0' and /BIC/ZBREVPRIM = '0' and /BIC/ZBREVSUBO = '0' .
    OR
    delete data_package where /BIC/ZBILLCONS EQ '0' and /BIC/ZBREVPRIM EQ '0' and /BIC/ZBREVSUBO EQ '0' .
    Good luck!

  • 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 to filter the duplicate records

    Dear Experts
    I have two questions regarding the start routine.
    1) I have a characteristic InfoObject with transactional InfoSource. Often the 'duplicate records' error happens during the data loading. I'm trying to put a start routine in the update rule to filter out the duplicate records. 
    After searching the SDN forum and SAPHelp, I use the code as:
    DELETE ADJACENT DUPLICATES FROM DATA_PACKAGE COMPARING KEY1 KEY2 KEY3.
    In my case, the InfoObject has 3 keys: SOURSYSTEM, /BIC/InfoObjectname, OBJVERS. My code is:
    DELETE ADJACENT DUPLICATES FROM DATA_PACKAGE COMPARING SOURSYSTEM /BIC/InfoObjectname OBJVERS.
    When checking the code I got message: 'E:No component exists with the name "OBJVERS".' So I only included the first 2 keys. But the routine does not work. The duplicate error is still happening. What is missing in this start routine?
    2) Generally, for a start routine, do I really need to include the data declaration, ITAB or WA, SELECT statement etc.?
    Do I have to use the statement below or just simply one line?
    LOOP AT DATA_PACKAGE.
    IF DATA_PACKAGE.....
    ENDIF.
    ENDLOOP.
    Thanks for your help in advance, Jessica

    Hello Jessica,
    if it won't be possible for you to get unique data from the very beginning, there is still another way to manage this problem in a start routine.
    Sort ... and delete adjacent ... must remain. Further on build up an internal table of type data_package, but defined with STATICS instead of DATA. This i-tab stays alive for all data-packages of one load. Fill it with the data of the transferred data-packages, and delete from every new data-package all records which already are in the statics i-tab. Alternatively you could do the same with a Z-(or Y-)database-table instead of the statics i-tab.
    It will probably cost some performance, but better slow than wrong data.
    Regards,
    Ernst

  • Start routine and record aggregates

    Hy expert's, i have this question:
    The source of my transformation consist of these fields:
    DM    IS    DATETO_IS    DATEFROM_IS.
    All these fields are char (8) (also the field date).
    The source of  transformation can consist of this record:
    DM | IS | DATETO_IS | DATEFROM_IS
    A1  | C1| 99991231    | 20090101 
    A1  | C1| 31122008    | 20080101
    So, i would that the start routine response with a unique record as:
    DM | IS | DATETO_IS | DATEFROM_IS
    A1  | C1| 99991231    | 20080101 
    Could you help me?
    Thank's a lot.
    Sincerely yours
    Andrea M.

    Here's some sample code that may help you:
    Global Desclarations
    DATA: t_source_package TYPE _ty_t_sc_1.
    Routine
    IF NOT source_package[] IS INITIAL.
      t_source_package[] = source_package[].
      SORT
        source_package
      BY
        dateto_is
      DESCENDING.
      DELETE
        ADJACENT DUPLICATES
      FROM
        source_package.
      SORT
        t_source_package
      BY
        datefrom_is
      ASCENDING.
      DELETE
        ADJACENT DUPLICATES
      FROM
        t_source_package.
    ENDIF.
    LOOP AT source_package
      ASSIGNING >source_fields>.
      READ TABLE
        l_source_package
      WITH KEY
        dm
        is.
      IF sy-subrc EQ 0.
        <source_fields>-datafrom_is = t_source_package-datafrom_is.
      ENDIF.
    ENDLOOP.
    This will not help you however if there's a possiblity where the minimum of DATAFROM_IS is in one Data Package and the maximum of DATATO_IS is in a different Data Package.

  • 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 for restricing the data records from ODS1 - ODS2

    Hi
    I need small ABAP Code in Start Routine Of Update rules Of ODS . Im in BW 3.5 .
    I have records like below in first layer ODS and i want to restrict some records while going to second layer ODS ..
    ODS1 :-
    DocNO   EventType    Date
    123         001             08/08/2008
    123         003             08/08/2008
    123         011              09/08/2008
    I want one record in ODS2 for this document number whose EventType = 001 only and date of third record ... like below
    Doc NO     EventType      From Date          Todate
    123              001               08/08/2008         09/08/2008
    So how can i get like this record in the ODS2 which will get data from ODS1 . So i need to write the code in the start routine of the ODS2 .
    So please give the me the code for start routine ....
    Regards
    Suresh

    Its difficult in BW 3.5 to include this logic in START_ROUTINE as you cannot add the extra to_date field to the DATA_PACKAGE table.
    You need to create a new global internal table with the same structure of DATA_PACKAGE with additional field to_date. then use the logic to fill in the global internal table
    define a internal table new_data_package with the required structure like (docno, eventtype, fromdate todate)
    data: l_w_datapkg_001 type data_package,
    data: l_w_newdatapkg type new_data_package,
    data: l_w_datapkg_011 type data_package
    LOOP AT DATA_PACKAGE INTO l_w_datapkg_001 WHERE event_type = '001'.
    l_w_newdatapkg-docno = l_w_datapkg_001-docno.
    l_w_newdatapkg-event_type = l_w_datapkg_001-event_type.
    l_w_newdatapkg-fromdate = l_w_datapkg_001-date.
    MOVE CORRESPONDING FIELDS OF l_w_datapkg_001 INTO l_w_newdatapkg.
    READ TABLE data_package INTO l_w_datapkg_011
    WITH KEY docno = l_w_datapkg_001-docno
                     event_type = '011'.
    l_w_newdatapkg-to_date = l_w_datapkg_011-date.
    APPEND l_w_newdatapkg TO new_data_package          
    ENDLOOP.
    Now the new datapackage contains the ODS2 data that u needed

  • 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.

Maybe you are looking for

  • Database connection questions

    <p>Hello,</p><p>1) Whenever I use a JDBC connection in my report, viewing that report (outside of preview) always prompts me with a database logon prompt.   How do I get rid of this?</p><p> </p><p>2) I would like to use JNDI for my db datasource at r

  • Create sales order with reference to archived billing

    Hello, Is it possible to create sales order with reference to archived billing? Thanks in advance and kind regards

  • Core Interface: Planned Order Integration

    Hi We are planning a product in both systems (ECC & APO). We want to restrict the Planned Order Integration b/w ECC & APO which are generating in ECC. At a same time we want a Planned order integration which are generating in  APO. Is there any stand

  • Why do I get question marks on iphoto instead of the photos?

    Why do I get question marks on iphoto instead of the photos?

  • Unable to 'Upload to FTP Host' in Muse CC 2014

    I have a client that wants to use GoDaddy for their server. I have all the correct user names/ passwords and if I keep tapping "try again" I will eventually get the following screen: After I hit "Resume" 5-6 times, the upload will advance: and eventu