Start routine to update some fields of a ODS based on the another ODS

Hi I know i have to do abap coding at the start routine to update a ODS based on another ODS. I have tried doing the code for quite some time now and i have not been successful. I think I havenu2019t followed the definition required for this routine.
I have 2 ODS, ODS1 has 3 key fields and ODS2 has 1 key field
I have to map the ODS based on a 1:3 relation.
I am writing this start routine for the update rules from ODS2 to ODS1.
The logic is if the key field of ODS2 is equal to either Key field 1 or Key field 2 or Key field 3 of ODS1 then that record from ODS2 has to be updated to the corresponding matching record of ODS1, else no update. The 3 key fields of ODS1 have different character length and character types and the key field of ODS2 has a different character length and type when compared to the any of the key fields of ODS2 can match any of those.
Like key field 1 of ODS1 has length 10. Key field 2 of ODS1 has length 10 and key field 3 of ODS1 has length 20 and all these fields are not alpha converted, but the key field of ODS2 has length 60 and it is alpha converted.
Can anyone please help me in this code.
My Code is as below.
ITAB1-T_BOL = DATA_PACKAGE-/BIC/ZLBOL.
***********NISTEVO SELECT******************************
  SELECT /BIC/ZLBOL FROM /BIC/AWLONST0100 INTO ITAB1-T_BOL
              WHERE /BIC/ZLBOL = ITAB1-T_BOL .
**************R/3 SELECT*******************************
    SELECT /BIC/ZLRDELNU /BIC/ZLRSHIPNU /BIC/ZLREXTID
              FROM /BIC/AWLOR3O0400
              INTO CORRESPONDING FIELDS OF ITAB1
              WHERE
              /BIC/ZLRDELNU = ITAB1-T_BOL OR
               /BIC/ZLRSHIPNU = ITAB1-T_BOL OR
               /BIC/ZLREXTID = ITAB1-T_BOL .
      SORT ITAB1 BY T_DELNU T_SHIPNU T_EXTID .
      LOOP AT DATA_PACKAGE.
        READ TABLE ITAB1 WITH KEY T_DELNU = DATA_PACKAGE-/BIC/ZLBOL.
        IF SY-SUBRC = 0.
          EXIT.
        ENDIF.
        READ TABLE ITAB1 WITH KEY T_SHIPNU = DATA_PACKAGE-/BIC/ZLBOL.
        IF SY-SUBRC = 0.
          EXIT.
        ENDIF.
        READ TABLE ITAB1 WITH KEY T_EXTID = DATA_PACKAGE-/BIC/ZLBOL.
        IF SY-SUBRC = 0.
          EXIT.
        ENDIF.
        DELETE DATA_PACKAGE .
      ENDLOOP.
    ENDSELECT.
  ENDSELECT.
Points will be awarded.
Edited by: satish rajaram on Nov 6, 2008 4:51 PM
Edited by: satish rajaram on Nov 7, 2008 11:40 AM
Edited by: satish rajaram on Nov 7, 2008 11:43 AM

The logic is if the key field of ODS2 is equal to either Key field 1 or Key field 2 or Key field 3 of ODS1 then that record from ODS2 has to be updated to the corresponding matching record of ODS1, else no update. The 3 key fields of ODS1 have different character length and character types and the key field of ODS2 has a different character length and type when compared to the any of the key fields of ODS2 can match any of those.
Can you try below logic :
Below is not code it needs to be manipulated as per requirement.
ODS2 ---> ODS1
SELECT <key fields of ODS1>
FROM /BIC/A<ODS1>00
INTO ITAB
FOR ALL ENTRIES IN DATA_PACKAGE
WHERE
keyfield1 = data_package-key1
or
keyfield2 = data_package-key2
or
keyfield3 = data_package-key3
**Now itab has all entries which neednot be deleted from data_package.****
if sy-subrc=0.
***Check Itab and delete only those records not present in itab from data_package****
endif.
Hope this helps.

