Inserting code in final steps of Update Rule transformation

Hi,
I am extracting data into a cube from an ODS and doing some aggregation in the process. E.g 3 records in the ODS might become 1 in the cube.
This is fine for some things like Quantity, but not ideal for things like unit price. One work around is for the ODS to have a counter.
e.g
MATERIAL QUANITITY  UNIT_PRICE   COUNTER
1234     13         $1.50         1
1234     21         $1.50         1
1234     45         $1.50         1
This comes across into  a cube like
MATERIAL QUANITITY  UNIT_PRICE   COUNTER
1234     79         $4.50         3
- unit price can then be calculated by dividing unit price by counter - however it needs to be done within the query.
I thought perhaps we could perform this calculation when populating the cube, if the items were firstly collected within an interim table before being passed to the return_table.
i.e
1. Define key figure using ABAP routine and return table.
2. Append INTERIM_TABLE within update rules for each read of the ODS
3. Once all ODS records have been read and inserted at an aggregate level within INTERIM_TABLE, loop through INTERIM_TABLE, perform calculation and append RETURN_TABLE.
My question is: Is there a simple way to determine that all ODS items have been read (like an "at last" statement) and if so, where can this code be inserted? Can it be simply placed in the update rules routine if I have the appropriate logic to determine that all items have been read?
Thanks
Adrian

Hi Adrian,
   Why cant you use Addition, minimum or maximum in update rules...?? Here you can use Maximum option for Unit Price.
http://help.sap.com/saphelp_nw04/helpdata/en/3f/0e503c3c0d563de10000000a114084/content.htm
Hope it Helps
Srini

