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.

Similar Messages

  • 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

  • Update rule problem for date in Prod

    My scenario is like this:-
    ODS 2 is loaded from ODS 1, in ODS 1 there is a data field calendar day (DATS, time characteristic) and there is a data field posting date (DATS, characteristic) in ODS 2. In the update rule, the posting date is updated from calendar day by a formula source. 
    The problem is the posting date data field is updated into ODS 2 correctly in development box but it is not updated (blank) in production box.  I can't figure out what is the cause, hopefully someone can give me some help.  Thanks.
    Cheers!
    Cecil

    The only different is the development system is having this part of code in the update rules program compare to production system.  Do I need to compile the update rules formula manually?
    *This ABAP Code was generated automatically          *
    *Formula Calculator                                  *
    *Generated :2008:09:12-10:47
    *User: XXX
    *Calculation:
    result = COMM_STRUCTURE-CALDAY.
      ENDCATCH.
      if sy-subrc <> 0.
        perform error_message using 'RSAU' 'E' '507'
                'ROUTINE_0004' g_s_is-recno
                rs_c_false rs_c_false g_s_is-recno
                changing c_abort.
      endif.
    Cheers!

  • Regarding sample code to update partner function using SD_PARTNER_UPDATE

    Hi All,
    Please provide some sample code to update/add partner function using FM 'SD_PARTNER_UPDATE'.
    regards
    Vishnu

    A better option would be to use a break point on this FM while creating a sales order. That way you will know how standard uses this FM.
    Thanks,
    Vikram.M

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

  • Simple creation of Update Rule from BW Data Source

    Hi guys,
       Pertaining standard SAP Business Content extractors
       I am referring to <b>InfoCube : 0PA_C01(Headcount and Personnel Actions)</b>
       I am attempting to<u> create </u>an <b>Update Rule</b> from <b>Info Source : 0HR_PA_PA_1(Headcount)</b>
       This <b>Info Source : 0HR_PA_PA_1(Headcount)</b> is connected to <b>BW Data Source</b>(Not R/3!) 0HR_PA_PA_1
       I have created an Info Package for this Info Source and managed to get 15 records{In Contrast to my 68800 Records from Info Source : 0HR_PA_0(Employee)}
       So, when I create an Update Rule to Connect <b>Info Cube: 0PA_C01(Headcount and Personnel Actions)</b> to <b>Info Source to Info Source : 0HR_PA_PA_1(Headcount)</b>, I get the following error
    ERROR : <b>IC=0PA_C01 IS=0HR_PA_PA_1 error when checking the update rules</b>
      Could you please also advice, why do I only get 15 records for Data Source 0HR_PA_PA_1 ?
      P/S : I am on BW 3.5

    Hey Rohini,
       This <b>Data Source: 0HR_PA_PA_1(Headcount)</b> is tricky to me because it`s a BW Data Source.
       Exact Error Message is as follows :-
      "<b>Error Message : RSAU461
        IC=0PA_C01 IS=0HR_PA_PA_1 error when checking the update rules</b> "
       My Exact Problem is that I don`t see any values for the following fields in my Info Cube : 0PA_C01(Headcount and Personnel Actions)
      Country;
      Country Code;
      Gender;
      Nationality;
      Language;
      Postal Code;
      Region;
      Position;
      Job;
      Payroll Area;
      Payroll Group;
      Pay Scale's;
      Pay Grade's
      This is because, this information is supplied by InfoSource : 0HR_PA_PA_1
      But I don`t have an Update Rule for this InfoSource in my InfoCube : 0PA_C01
      So, that's why I am attempting to create this additional Update Rule
    <i>  And also, could someone enlighten me why would SAP not include such a standard Update Rule when they have already idenfied those needed fields in a Cube ? This is suppose to be a STANDARD workable Business Content right ?</i>
      P/S: I have applied Note : 336229

  • Update rule on master data attribute

    Hi
    In my cube, I have a master data object  0COMP_CODE, which has attribute 0COMPANY.
    Additionally, in the same cube, there's:
    Master data object 0CUST_GROUP, which has attribute ZBUSPART
    Master data object 0CO_AREA, which also has attribute ZBUSPART
    I need to fill a characteristic ZTAXCODE (not a master data object) in the cube, with the following logic:
    If 0COMPANY is between 1 and 30, populate ZTAXCODE with value of ZBUSPART from 0CUST_GROUP
    If 0COMPANY is between 31-9999999, populate ZTAXCODE with value of ZBUS_PART from 0CO_AREA
    I guess this will have to be done in the update rule.  Right now I have 0COMP_CODE in the communication structure. How should the code be written to populate ZTAXCODE, with value of ZBUSPART, based on the value of the attribute of 0COMP_CODE - 0COMPANY?
    Any help with getting me started here would be appreciated...
    Thanks
    Marty

    In the start routine.
    First, for all data package select company code, cust_group and zbuspart from cust_group and store it in the internal table.
    Second for all data package select company code, co_area and zbuspart  from co_area and store it in the second internal table.
    Third for all data package select company and company code from comp_code and store it in the third internal table.
    Now in the update rule routine.
    read the third table and get the company for the company code and if the value which comes from this company is between 31 and 9999999 then read from second internal table otherwise read from the first internal table and update the result.
    hope that is clear.
    thanks.
    Wond

  • Update rule problem - while data load

    Hi friends,
    I got the following error while doing initialisation for 2lis_02_sgr.
    "ABORT was set in the customer routine 9998
    Error 1 in the update "
    In the forum i searched for this error and this error is something related to the start routine in my update rule.
    But i dont know whats wrong with my routine.
    Im giving the start routine below,pls go through this and give me your suggestions..
    PROGRAM UPDATE_ROUTINE.
    $$ begin of global - insert your declaration only below this line  -
    TABLES: ...
    <i>TABLES /bic/AZMM_PUR100 .
    DATA:  T_PUR1 LIKE /bic/AZMM_PUR100 OCCURS 0 WITH HEADER LINE.</i>
    $$ 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/CS2LIS_02_SGR.
    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
    if abort is not equal zero, the update process will be canceled
      CLEAR: T_PUR1[] ,
             T_PUR1,
             ABORT.
      SELECT * INTO TABLE T_PUR1 FROM /bic/AZMM_PUR100.
      IF SY-SUBRC EQ 0.
        SORT T_PUR1 BY DOC_DATE
                       DOC_ITEM
                        DOC_NUM.
      ELSE.
        MONITOR-msgid = sy-msgid.
        MONITOR-msgty = sy-msgty.
        MONITOR-msgno = sy-msgno.
        MONITOR-msgv1 = sy-msgv1.
        MONITOR-msgv2 = sy-msgv2.
        MONITOR-msgv3 = sy-msgv3.
        MONITOR-msgv4 = sy-msgv4.
        append MONITOR.
      if abort is not equal zero, the update process will be canceled
             ABORT = 1.
      ENDIF.
       ABORT = 0.
    $$ end of routine - insert your code only before this line         -
    ENDFORM.
    Thanks & Regards
    Ragu

    thanks gimmo and a.h.p,
    i have done the correction as you said,pls verify that.
    And also kindly explain me what is the reason for this start routine,what exactly it does???
    CLEAR: T_PUR1[] ,
             T_PUR1,
             ABORT.
      SELECT * INTO TABLE T_PUR1 FROM /bic/AZMM_PUR100.
      IF SY-SUBRC EQ 0.
        SORT T_PUR1 BY DOC_DATE
                       DOC_ITEM
                        DOC_NUM.
    abort = 0.    (  added  abort = 0 as per your suggestion )
      ELSE.
        MONITOR-msgid = sy-msgid.
        MONITOR-msgty = sy-msgty.
        MONITOR-msgno = sy-msgno.
        MONITOR-msgv1 = sy-msgv1.
        MONITOR-msgv2 = sy-msgv2.
        MONITOR-msgv3 = sy-msgv3.
        MONITOR-msgv4 = sy-msgv4.
        append MONITOR.
      if abort is not equal zero, the update process will be canceled
             ABORT = 1.
    exit. ( added exit as per your suggestion )
      ENDIF.
       ABORT = 0.
    $$ end of routine - insert your code only before this line         -
    ENDFORM.
    Thanks & Regards
    ragu

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

  • Code in update rule

    Hi Guru's
    Can anyone explain in detail the meaning of the code blow in update rule.
    <b>tmpwk TYPE /bic/cs8ismactp-calweek,
    botwk TYPE /bic/cs8ismactp-calweek,
          first_rec VALUE 'T',
          var_maxline TYPE i,
          var_country(2) TYPE c,
          ret_code TYPE i,
          out_value TYPE /bic/cs8ismactp-/bic/g_pivpri.</b>
    Thanks in Advance
    Regards
    K Kumar

    Hi Sam,
    the code is below
    <b>result value of the routine
      IF COMM_STRUCTURE-/BIC/G_NOFAC = COMM_STRUCTURE-/BIC/G_RENOF.
        RESULT = 1.
      ELSE.
        RESULT = 0.
      ENDIF.
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.</b>
    Regards
    Venkat

  • Unable to map Update Rule with u201CMaster data attribu201D option

    Hi,
    Does anybody know the reason why sometimes, in update rules to an ODS, I cannot map an InfoObject with the option u201CMaster data attribu201D?
    I have the characteristic in the ODS, and for another update rule, to the same ODS, I am able to map this field correctly, but for a specific rule, the u201CMaster data attribu201D field appears in blank when I press F4.
    Strange this behaviouru2026
    Can anybody help me with this issue?
    Thanks,
    Best Regards,
    Joana

    Hi  Shanthi,
    I didn't insert the InfoObject as an InfoProvider.
    The problem is that I have two update rules for the same ODS object. For one I can map the characteristic correctly, and for the other, when I press F4 in the "Master Data Attrib", no characteristics appear.
    Thanks,
    Joana

  • 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

  • Program to activate update rule for master data (info objects)..very urgent

    Hi all,
    I have an info provider(A0CUSTOMN). For this the update rules are not active.In production system i am not able activate.Please let me know if there is any program to activate the update rule for masterdata(info object).
    Thanks=points
    Manjula

    Hi Manjula,
    Leave the id and infocube field blank.  Just provide the infosource name.
    BTW is this a direct update master data object?  In that case all this is not relevant.
    Check if it appears as an Infoprovider. 
    I did not ask enough questions to start with.
    BR/
    Mathew.

  • Updating the Leave Information (dates selected) from MSOutlook to SAP ESS

    Hi Forum,
                    I had a scenario where I need to use Microsoft Outlook as an interface and the leave information selected in outlook calender should be updated to SAP ESS. Does Any one worked on similar kind of scenarios ? I would like to know if any API is available to interface between MS Outlook and SAP. If not is there any 3rd part integration technologies available ? Helpful answers will be Appriciated in the SDN way
    Regards
    Ramesh

    Hi Manoj,
                   Thanks for your reply. I am looking for a Java API using which i can read the calender information in outlook (dates selected and saved by the user). If I can get this dates information i could think of updating the same dates (leave info) to SAP ESS usingn JCO Client java program.
    Please suggest me some java API to read the calender information stored in outlook.
    Thanks & Regards
    Ramesh

  • Update Rule Error ( Invalid Data) while load 0VENDOR

    Hello All,
    I have attributes like  0POSTAL_CD of 10 Char (Postal Code) and 0SORTL 0f 10 Char (Sort Field) of Vendor. From yesterday onwards the Production master data loads for 0VENDOR started failing saying:
    Record 211 :0POSTALCODE : Data record 211 ('03 2VEN4000040 '): Version 'HK HONG KONG ' is not valid
    Record 136 :0SORTL : Data record 136 ('0002000175 '): Version 'SATTLER, I ' is not valid
    Solutions tried:
    Interstingly what we found is: when u edit the PSA data for the above records and again input the same values, the load runs fine.
    I found  this thread some what relating to my problem, but I could'nt get the solution.
    Please help to solve this issue which I am facing alone....... Thanks for your support

    Hi Ram,
    Really add more valid char is a possible option, but in your case I dont believe that was a good idea...
    I believe that this msg is an automatic master data validation.
    Ex:
    0SORT:  is not valid use comma ( , ) or sapce in this field
    0POSTALCODE: the value  'HK HONG KONG '  dont seems to be a correct value for a zip code
    I belive that this validation is not about allowed extra-char
    Check both InoObject and see wich datatype support.
    Hope this Help!

Maybe you are looking for

  • Additional Files in Sender File Adapter

    Hi I have to collect 2 files (IN.txt, IS.txt) and attach 2 files as an attachment to mail. So I opted Additional Files in Sender File Adapter Source Directory = D:\usr\sap\pitest\LoadTest\Output\Invoice File Name = IN.TXT Additional Files File List <

  • LR4 Unable to Process Some Images into CS3

    I am running LR4 on Windows Vista. When processing images I first work in LR and then move them into CS3 for any final touches and final processing. Recently, when I attempt to move an image from LR4 to CS3, I get a message saying "LR was unable to p

  • Error during XML = ABAP conversion

    Hi   We have a synchronous call from a SRM application through a proxy framework to a vendor http server through XI. The response from the vendor's http server is returned through a custom structure -and is returned through XI back to the calling SRM

  • Mavericks running slow

    I have a early 2011 MacBook Pro 17", 2.2 GHz i7, 16gb RAM, and I have installed Mavericks OS. After the upgrade, I find that my Mac is running pretty sluggish and slow, definitely not your typical Apple product. While view my photos through Finder, I

  • Is there any possible way to add speech bubbles on iMovie?

    I'm trying to make a stop-motion but I need speech bubbles.