Similar Messages

  • 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

  • Start Routine Logic Updating Field in Target ODS

    Hi,
    I am creating a  Start Routine to Update Field (date) from one ODS to another based on the Key Structure: Document Number, Line Item Number.
    I am encountering a situation as follows:
    Source
    Doc Num 1 Line Item 10 Date 1/1/1
    Target
    Doc Num 1 Line Item 10 Date 1/1/1
    DocNum 1 Line Item 20
    DocNum 1 Line Item 30
    DocNum 1 Line Item 40
    The Routine I have now correctly updates line item 10 with the date 1/1/1.
    I am trying to modify the code to only update the target ods if all of the line items are in the source.  In this example Line Item 10 would not get updated since Line Items 20,30,40 are not in the Source ODS. 
    Has anyone encountered something like this.
    Thanks for any help.

    Hi,
    If you have all the line items in target for which you want to do updates  you can do this in transformation start routine.
    Try this first hand logic :
    1. Create a internal tables(say SOURCE_INTERNAL_TABLE and TARGET_INTERNAL_TABLE)
        with fields document number and another field integer say COUNTER
    2. Read active table of source for all the document numbers in source package.
    3. Update the SOURCE_INTERNAL_TABLE for all the document number with appropriate counts
        (All the records of same document number should be in same data package)
    4. Update the TARGET_INTERNAL_TABLE by reading the target ODS as done for source.
    5. LOOP  AT SOURCE_PACKAGE
         if COUNTER in SOURCE_INTERNAL_TABLE and TARGET_INTERNAL_TABLE is not same
         then delete the record from source package itself
       END LOOP
    6. Your next code
        (Please take care that you are not referring the deleted records otherwise it will through a dump)
    If you don't have all the line items in target then you need to bring them somewhere in BI (document number and item number only sufficient with both as a key fields) so as to refer them in your start routine.
    Please update me if anything is wrong or if any corrections in logic.
    Thanks and Regards,
    Prashant Vankudre.

  • Start routine and update rules

    Hi,
    What is accessed first:-
    Start Routines or Update Rules?
    What is the use of global variables in start routine?
    Please reply.
    Thanks.

    Hi......
    You have different types of Routines in BW .
    1) Start Routine in Transfer Rules
    2) Transfer Routine in Transfer Rules.
    3)Start Routine in Update Rules
    4)Update Routine in Update Rules.
    The routines that you write in transfer rules are applicable to all the Data targets that get the data from that particular Infosource, when you are going to write some code in Transfer rules, you have to understand that you are going to manupilate the data that is going to get into BW .
    If you are going to write in Update Rules , then that logic is going to apply only for that particular Data target .
    Eg : Let suppose I have a Flat file that gets data from 3 countries, US, Canada and Mexico.
    Now I have prepared the data source for the same . But I dont want to have the data of Mexico in to BW itself.
    So I will write a Start routine at TR to eliminate the data of Mexico.
    My Next step is I want the data of US into one ODS and Canada data in to another ODS.
    For this I handle the dataflow at Start routine in Update rules, to eliminate Canada data for US ODS and Vice Versa.
    Global variables in Start routine
    You can have global variables, internal tables populated by the
    startup routine. This data will be available to the field
    routines. Create yourself a start routine, declare some
    variables in the global section, and then create a field
    routine. You will be able to use the globally declared objects
    in the field routine
    Please check below help link for routines in sap netweaver 2004s
    http://help.sap.com/saphelp_sem60/helpdata/en/e3/732c42be6fde2ce10000000a1550b0/frameset.htm
    How to guide "How to transformations routines".Please check the below link:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/dc1d9990-0201-0010-16aa-db3c4eb8b642
    start routine in transfer rules
    Look up to load master data
    excluding
    Start Routine in Transfer Rules
    Sample code in Update Rule to restrict data selection?
    Append Datapak - transfer start routine
    Excluding Blank field in Infopackage Filter
    Trans Routine ABAP help ..
    transfer routine
    Date key figure: Convert DATS format to DEC format
    Date Conversion in Flat File
    Transfer Routine ABAP
    conversion exit
    Date Conversion
    Problem with  conversion char to numc in transference rules
    conversion routine..?
    update routine
    How to call a function in Update Rules to reverse a key figure sign
    Need Sample Code for Update Rules
    Date calculation
    Difference between data in PSA and Data in Infocube
    No RETURNCODE <> 0 allowed in update routines in transfer mode
    the diffrerece between DEC and (yyyymmdd) 8 char in Time defination
    Access master data in update rules
    Date key figure: Convert DATS format to DEC format
    start routine in update rules
    Is it possible to read a third ODS in update rules between two ODS?
    update rule coding while loading data from ODS to CUBE
    Start Routine in Update Rules to populate additional fields from ODS
    Coding in Update Rules accessing a Z-Table
    Start routine
    Hope this helps you..........
    Regards,
    Debjani.........
    Edited by: Debjani  Mukherjee on Oct 1, 2008 4:58 PM

  • Diff between the Start routine and Update rules?

    Hi Gurus
    Diff between the Start routine and Update rules?
    Thanks in advance
    Raj

    Hi,
    Routines are like conditions or business rules that could be applied to filter the data while entering the BW system or could be used to apply certain conditions on the info objects itself.Update rule level you manipulate your data and  write your start routine.
    There are 4 types of routines
    1. Start routine- Could be used at two levels (transfer rule level and the Update rule level)
    This Start routine written at the transfer rule level helps filter the necessary data coming from the source system.
    For Example: If you decide to extract data that contain only quantity greater than 500 , then you could specify the Start rouitne to achieve this.
    The Start routine at the Update rule level provides similar functionality but at this point it helps direct specific data to 
    different data targets.  For Example: If there 3 data targets being fed from the Infosource, you may want to apply some condition to each data target, like send year 2000 data ti Data target1, 2001 to data target 2 and so on.  This can be achieved by using Start routine at the Update rule level
    2. Transfer Routine: This feature is available at the transfer rule levels
    While performing the transfer rules operation, there are 4 features available to the developers to create business rules on top pf the Infoobjects.
    1. You could do a one to one mappping of the Infoobject
    2. Provide a constant value
    3. Include a formula
    4. Write an ABAP routine.
    These 4 options refers to the transfer routine
    3. Update Routine:
    The limitations of just having 4 options in the transfer routine is overcome at the update rule level. There are various other 
    sophisticated features avaialable apart from the 4 options mentioned above. These business rules could be specified pertaining to each data target.
    4. Conversion Routine: It provides functionality to do Currency and unit conversion.
    Regards.

  • Update a field multiple times, but only if the field is empty

    I am having trouble updating a field in my table based upon a set of 7 different rules. I have been scratching my head at this for a few days, and am not sure what exactly is wrong, but am sure there is something small causing me problems. My current code
    is:
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value1'
    WHERE svc = 'Y' AND Field1 = '' ;
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value2'
    WHERE Dlv Is Null AND Cat = 'svc' AND Field1 = '';
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value2'
    WHERE (prod LIKE 'ABC%') OR (prod LIKE 'ABB%') AND Field1 = '';
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value3'
    WHERE Dlv = 'Elec' AND Field1 = '';
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value4'
    WHERE Ord = '0' AND Cat = 'Hdw' OR Cat = 'Bnd' AND Field1 = '';
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value5'
    WHERE Ord = '0' AND (NOT (Cat = 'Hdw')) AND (NOT (Cat = 'Bnd')) AND Field1 = '';
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value4'
    WHERE (Ind = '1' AND Cat = 'Hdw') OR (Cat = 'Bnd') AND Field1 = '';
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value5'
    WHERE (Ind = '1' AND NOT (Cat = 'Hdw')) AND (NOT (Cat = 'Bnd')) AND Field1 = '';
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value6'
    WHERE Ind = '0' AND Cat = 'Hdw' OR Cat = 'Bnd' AND Field1 = '';
    COMMIT TRANSACTION
    BEGIN TRANSACTION
    UPDATE MyTable
    SET Field1 = 'Value7'
    WHERE (Ind = '0' AND NOT (Cat = 'Hdw')) AND (NOT (Cat = 'Bnd')) AND Field1 = '';
    COMMIT TRANSACTION
    My biggest problem seems to be that between the piece that updates Field1 as either Value4 or Value5 is that something is not right. I initially had this set up in MS Access, and so am using that as a comparison
    to check my final values once the field has been udpated. When I run in Access I get a total of 9,802 for Value6 and 14,107 for Value4, yet when I run the SQL code I get 19,548 for Value 6 and 4,478 for Value4.
    I also get some differences for the other values, but nowhere near as large of a difference as with the 2 values above. I feel fairly confident that I have something not quite right with my syntax, but I cannot
    figure out exactly what it is. Field1 at the beginning of the query is inserted into the table as a blank value.
    Thanks.

    Combining OR and AND may be tricky, so I think your problem lies here:
    UPDATE MyTable
    SET Field1 = 'Value4'
    WHERE Ord = '0' AND Cat = 'Hdw' OR Cat = 'Bnd' AND Field1 = '';
    You can change this to
    UPDATE MyTable
    SET Field1 = 'Value4'
    WHERE (Ord ='0' AND Cat IN ('Hdw','Bnd')) AND Field1 = '';
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • How can I allow the application to line through a field that has been locked after being digitally signed?  We have multiple sections on a form with some fields being proposed information and other in another section having the approved information. once

    How can I allow the application to line through a field that has been locked after being digitally signed?
    We have multiple sections on a form with some fields being proposed information and other in another section having the approved information. once the approved information is entered we line through the proposed field so the data entry clerk won't pick up the wrong information.  However we are receiving an error when attempting to enter data  in the field which we have this edit.  Error property: line through cannot be set because doing so would violate the document permission setting.  any idea how we can get around this issue?

    You can control which fields are locked down after signing by setting up a collection. Then those that are not locked can be changed after signing. If this is not possible, then the line outs must occur prior to signing.

  • FM / BAPI to update STEUC field in marc Table basing on material and plant

    Hi,
    I need to to update STEUC field in marc Table basing on material and plant. please suggest FM / BAPI.
    Thanks.
    raviraj.

    Hi
    Try this BAPI function module:
    " BAPI_MATERIAL_MAINTAINDATA_RT "
    Data: LS_HEADDATA TYPE BAPIE1MATHEAD,
             LS_RETURN TYPE BAPIRETURN1,
              LT_PLANT TYPE TABLE OF BAPIE1MARCRT,          LS_PLANT TYPE BAPIE1MARCRT,
              LS_PLANTX TYPE BAPIE1MARCRTX,          LT_PLANTX TYPE TABLE OF BAPIE1MARCRTX.
            CALL FUNCTION 'BAPI_MATERIAL_MAINTAINDATA_RT'
                   EXPORTING
                       HEADDATA   = LS_HEADDATA
                   IMPORTING
                       RETURN     = LS_RETURN
                   TABLES
                       PLANTDATA  = LT_PLANT
                       PLANTDATAX = LT_PLANTX.
    Check the PLANTDATA in the above fm in which pass your ''STEUC'' to BAPIE1MARCRT-CTRL_CODE......
    Hope this works.....

  • If I do not want to update some of them, how do I delete the notice.

    I have 21 updates for my apps.  If I do not want to update some of them, how do I delete the notice?

    Most of the apps being updated for the new iPad also contain bug fixes and in some cases new features. I go ahead and update. Having the latest version of an app is usually a good thing.

  • Start Routine in Update Rule

    I want to replace all '# ' values showing up in a report with  space. For this I plan to write a Start Routine in the Update Rules which should scan all the data coming in into the cube and replace all  null or '' with space.
    What is the best way to write this routine. It should check all data in all the fields of the data load coming in.
    Thanks

    Hi,
         The space is shown as # in the BW Reports, to confirm check the value in the cube for this field, so
          you need to change that to some other character like X or Y or explain your end users that SAP
          designates a space as # and it will be displayed that way in the reports.
    Regards,
    Raj

  • Help needed on start routines in update rules

    Hi All,
    I want to extract data from two data sources(For ex 2LIS_02_HDR, 2LIS_02_ITM).
    I am using 2 first layer ODS' and one second layer ODS for consolidation.I want to write a start routine in the update rules so that the data of the MATNR(Material Number) field from 2LIS_02_ITM will be populated in the second layer ODS when the keys (EBELN) of the datasources are equal in the first layer ODS'.
    Can anyone send me the code for this requirement?
    Thanks in Advance,
    Sanjana.

    i am assuming u have a direct transformation with 2lis_02_hdr
    and u want to look up on the DSO of 2lis_02_ITM to get the material.
    MATNR = 0material
    EBELN = 0docnum.
    put this code in the start routine of the transformation of 2lis_02_HDR.
    TYPES: BEGIN OF s_itm,
                material TYPE /bi0/oimaterial,
                docnum TYPE /bi0/oidocnum,
                END OF s_itm.
        DATA: wa_itm TYPE s_itm,
              t_itm TYPE STANDARD TABLE OF s_itm.
    LOOP AT DATA_PACKAGE.
            SELECT material
                          docnum
            FROM /bic/aDSO_itm
       APPENDING TABLE t_itm
       WHERE docnum = <comm_structure>-docnum.
    endloop.
    IF NOT t_itm[] IS INITIAL.
          SORT t_itm ASCENDING BY docnum.
         DELETE ADJACENT DUPLICATES FROM t_itm      COMPARING docnum.
         ENDIF.
    Now write this below code in the update routine of 0material in the transformation from 2lis_2_HDR.
    CLEAR RESULT.
    READ TABLE T_itm INTO WA_Itm WITH KEY
          DOCNUM  = comm_structure-docnum.
    BINARY SEARCH.
    IF SY-SUBRC = 0.
      RESULT = WA_itm-material.
    ENDIF.

  • Process: Start Routine, Delta, Update Rules

    Hi SDN,
    Can someone point to detailed discussion on the events related to loading, such as:
    Start Routine is exectued before each data package, or entire load?
    Update rules are applied row by row or the entire KYF column in a data package is processed first?
    When is delta determined, before Start Routine is executed, or, after it is executed, and before update rules are applied? This is important to know if we are dropping records from the data package.
    If you have the answers, would love to hear and appreciate.
    Thanks.
    Saf.
    P.S. I always award points.

    Thanks Farhan,
    If you don't mind, can you outline how delta is determined, between ODS and ODS and ODS and Infocube. If I am correct, records in the sender object are marked as sent. Can I look at the field where the flag is?
    Also, you are saying that only those records make up the data package which are new, in case of a delta load. That means, if there were no new records, Start Routine would not even execute, or it still will but do not have any records processed?
    I already awarded the points.
    Thanks.
    Saf.

  • Start routine for  Update Rules

    I need to write a start routine for the update rules for an DSO with main idea as follows:
    I must compare the record that comes from the infopackage with the record that's already in my DSO. If the X date for the same 0PM_ORDER is the same as one in my DSO - do nothing
    If the X date is previous to the X date in my DSO for the same 0PM_ORDER - the new record must be created and at the same time all the records with subsequent(later) X dates for this 0PM_ORDER must be deleted.
    If the X date is later than the X date in my DSO for the same 0PM_ORDER - the new record must be created.

    Hi,
    Find the below code.
    DATA: BEGIN OF ITAB1,
    ZDATE TYPE /BIC/DATE
    END OF ITAB1.
    SELECT zdate FROM /BI0/QEMPLOYEE INTO corresponding
    fields
    of ITAB1 where employee = SOURCE_FIELDS-EMPLOYEE.
    IF ITAB1-ZDATE COMMUNICATE_STRUCT-DATE
    RESULT = ITAB1-CLM_IPAA.
    ENDIF.
    ENDSELECT.
    There will be an table for each DSO if you go for an manage DSO you will get three table i.e New,Active and Change Log take Active tables date field and compare with the communication structure that comes to routine.
    The above example is just an example table will be different from DSO to DSO.
    Let me know your thoghts.
    Regards,
    Shivu.

  • How to debug start routines of update rules from ODS to InfoCube

    Dear gurus,
      I have an update rule from ODS to InfoCube. I wrote a start routine in the update rule. Now I want to debug it. I went to monitor and simulate update the data package and only got the prompt "No data exists in the corresponding PSA table". So how can I debug this start routine?
      Thanks in advance.
    Jin Ming

    Jin,
    In order to use PSA between ODS and InfoCube, you may have to use an exclusive InfoPackage and load separately. In that InfoPackage, choose the radio button to use a PSA.
    I think you are currently updating the InfoCube directly without using a separate InfoPackage.
    Look for an InfoSource under DataMarts (search for 8<ODS Technical name>) and create your InfoPackage there.
    Good luck.

  • ABAP Help at start routine of Update rule

    Good After Noon All,
    My requirement is that cube ZAPO_C24M  there’s an UPDR flowing from 8ZAPO_C24M back to itself so to speak.The request is to change the data in the cube from Fiscal Year Variant Z3 to Z4.
    But in start routine  i have to  take the existing record and reverse all of the key figures, and also change the RECORDMODE of the record to indicate it is a reversal record. This for specific Country KR and for these country the Fiscal variant is Z3. Again in the start routine, create a new record identical to the existing record that has Fiscal Year Variant Z4 instead of Z3.
    So the idea is we’d load from the cube and send back to the cube one record that reverses out the existing data, and another record that contains the same data but with Fiscal Variant Z4 instead of Z3.
    Please Help me.
    Points will be awarded for the right answer

    Hi Vaishali,
    In the start routine copy the DATA_PACKAGE to a local table.
    Select the records where the specific country is KR.
    Delete all other records.
    Then read the records in loop, Keep one record same and just change the fiscal year variant.
    And for the same multiply all the key figures by -1.
    Transfer the content of the local table back to DATA_PACKAGE.
    maintain one to one mapping in the update rule.
    I am sure it will update, but you need to be sure that if you change Fiscal year variant then probably your fiscal period value should change. In that case you have to update it accordingly in the start routine.
    Regards.

Maybe you are looking for

  • Iphone 4s no IMEI number even pressing the "i" button

    Hello guys, I just hope to have an answer to my almost a month of problem regarding my iphone 4s. first problem is does not showing the IMEI number after pressing the "i" button, which I find it  weird. This only the first problem, the second problem

  • Mac lags while running windows xp from bootcamp

    my system never uses over 400mb out of 1024mb of ram. anyone else experiencing this problem?

  • Photoshop CS3 in wine with awesomewm.

    This has been happening for a while, and it's rather annoying. Every time I hover something, it moves like 3 pixes to the right and down. This includes the workspace window, the toolox, and all other windows (Character, Color palette, etc). I've sear

  • Repeatedly loading a page....

    how can we block someone from reloading a page thousands of times as a denial of service attack? we have wls 5.1 sp8. basically, if you load a jsp, and hold down f5 in IE, it will reload it hundreds of times, killing performance. I noticed that most

  • How to add 'Do Not Reply' in MacMail OSX Mountain Lion

    For security purposes with some of my e-mails, I do not want respondents to 'Reply'. I have noted this indication from other correspondents especially Apple and Microsoft. I have not been able to find this feature in MacMail Version 6.6 Preferences.