ABAP for removing records in update rule

hello all,
we have data loading to several infocubes based on sales order type (logical partition).  our entire business and reporting strategy for sales is based on order type.  we have 1 extractor loading these 5 cubes.  we want to code in the update rule to check for each cube a particular value, and if its not this value, remove the record.
example would be loading order type cube zpt1 we want to check the records coming into this cube that the value for characteristic ziden = z1.  if not, remove the record and do not update the cube.  the other cubes are the same.  cube zpt2 checks if characteristic ziden = z2.  if not, remove all other records.
can someone inform us how this coding would look like in the update rules?
thanks so much

I'm assuming you need code for BW 3.x, since you mentioned Update Rules. There are a couple of ways:
DELETE
  data_package
WHERE
  /bic/ziden NE 'Z2'.
Or
LOOP AT data_package.
  IF data_package-/bic/ziden NE 'Z2'.
    DELETE data_package.
  ENDIF.
ENDLOOP.
If you're on BI 7, then you can create a filter on the DTP to the target so that it only extracts the records needed from the source.
Edited by: Dennis Scoville on Aug 19, 2009 1:59 PM

Similar Messages

  • Removing dashes '-' in update rules

    Hi all,
    I am looking for the simplest way to remove dashes in update rule.
    Data comes 123-45-678
    Format we need 12345678
    I'd appreciate any recommendations.
    PS: We'd rather not to add '-' to invalid characters list
    Mike

    Hi,
    You can try..
    REPLACE ALL ALL OCCURRENCES OF '-'  in COMM_STRUCTURE-'IO'  WITH  ' '.
    CONDENSE  COMM_STRUCTURE-'IO' NO-GAPS.
    or You can use FM  - SF_SPECIALCHAR_DELETE.

  • Puzzle why query returned wrong value for last record in update.

    Hi all,
    10.2.0.4, Windows 32 bit.
    Apply 15% dis.count to related 5 items ( total amount 522 ) sorted by lowest amount first (amount = 1).
    Last record ( amount = 200 ) will be the total dis.count amount ( 78.3 ) less applied accumulated dis.count amount ( 48.50 ).
    Query runs fine without update clause but wrong result for last record with update.
    CREATE TABLE "T1"
        "ID"       NUMBER NOT NULL ENABLE,
        "ITEM_ID"  VARCHAR2(20 BYTE) NOT NULL ENABLE,
        "AMOUNT"   NUMBER(10,2) NOT NULL ENABLE,
        "dizcount" NUMBER(10,2)
    INSERT INTO T1 ( ID, ITEM_ID, AMOUNT, dizcount )  VALUES ( 65, '101', 1, NULL ) ;
    INSERT INTO T1 ( ID, ITEM_ID, AMOUNT, dizcount )  VALUES ( 65, '102', 1, NULL ) ;
    INSERT INTO T1 ( ID, ITEM_ID, AMOUNT, dizcount )  VALUES ( 65, '201', 200, NULL ) ;
    INSERT INTO T1 ( ID, ITEM_ID, AMOUNT, dizcount )  VALUES ( 65, '215', 155, NULL ) ;
    INSERT INTO T1 ( ID, ITEM_ID, AMOUNT, dizcount )  VALUES ( 65, '111', 165, NULL ) ;
    UPDATE t1 a
    SET a.dizcount =
      (SELECT
        CASE
          WHEN rec_count = row_count
          THEN (78.3 - NVL(lag(temp_total,1) over ( order by rec_count) ,0))-- 78.3 is total dizcount amount from 522 * .15
          ELSE disc_amt
        END amt
      FROM
        (SELECT id,
          item_id,
          disc_amt,
          rec_count,
          row_count,
          CASE
            WHEN rec_count != row_count -- accumulate dizcount amount except for last record
            THEN SUM(disc_amt) over (order by rec_count)
            ELSE 0
          END temp_total
        FROM
          (SELECT ID ,
            item_id,
            amount amt,
            ROUND(amount * .15,1) disc_amt, -- dizcount is 15%
            row_number () over (order by amount) rec_count,
            COUNT ( *) over () row_count
          FROM t1
          WHERE ID = 65
        GROUP BY id,
          item_id,
          disc_amt,
          rec_count,
          row_count
        )b
      WHERE a.item_id = b.item_id
      );Regards
    Zack
    Edited by: Zack.L on Jul 26, 2010 1:26 AM

    Zack.L wrote:
    Query runs fine without update clause but wrong result for last record with update.Not sure why but looks like another case in favour of MERGE.
    MERGE INTO T1
    using (SELECT id, item_id,
        CASE
          WHEN rec_count = row_count
          THEN (78.3 - NVL(lag(temp_total,1) over ( order by rec_count) ,0))-- 78.3 is total dizcount amount from 522 * .15
          ELSE disc_amt
        END amt
      FROM
        (SELECT id,
          item_id,
          disc_amt,
          rec_count,
          row_count,
          CASE
            WHEN rec_count != row_count -- accumulate dizcount amount except for last record
            THEN SUM(disc_amt) over (order by rec_count)
            ELSE 0
          END temp_total
        FROM
          (SELECT ID ,
            item_id,
            amount amt,
            ROUND(amount * .15,1) disc_amt, -- dizcount is 15%
            row_number () over (order by amount) rec_count,
            COUNT ( *) over () row_count
          FROM t1
          WHERE ID = 65
        GROUP BY id,
          item_id,
          disc_amt,
          rec_count,
          row_count
        ))b
    on (t1.id = b.id and t1.item_id = b.item_id)
    when matched then update set dizcount = b.amt ;This worked for me. I tested on 11.2 but should work on 10.2.0.4
    SQL> select * from t1 order by amount ;
            ID ITEM_ID                  AMOUNT   DIZCOUNT
            65 101                           1         .2
            65 102                           1         .2
            65 215                         155       23.3
            65 111                         165       24.8
            65 201                         200       29.8p.s. BTW, not sure if you want the column names in different cases, but your script, as it is, gave me an error (on 11.2)

  • ABAP Program to delete the update rules

    Hi guys,
            Is there any ABAP Program to delete the update rules if any body knows.

    Hi dear,
    try with FM RSAU_UPDR_DELETE...
    Hope it helps!
    Bye,
    Roberto
    ...and please dont forget to reward the answers...it-s THE way to say thanks here !

  • Split one record into multiple records in Update Rules

    Hello All,
    I am trying to split a single record from R/3 into 2 records.
    My data flow is form R/3 > PSA > ODS > Cube
    when loading data into ODS i have to add the original record as it is to ODS. For second record i have to check a condition, & change few keyfigure values to 0 and fill an extra field.
    Example:
    Record in R/3 :
    Month | %1 | %2 | %3 | % 4 | ORGUNIT | JOB| EMPLOYEE| POSITION|
    02.2006 | 0 | 1 | 0 | 0 | 3000000| 248 | 2546352 | 500000 |
    Record in BW Comm_Structure.
    In Transfer rules i m writing an extra field to the R/3 record.
    Month | %1 | %2 | %3 | % 4 | ORGUNIT | JOB| EMPLOYEE| POSITION| NEW_FIELD |
    02.2006 | 0 | 1 | 0 | 0 | 3000000| 248 | 2546352 | 500000 | 2546352 |
    NEW_FIELD transfer routine :
    If employee NE 0
    Result  =  employee
    else.
    Result = 0 .
    Till this point everything works fine.
    Now i want to load this record into an ODS. I want to split the above single record into 2 records.
    Records in ODS should be :
    Month | %1 | %2 | %3 | % 4 | ORGUNIT | JOB| EMPLOYEE| POSITION| NEW_FIELD |
    02.2006 | 0 | 1 | 0 | 0 | 3000000| 248 | 2546352 | 500000 |  0 |
    02.2006 | 0 | 0 | 0 | 0 | 3000000| 248 | 2546352 | 500000 |  2546352 |
    Condition for NEW_FIELD.
    For first record always NEW_FIELD =0.
    For Second Record
    If NEW_FIELD NE 0.
    Cahnge KF's  %1, %2, %3, %4 = 0.
    If EMPLOYEE is 0 then no need to create extra record.
    I tried to use achieve this using return table, but no success.
    Can any one help me with ABAP syntax please. I am bit weak in ABAP Programming.
    Thanks in advance.
    POPS

    Dear:
    You could do so in update routines. Select the 'return table' option.
    useful links:
    https://forums.sdn.sap.com/click.jspa?searchID=10118555&messageID=2906656
    https://forums.sdn.sap.com/click.jspa?searchID=10118555&messageID=913873
    https://forums.sdn.sap.com/click.jspa?searchID=10118555&messageID=2441579
    Thanks

  • ABAP Runtime error while activating Update rules.

    Hi Gurus,
    Actually we are in NW 2004's SP9.
    While activating the update rules of cube "0PY_PPC01" it is going to ABAP runtime error. It is giving the key words like "MESSAGE_TYPE_X"
    "%_T005K2" or "INSTANTIATE". And i apply NOTEs also i am unable to fix it.
    Can any one give  correct NOTE number that can fix it or any suggestions.
    Thanks in advance.
    Thanks
    Raju.k

    Hi Sven,
    Now we are also in SP11, But the thing is all the other UR are working fine Except
    this UR. Even there is no perticular NOTE number for this.
    Thanks
    Raju.k

  • Convert ABAP code in start routine/update rule to transform. start routine

    Dear BW ABAPers,
    I have created a custom purchasing info cube (YCP_PURC1) based on 0CP_PURC1 standard cube. I would like to convert this new data flow to BI7 (from 3.x), and convert the standard update rule to transformation. I would need to rewrite the below start routine from the standard update rule to a start routine ABAP code in the newly created  transformation / start routine. My ABAP knowledge is limited. Will you please help?
    *this is the start routine from the update rule. As a side note, the data source is 2LIS_02_SCL.
    LOOP AT SOURCE_PACKAGE.
        IF (     SOURCE_PACKAGE-cppvlc  EQ 0
             AND SOURCE_PACKAGE-cppvoc  EQ 0
             AND SOURCE_PACKAGE-cpquaou EQ 0 ).
          DELETE SOURCE_PACKAGE.
          CONTINUE.
        ENDIF.
    no_scl is initial ( e.g. for good receipts, billing)
    value has to be set depending on storno
        IF SOURCE_PACKAGE-no_scl IS INITIAL.
          IF SOURCE_PACKAGE-storno = 'X'.
            SOURCE_PACKAGE-no_scl = -1.
          ELSE.
            SOURCE_PACKAGE-no_scl = 1.
          ENDIF.
          MODIFY SOURCE_PACKAGE.
        ENDIF.
      ENDLOOP.
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    Many thanks and look forward to your kind feedback.
    Kind regards,
    Csaba

    Dear All, Durgesh,
    thanks to you all for your valuable input. Mainly the ABAP part was more interesting for me.
    Durgesh, thanks for your input, it was useful. I just had to change the info objects to data source fields and add the lines before the loop:
    DATA: I_PACKAGE TYPE TYT_SC_1.
        FIELD-SYMBOLS <i_package> TYPE tys_sc_1.
        I_PACKAGE[] = SOURCE_PACKAGE[].
        LOOP AT SOURCE_PACKAGE assigning <i_package>.
          IF ( <i_package>-BWGEO EQ 0
          AND <i_package>-BWGEOO EQ 0
          AND <i_package>-BWMNG EQ 0 ).
            DELETE SOURCE_PACKAGE index sy-tabix.
            CONTINUE.
          ENDIF.
    no_scl is initial ( e.g. for good receipts, billing)
    value has to be set depending on storno
          IF <i_package>-NOSCL IS INITIAL.
            IF <i_package>-ROCANCEL = 'X'.
              <i_package>-NOSCL = -1.
            ELSE.
              <i_package>-NOSCL = 1.
            ENDIF.
          ENDIF.
        ENDLOOP.
    Points have been assigned accordingly.
    Thanks,
    Csaba

  • ABAP program running time-BW update Rules

    Hi All,
    I have an ABAP program that is in one of the update rules from source ODS to destination ODS. Source ODS has 20million records. When we are loading the records to destination ODS , Is there any way I can find howmuch time will take to process 1 record and also when it is running how do I know howmany records it has processed or howmany yet to process ? I have tried with SM50 but not able to find much useful information?
    Please help me and if you have any documents please send it to [email protected]
    Regards
    Vennela

    Hi Vennela,
    just choose one request and click on monitor -> details. Click on processing -> Data Package 1 -> Update Rules. If you put the cursor on the first node, you'll see a date and time field on the screen (below). If you click on the last node you'll see how long it took to process the records.
    Another possibility would be to run it in simulation mode and check the response time. To do so, you'll have to click on 'Response Time' in the SAP GUI field below at the right side of your screen (normally it shows the system name and mandant).
    Hope that helps!
    Regards
    Nicola

  • How to use two values for a constant in update rule..

    Hi,
    I have to make a update rule for Fiscal year variant. and I have to assign two values Z4 and FW as constant to it.
    Please suggest me any idea. As I think at a time we can give only one constant value to a update rule...
    Thanking you..
    Saurabh Tiwari
    [email protected]

    Hi:
    If you want to give either Z4 or FW depending on a Logic, you can use ABAP or Formula Builder.
    Ofcourse you cannot give FiscVariant = 'Z4FW' because thats not a valid value.
    Ram C.

  • Need PL/SQL Command for to check all rows value for child record and update

    Hi All,
    i want to update one field following by
    one to many relationship for example
    in child applet status field is value is "Closed" for all child record then parent value also should update to closed
    Note: if one child record field status is "Open" don't do the update operation

    You can do it in single UPDATE operation.
    Here is sample & Result:
    create table PA (id varchar2(3), name varchar2(12), STATUS varchar2(12));
    insert into pa values('001','Cary','Open');
    insert into pa values('002','TOM','Open');
    create table boy (par_id varchar2(3), id varchar2(4), name varchar2(12), status varchar2(12));
    insert into boy values('001','ABC1','Cary','Open');
    insert into boy values('001','ABC2','Mac','Closed');
    insert into boy values('001','ABC3','Ray','Closed');
    insert into boy values('001','ABC4','NALLY','Open');
    insert into boy values('002','ABC5','ME','Closed');
    insert into boy values('002','ABC6','SHE','Closed');
    UPDATE PA
    SET STATUS='Closed'
    WHERE NOT EXISTS
      (SELECT 1
      FROM BOY
      WHERE BOY.PAR_ID=PA.id
      GROUP BY BOY.PAR_ID,
        BOY.STATUS
      HAVING SUM(DECODE(BOY.STATUS,'Open',1,'Closed',0,0))>0
    select * from pa;
    001     Cary     Open
    002     TOM     Closed

  • BI Content Update rules not available for 0IC_C03 cube

    Hi
    We have recently did technical upgrade to our DEV box and made a system copy for sand box. I am trying to install the BI content for 0IC_C03 infocube. I cant see update rules for this data flow. I could see Transformations and can also see info source (ex: 2LIS_03_BF_TR) which we dont expect. We havent migrated or never used inventory BI content. What is the reason we could see transformations for this cube data flow in BI content? We are on SP15. I tried to install transformations but cant install them properly.

    Hi A,
    Business content it's still using 3.x data flow. That's why you see a 3.x infosource.
    You won't have transformations for this. The update rules icon is like a transformation but with a small white square on the left.
    So the dataflow you should have is:
    Cube
      Update Rules (0IC_C03 2LIS_03_BF)
        3.x InfoSource (Material movements (as of 2.0B))
          Transfer Rules
            Datasource
    You'll see a small square next to all the objects, except for the cube. This means 3.x object.
    Hope this helps.
    Regards,
    Diego

  • Update Rule 8ZCDSDS03 and 80CDS_DS07 for data mart

    Hello Guru´s
    My proble is this
    8ZCDSDS03 Update rules to Data marts for cube 0SD_C03
    80CDS_DS07 Update rules to Data marts for cube 0SD_C11
    are in gray i don´t know why. do you have and explanation or a solution for that.
    whit best regards
    agt

    Hi Antonio,
    Any time you make a change to a cube, check the update rules feeding it and activate them. Also check if this InfoCube is supplying data to other data targets and check the 8* update rules and activate if required.
    Right now you can double click the grey rules and activate them and transport the active rules (if required)
    Hope this helps...

  • BW 3.5 update rules for master data

    Hi all,
             I create a dummy report in that report lifnr is charactics and name its att. after  this i create a application component and assign data source and create infopkg   data coming in lifnr and name field properly <b>i assign data source using direct master data update</b> after this i create infocube and assign dim.
    but when i rgt click on infocube and display dataflow it shows only one level and when i open bex and open that it shows no application data found why this happened after creating infocube it is nessory that i creat update rule for this am i right plz send your openion.
    thx

    Hi Ankit,
                  Yoy have to load data to the cube.For that you need update rules.
    Steps to load data to the cube
    1.Replicate the datasource.
    2.Assign Infosource
    3.Create transfer rules
    4.Maintain the update rules to the cube.
    5.Right click on the datasource and schedule an infopackage for it.
    Execute the Infopackage and pull the data to the cube.
    Hope this helps
    Regards
    Karthik

  • Error while Activating update rule in BW

    Hi,
    I am getting an ABAP dump while activating an update rule. The rule is from DSO to cube.
    "MESSAGE_TYPE_X" " "    
    "%_T020N1" or "%_T020N1"
    "INSTANTIATE"           
    I have added some new fields in a DSO. The rule is from DSO to cube. While activating it, I am getting this ABAP dump. There are few other rules from this DSO to other DSO which got activated but this one is causing dump.
    Any ideas/suggestions on this would be really helpful.
    Thanks,
    Naveen

    Hi
    Check if your Cube , DSO and UR's are active. If not reactivate them. Ideally you could recreate the UR's and check the status by running the extraction.
    I would also recommend to use elimination method to check if any particular field is creating an issue. While recreating the UR's , create them for a few fields - active - check extraction - this will also let you know if the issue is within any oif the rules.
    Cheers
    Umesh

  • Error in ODS Update Rules.

    Hi,
    We have an abap routine in an ODS Update rules to get FISC YEAR (type NUMC 4) with a field FISCPER(numc 7) from a table. This routine worked fine. But now we moved the abap routine to cmod program in r/3, and when I am doing a direct mapping of fiscper to fiscyear,  I am getting this error message 'Fiscal year variant missing for time conversion of characteristic 0FISCYEAR'.  I already did a direct mapping of Fiscal year variant in the update rules.
    Am I missing some thing here?
    Thanks!

    Yes, I am getting fiscvar as V6 from cmod program in r/3, and did a direct mapping in update rules.

Maybe you are looking for