Similar Messages

  • ABAP code help for 0PROFIT_CTR  (in Update rules)

    Hi
    Can you please give me the update rules code that would do the following in BW 3.5:
    If Profit Center is 10 digits long, its ok but if Profit Center is 5 digits long, concatenate with 5 zeros.
    Thanks
    Jimi
    Edited by: jimi ogun on Dec 1, 2011 1:44 PM

    Hi Soorej
    I tried teh code in my transfer rules but the result was blank. I guess it was because i didnt insert anything in the RESULT line... This is what i tried to do but i get a syntax error:
    $$ begin of routine - insert your code only below this line        -
    DATA: l_s_errorlog TYPE rssm_s_errorlog_int.
    data : len type i,
          v1(10) TYPE c value 'abcde'.
    len = strlen( v1 ).
    if len = 5.
    CONCATENATE v1 '00000' into v1.
    endif.
      RESULT = /BI0/OIPROFIT_CTR.
    returncode <> 0 means skip this record
      RETURNCODE = 0.
    abort <> 0 means skip whole data package !!!
      ABORT = 0.
    The syntax error i get is below:
    E:Field "/BI0/OIPROFIT_CTR" is unknown. It is neither in one of the
    specified tables nor defined by a "DATA" statement. "DATA" statement.

  • Update rule--transformation

    Hi,
    i am working on BI 7.0. i was  having problem in creating proper transformation with routines so i followed following path. please let me know if i am correct since there was no error in loading still data validation is to be done
    STEPS:
    1> created transformation by right click on 3.x update rules.
    2> Now used the rule routines as defined in thios transformation in my new transformation created from 7.0 DS by copy and pasting the codes at appropiate place in routine. haven't tried for start routine.
    3> followe the usual 7.0 flow IP>transformation>target(in my case cube). was able to succesfully load data.
    Hope i am not making some blunder
    waiting for some quick response whether i am on right track or not so that i can use it in other cubes/
    Thanks
    Prashant

    Hi,
    be carefull for startroutine! The parameter names have changed from 3.0 update rules to 7.0 transformations! data-PAckage gets to data_source.
    But the rest look ok.
    Regards,
    Juergen

  • Loading time-dependent master data using update rules/transformations

    Hi
    I am trying to load time-dependent master data to an infoobject. It seems that I get an error message on duplicate records if I use a transformation or update rule. Does this only work with direct update ?

    In the DTP you have the option to ignore duplicate records....
    Just select that and then load data...

  • Error when transpotring Update Rules

    Dear colleagues.
      When transporting an update Rules into our Quality enviroment the system pops up the following error:
    IC=ZWEPP_C02 IS=ZWE_BOM_RMX_IS syntax error:  rows 0.
    I've verified the Update Rules on the Quality System and everything is correct but it remains inactive due to the transport fails.
    I would appreciate your feedback.
    Thanks in advance.

    Dear khaja.
      I send you the transport log as well as the Return Code.
    Error when activating update rule 5MYASZMBOIQZSRR60674OBKJ3
    IC=ZWEPP_C02 IS=ZWE_BOM_RMX_IS error when generating InfoCube Update program
    IC=ZWEPP_C02 IS=ZWE_BOM_RMX_IS syntax error:   rows 0 (When generating the update program for data target ZWEPP_C02, InfoSource ZWE_BOM_RMX_IS, a syntax error occured in row 0.  Message no. RSAU466)
    Errors occurred during post-handling RS_AFTER_IMPORT for ROUT L
    Please, let me know if you need anything else.
    Thanks.

  • Transport Failure - (Infocubes & Update Rules collection)

    Hi SDners,
    While i transporting the Request (which contain Infocubes and relevant update rules only)from develpment system to quality, the request was failed due to following Errors given below.
    Start of the after-import method RS_CUBE_AFTER_IMPORT for object type(s) CUBE (Activation Mode)                
    Error/warning in dict. activator, detailed log    > Detail                                                     
    /BIC/L100146 (specify a primary key)                                                                           
    Table /BIC/L100146 could not be activated                                                                      
    Return code..............: 8                                                                               
    DDIC Object TABL /BIC/L100146 has not been activated                                                           
    Error when activating InfoCube 100146                                                                          
    Error/warning in dict. activator, detailed log    > Detail                                                     
    /BIC/L100146 (specify a primary key)                                                                           
    Table /BIC/L100146 could not be activated                                                                      
    Return code..............: 8                                                                               
    DDIC Object TABL /BIC/L100146 has not been activated                                                           
    Error when activating InfoCube 100146                                                                          
    Error/warning in dict. activator, detailed log    > Detail                                                     
    /BIC/V1001042-0NETPRICE (combination reference table/field /BIC/V1001042-0LOC_CURRCY does not exist)           
    /BIC/V100104H-0NETPRICE (combination reference table/field /BIC/V100104H-0LOC_CURRCY does not exist)           
    /BIC/V100104I-NETPRICE (combination reference table/field /BIC/V100104I-LOC_CURRCY does not exist)             
    /BIC/V100104J-0NETPRICE (combination reference table/field /BIC/V100104J-0LOC_CURRCY does not exist)           
    /BIC/V100104M-0NETPRICE (combination reference table/field /BIC/V100104M-0LOC_CURRCY does not exist)           
    /BIC/V100104T-NETPRICE (combination reference table/field /BIC/V100104T-LOC_CURRCY does not exist)             
    Table /BIC/V1001042 could not be activated                                                                     
    Table /BIC/V100104H could not be activated                                                                     
    Table /BIC/V100104I could not be activated                                                                     
    Table /BIC/V100104J could not be activated                                                                     
    Table /BIC/V100104M could not be activated                                                                     
    Table /BIC/V100104T could not be activated                                                                     
    Return code..............: 8                                                                               
    DDIC Object TABL /BIC/V100104T has not been activated                                                          
    Error when activating InfoCube 100104                   
    Can any one suggest the solution.
    Thanks,
    Satya
    Edited by: satya prasad on Jan 15, 2010 11:48 AM

    Hi,
    Create two transport requests -
    TR1) Collect the InfoObjects (If newly creted or activated from the Business Content), InfoProviders and the Queries if created.
    TR2) Collect the Datasource, Infopackages, Transfer Rules, InfoSources, Update Rules, Transformations and DTPs
    Transport TR1 followed by TR2.
    Regards,
    Geeta

  • How to get the hierarchy in update rules

    i want to update the material hierarchy to the open hub data file
    i create a update rule(transformation)
    and i want to get the node name at the last level of the hierarchy tree above the material level
    how can i do this?

    no
    for example
    now we have maintain the hierarchy of material like this:
    026(level 1)
    -026/100(level 2)
    -026/200(level 2)
         |-026/20010(level 3)
         |---800501234(level 4)
    in this hierarchy tree,the material 800501234 is in the level 4
    and i want to get the last level hierarchy node above the material
    for 800501234,the hierarchy node is 026/20010
    so
    i want to export the data like this:
    hierarchy id      |        material
    026/20010        |        800501234
    how can i do this?
    Edited by: Yang Zelphar on Mar 25, 2009 5:03 AM
    Edited by: Yang Zelphar on Mar 25, 2009 5:04 AM

  • Sample code in Update Rule to restrict data selection?

    We used to restrict data selection in InfoPackage data selection, e.g., for company code range when loading data from a source system (e.g. EBP which is similar to R3), but somehow the company code range we set in InfoPackage data selection not working and we found actually it occurs on the source system side when running RSA3 on EBP side and input the company code range in RSA3 selection section, but still it extracts data beyond the company code range.  We don't understand why EBP data selection doesn't work, then we consider in update rule on BW to set the company code range.  We know in update rule, we can select Start Routine, formula, or routine to set the company code range.  But we would be appreciated if experts here can recommend which one is the most efficient to load data fast for data load performance reason and would be appreicated if you can let us know the sample code!
    Thanks in advance!

    hi Hari,
    I copy the whole code of the start routine below:
    PROGRAM UPDATE_ROUTINE.
    $$ begin of global - insert your declaration only below this line  -
    TABLES: ...
    Includes to update generic objects
    INCLUDE rsbctgn_top .
    INCLUDE rsbctgn_update_rules .
    INCLUDE rsbctbbp_generic_objects.
      The following section is prepared for you if you compound
      the business partner 0BPARTNER with the
      Source System 0BBP_SYS_BP or if you compound the organizational
      Unit 0ORGUNIT with the source System 0BBP_SYS_BP
    TYPE-POOLS: RRSV.
    Data: L_HLP_CHAVL_CMP       TYPE RSCHAVL.
    DATA:
           L_S_DEP       TYPE RRSV_S_DEP,
           L_T_DEP       TYPE RRSV_T_DEP.
      End of compound
    DATA: l_s_errorlog        TYPE rssm_s_errorlog_int,
          l_hlp_chavl         TYPE rschavl.
    $$ end of global - insert your declaration only before this line   -
    The follow definition is new in the BW3.x
    TYPES:
      BEGIN OF DATA_PACKAGE_STRUCTURE.
         INCLUDE STRUCTURE /BIC/CS0BBP_CONF_TD_1.
    TYPES:
         RECNO   LIKE sy-tabix,
      END OF DATA_PACKAGE_STRUCTURE.
    DATA:
      DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE
           WITH HEADER LINE
           WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
    FORM startup
      TABLES   MONITOR STRUCTURE RSMONITOR "user defined monitoring
               MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n
               DATA_PACKAGE STRUCTURE DATA_PACKAGE
      USING    RECORD_ALL LIKE SY-TABIX
               SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
      CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
    $$ begin of routine - insert your code only below this line        -
    fill the internal tables "MONITOR" and/or "MONITOR_RECNO",
    to make monitor entries
    delete data_package where 0comp_code < 'X300' OR 0comp_code > 'X6ZZ'.
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    $$ end of routine - insert your code only before this line         -
    ENDFORM.

  • Comment out code in Update Rule

    Hello,
    Quick question.
    How do I comment out code in the update rule?  I need to comment out a large amount of code for testing purposes.
    Thanks,
    Sheila

    Hi Sheila
    Go to Update rule code (routine) ->> select the code you want to comment out with mouse ->> then go to top menu Utilities -> Block/Buffer-> Insert Comment *
    This will comment out the code that you had selected.
    Regards
    Pradip
    (don't forget points)

  • How can I view the code for a routine in an update rule

    on loading data for 0PLANT_ATTR, I am getting an error for No Local Currency found in Plant 1000 and SAles Org 6000. 
    in looking at the update rules for this, I see that there is a routine for the update of the local currency:
    Perform GET_LOCCURRCY_FOR_PLANT
    USING COMM_STRUCTURE-PLANT
    COMM_STRUCTURE-SALESORG
    CHANGING hlp_monitor
    RESULT
    hlp_subrc.
    How do I see the code behind this?  I want to make sure that I understand everything that needs to be populated in Master Data so that I can ask my functional consultant to update all the necessary fields.
    Thanks
    JP

    Hi Riccardo,
    When I double click on it, I get a message at the bottom that says program reindexed. 
    After looking again, I found that when I double clicked on the comm structure, then the routine, I was able to see it.
    Thanks
    JP

  • Creation of WDS fails on final step - unable to update settings

    Hey Ya'll -
    I've setup my WDS several times in the past and it's always worked flawlessly. For whatever reason, it quit working recently, and I decided to do a hard reset on my routers and re-create the WDS. I have two Airport Extreme Base Stations.
    I've followed the instructions for creating a WDS to the letter. It does everything exactly right until the final step ... after it says "WDS created succesfully" - I click OK, and it says:
    1) rejoining this base station's network
    2) writing base station configuration ...
    It hangs up here, and after about 5 minutes, it finally unlocks (spinning colored beach ball) and says "the airport admin utility was unable to update the settings of the selected base station".
    Both base stations are in range right here on my desk. I've tried this 4 times now, and it crashes in the same place everytime.
    If I run Airport Admin Utility on each router separately, to change the password, rename the router, etc., it connects easily, writes the configuration, and exits properly. I've done several tests (changing the name of the router, mostly) and I've even tried doing the manual WDS creation, but it does not work.
    I have 10.4.3 with Apple Base Station V5.6 and Apple Airport Admin Utility Version 4.2.
    Help!~?
    Thanks,
    FRED

    I would suggest going to
    https://helpx.adobe.com/support.html
    and jumping through whatever hoops are needed to get to the CHAT capability, then initiating an online chat with an Adobe Support person. You will end up speaking with someone in India, but I've had strange problems such as yours solved several times this way. You need to be patient, as it's not a "quick" process, but it should get you to where you need to go.
    Good luck.

  • ABAP code in update rules to convert the date

    Hi,
    Could any one send me the ABAP code that is written in the update rules to convert the date (DD/MM/YYYY  -- lenght 10) to YYYYMMDD ---  length 8  format.
    Also please let me know where I should write this code; while creating update rules or while creating infosource.
    Thanks,

    Hi Bharath,
    Hi Bharath,
    I suggest you do the conversion of dates in the transfer rules. Here is the correct code you need:
    * Assuming the source data field is called MYDATE
    * Place the ff. in the routine in the transfer rules:
    concatenate tran_structure-mydate+6(4) tran_structure-mydate+3(2) tran_structure-mydate(2) into result.
    replace MYDATE with the name of the source field (10 chars) in the transfer structure. Hope this helps.

  • 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

  • URGENT !!! - ABAP code in update rule

    Friends,
    With my limited knowledge in ABAP, I need some help from the forum.
    I need to create a routine in update rule to capture 'date of last GR against a PO delivery schedule'. Let's say
    PO # 1234
    IT # 10
    SCL # 1
    There are multiple partial deliveries against SCL # 1 above and I have to capture the last delivery date and subsequently the last invoice date. If I try to set the rule to capture the 'posting date' based of 'transfer type'  - the GR date field gets overwritten by the last invoice date (the date of last activity). My requirement is to separate the two i.e.
    1) Date of last GR against PO - Item - SCL line
    2) Date of lasr INV against PO - Item - SCL line
    Can any one help me with the code ???
    Thanks,
    AK

    Hi,
    check the following link, gives an example of an update routine.
    http://help.sap.com/saphelp_nw70/helpdata/en/80/1a64fae07211d2acb80000e829fbfe/frameset.htm

  • How to Code "AND" logic in Update Rule?

    Hi:
    I have minimal ABAP knowledge and need some help....
    I have to use the Query logic and code in my Update rule... (i.e. multiple conditions have to be met)
    IF (COMM_STRUCTURE-Sales_Org = '100' AND  COMM_Structure-Division = 'LA' AND COMM_STRUCTURE-Acct_Grp = '0120')
          RESULT = COMM_STRUCTURE-Credit_Amoutn (I want to assign a specific KF)
    ELSE
         RESULT = 0 (I want to assign Zero)
    ENDIF
    I attempted this logic, but I keep getting an error with 'AND' statement.  I am not sure what is the syntax.
    Can someone please help me out with the  logic/sytax
    Thanks..... Lee

    Hi:
    I responded without checking the logic.... assuming it would work...!~
    Unfortunately it gives me error:
    QUOTE
    E:Incorrect logical expression: ")" must be followed by "AND" or "OR" . .
    UNQUOTE
    Can anyone help me resolving this please....!!!!
    Thanks... lee

Maybe you are looking for

  • Oracle database upgrate

    urrently we are running Oracle Server 7.3.4 Under Unix (SunOS5.7) with access to a Sybase 12.5.0.1 via Oracle-Sybase Transparent Gateway 4.1.1.0.0. For the web services, we use OAS 4.0.8.1. Our web applications are based on Javascript and Oracle PL/S

  • Change default Windows background during deployment

    I have a Windows deployment server up and running and deploying custom Windows 7&8 images which all work fine. I want to be able to change the default Windows background to a custom image during deployment so when a new user is created and logs in lo

  • HT5861 iBooks won't let me sign in

    I just upgraded to Mavericks and was checking out the iBooks app. It transferred my current collection of books on itunes at this computer, but won't let me sign in to the app with my id. It won't even present the window or page to input my id and pa

  • EHS Report Management Document Key

    I am working in the EHS module.  In ABAP I am using the FM BAPI_BUS1077_GETDETAIL and have tried a number of different VATS to retrieve the Document Key for the reports attached to the specifications without success.  In SAP, using transaction CG02BD

  • Help to find 40107 model for Multisim 9

    Hello! can somebody help me to find 40107 Multisim model? or even though SPICE model. tnx