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

Similar Messages

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

  • ABAP porgram in update rule-Job stats

    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 Shravani,
    try using this code.. ths is done as a report, you will have to change the fields.
    **get the first 4 chars of the date. date is stored as YYYYMMDD format internally. check with the system year. sy-datum has the system date
    if comm_structure-stat_date+0(4) = sy-datum+0(4).
    **get the month i.e the 5 and 6th characters from the date and compare them
    if comm_structure-stat_date+4(2) > sy-datum+4(2).
      result = 0.
    **ELSE. .... you havent mentioned what u want to do if the month is lesser or equal to the system month
    endif.
    else.
    **Get the first 6 chars of the statistical date.. i.e the year and month.
      result = comm_structure-stat_date+0(6).
    endif.
    Regards
    Sujai

  • ABAP Help on Update Rule Needed

    Hello.  I am trying to write a routine on an key figure in an update rule.  Basically, I am trying to load a custom key figure with either a 1 or a 0. 
    Here is the pseudocode:
    IF
    (((GI_DATE - ACT_GI_DTE) < 0) OR
      ((GI_DATE - ACT_GI_DTE) > 3)
    THEN
        NEW_KEY_FIGURE = 1
    ELSE
        NEW_KEY_FIGURE = 0
    ENDIF.
    Here is the code I currently have in the routine.  Any ideas on where I am going wrong here?  I am not an ABAP developer so please keep this in mind when responding.
    result value of the routine
      CLEAR RESULT.
    if the returncode is not equal zero, the result will not be updated
      IF COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE < 0 OR
         COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE > 3.
         COMM_STRUCTURE-NEW_KEY_FIGURE = 1.
      ELSE.
         COMM_STRUCTURE-NEW_KEY_FIGURE = 0.
      ENDIF.
      RESULT = COMM_STRUCTURE-NEW_KEY_FIGURE.
      RETURNCODE = 0.
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    Thanks for any help you can give.

    Hi,
    I think you can not put "-" in if command, so code should be like this:
    data: datediff type n.
    result value of the routine
    CLEAR RESULT.
    clear datediff.
    detediff = COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE.
    IF datediff < 0 OR datediff > 3.
    Result = 1.
    ELSE.
    Result = 0.
    ENDIF.
    RETURNCODE = 0.
    if abort is not equal zero, the update process will be canceled
    ABORT = 0.
    Regards,
    Andrzej

  • Urgent: ABAP routine in transfer rules

    Hi,
    when i am loading master data from R/3 into BW, i need to filter some records based on material type. there is no option in RSA6 (on R/3) or in Infopackage (BW) to make it available for filter.
    So i assume i need to write ABAP routine in transfer rules. can some one help me with ABAP. i need to load the records only when MTART field(material type) in MARA is "FINI" or "RAW" and skip other records.
    what is difference between deleting the whole data packet and deleting the record.
    Thank you very much in advance
    Regards
    Emil

    Hi
    Write the below code in the start routine of your transfer rules.
    Regards
    Prakash
    DATA: IT_DATA        TYPE STANDARD TABLE OF TRANSFER_STRUCTURE
                         WITH HEADER LINE
                         WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
    DATA: S_DATA, T_DATA TYPE TRANSFER_STRUCTURE.
    LOOP AT DATAPAK INTO S_DATA.
    IF S_DATA-MTART EQ 'A' OR S_DATA-MTART EQ 'B'.
    MOVE S_DATA TO T_DATA.
    DELETE S_DATA.
    ELSE.
    DELETE S_DATA.
    ENDIF.
    APPEND T_DATA TO IT_DATA.
    ENDLOOP.
    CLEAR T_DATA.
    DATAPAK[] = IT_DATA[].
    Assigning points is a way of saying thanks on SDN!!

  • Advice on abap routine in update rule

    Hello Experts,
    I have written a routine in update for replacing some 'not allowed characters' with space.
    The abap code is correctly working as a standalone program as is giving the correct results.However,
    when i write the same code in update routine, no change takes place in data, i.e. 'not allowed characters ' are still there in my data.
    Please advice if there is any special change that is to be made while writing the code in update routine.
    if STRLEN( CHECK_TEXT ) <> 0.
        ALLOWED_SPECIAL_CHARACTERS = ' &()*+,-.:;<>=?!@$%~'.
        ALLOWED_CHARACTERS = 'ABCDEFGHIJKLNMOPQRSTUVWXYZ_0123456789'.
          TRANSLATE CHECK_TEXT TO UPPER CASE.
        strl = strlen( CHECK_TEXT ).
        IF CHECK_TEXT CN ALLOWED_CHARACTERS.
           WHILE len1 LE strl.
            IF CHECK_TEXT+len1(1) CN ALLOWED_CHARACTERS.
            CHECK_TEXT+len1(1) = '.'.
             ENDIF.
           add 1 to len1.
          ENDWHILE.
        ENDIF.
    Regards
    Priyanka

    Thanx a lot for a quick reply .
    The main problem that we are facing is this simple code is working fine if it is executed as a report program but if no changes takes place when i move this same code to my update routine.
    (1) According to you i should write this routine in the start routine instead of update rotuine ??
    (2) how would function module help in my case...kindly elaborate a it.
    Here is the complete update rotuine.
    data:
    len1 TYPE i value 0
    R_TEXT(60),
    CHECK_TEXT(60),
    R_TEXT = COMM_STRUCTURE-/BIC/ZC_NTXT1.
    if STRLEN( R_TEXT ) <> 0.
      ALLOWED_SPECIAL_CHARACTERS = ' &()*+,-.:;<>=?!@$%~'.
      CONCATENATE 'ABCDEFGHIJKLNMOPQRSTUVWXYZ_0123456789/'
                  ALLOWED_SPECIAL_CHARACTERS
                  INTO ALLOWED_CHARACTERS.
      CHECK_TEXT = R_TEXT.
      TRANSLATE CHECK_TEXT TO UPPER CASE.
      strl = strlen( R_TEXT ).
    IF CHECK_TEXT CN ALLOWED_CHARACTERS.
          WHILE len1 LE strl.
          subs2 = CHECK_TEXT+len1(1).
            IF subs2 CN ALLOWED_CHARACTERS.
            CHECK_TEXT+len1(1) = '.'.
             ENDIF.
            ENDWHILE.
    endif.
        ENDIF.
    RESULT = CHECK_TEXT.

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

  • ABAP code for calculation rule in transaction M/08

    Hi,
    In M/08 transaction, we need to do this:
    When maintaining a PO, the user manually creates a condition like this:
    ZXXX Value (+10 %) positive value.
    However, in order to get the belonging negative condition (for accounting purpose), we need to automatically create that when the one above has been created:
    Automatic at the same time:
    ZYYY Value (- 10 %) negative value.
    In transaction M/08 you can enter ABAP code to each condition in the calculation rule. How can I program that ZYYY is created at the same time as ZXXX, when created for a PO ?
    Any help is appreciated.

    Hi Peter,
    This calculations rules are know as routines you can create with them using T code VOFM and then go the menu option -
    > Formula---->Condition value.Double click on that and you will get the ABAP code.
    Here you can amend the existing one or can create the way you like your logic to move and assign it to M/08 T code.
    Hope this will help you.
    Thanks,
    Birender Agnihotri

  • ABAP code for calculation rule in TK = M/08

    Hi,
    In M/08 transaction, we need the following:
    When maintaining a PO, the user manually creates a condition like this:
    ZXXX    Value (+10 %) positive value.
    However, in order to get the belonging negative condition (for accounting purpose), we need to automatically create that when the one above has been created:
    Automatic at the same time:
    ZYYY  Value (- 10 %) negative value.
    In transaction M/08 you can enter ABAP code to each condition in the calculation rule. How can I program that ZYYY is created at the same time as ZXXX, when created for a PO ?
    Any help is appreciated.

    Irrelevant

  • 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

  • Urgent: ABAP Code help reqd

    Hi,
    Can anyone please me provide me ABAP code for the following case:
    Table1 – JHAGA
    Table2 – JHAGVZ
    Primary keys in JHAGA:
    Order Item Number [POS_NR]
    Billing Dataset [GRUPPABRNR]
    Sales Document Number [AVM_NR]
    This requirement is for an InfoSet. For each order ideally we can have multiple sales agent. Sales Agent is being pulled from JHAGVZ. For this InfoSet we are going to go with assumption that we wont have more then 10 sales agent for an order,
    Consider 10 extra fields in InfoSet SA1 – SA10 for 10 Sales Agent.
    I need code which to populate this sales agent field. If an order exists in JHAGA then for that order in JHAGVZ populate the SA1-SA10 field.
    JHAGA – Order#10
    JHAGVZ – Order#10 – SalesAgent11
                   SalesAgent12
                   SalesAgent13
    Then SA1 should have SalesAgent11, SA2 should have SalesAgent12 and SA3 should have SalesAgent13 and so on…     
    Thank you,
    sam

    HI ,
    Are these two field a part of the table INFOROBJECT?
    if they are, you can write a select statement like :
    select 0CUSTOMER 0SALESORG YLEG_ENTITY
           from INFOROBJECT
           into Y_CUST_LE
           where ( Yacc_SEQ <> ´ZROO´  and
                   0PRICE_LIST <> space).
    Hope this helps.
    If not, please explain problem clearly.

  • Defining ABAP variables in update rules

    Hello,
    How can I define a variable in ABAP of the same type as an InfoObject? I know it's easy as long as the InfoObject is a part of the communication structure. But this InfoObject is not present neither in the source ODS nor in the target cube. It is a custom InfoObject, not BC.
    Regards,
    Christoffer Owe

    Hello,
    I have not succeeded with that. Trying
    DATA: TmpYearWeek LIKE /BIC/ZWKCLSDT.
    where ZWKCLSDT is my InfoObject, results in
    "E:Field "/BIC/ZWKCLSDT" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement."
    Regards,
    Christoffer

  • Update Rule Routine: Compare system date

    Can anyone help me with regards to writing some ABAP code in update rule?
    I would like to check if the value of a date characteristics is equal to system date in data source. If its value is equal to system date, assign '0' value to another numeric characteristics. Otherwise, it will get the difference between system date and the date characteristics. I have rewritten the routine as follows. But there is no effects on the result. Am I correct?
    if COMM_STRUCTURE-<date characteristics> = SYST-DATUM.
      RESULT = '0'.
    else.
      RESULT = COMM_STRUCTURE-<numeric characteristics>.
    endif.
    Many thanks in advance.

    I have rewritten the code as follows. ZLASTPURD is a numeric characteristics. The code is written in the routine of ZLASTPURD in update rule. But it takes no effect. The case "COMM_STRUCTURE-/BIC/ZLASTPURD ='0'" means another date characteristics is equal to system date, the value of ZLASTPURD is blank after modifying the code. However, the code is workable for  "RESULT = COMM_STRUCTURE-/BIC/ZLASTPURD.". Is there anything wrong?
    data lastpurdays type I.
    lastpurdays = '1'.
    if COMM_STRUCTURE-/BIC/ZLASTPURD = '0'.
      RESULT = lastpurdays.
    else.
      RESULT = COMM_STRUCTURE-/BIC/ZLASTPURD.
    endif.
    Many thanks in advance.

  • How to write ABAP Routeines in Update/Transfer Rules ?

    Hi Experts,
    Iam new to BW and i don't have ABAP knowledge.Can any body help me ..to write ABAP Routeines in Update rules/Transfer rules.Give me some basic knowledge with proper example.and what type of routeines we need to write ?
    I will appreciate if some one helps me with proper Documentation.My mail id is [email protected]
    Points will be rewarded.
    Thanks in advance,
    Nayanasri.

    Hi Nayanasri,
    It is not mendatory that u need to write Update routines for all update rules. It depends on the requirement. Without update routine u can always manage. My last implementation was for a small chemical firm where i did not use any of the update routine. Suppose if u want to change the records in datapackage depending on certain conditions, then u can go for this. I'm just pasting one of my update routine program
    PROGRAM UPDATE_ROUTINE.
    $$ begin of global - insert your declaration only below this line  -
    TABLES: ...
    DATA:   ...
    $$ 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/CS8YGTGDCL6B.
    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 /bic/yverbr NE  'V2'.
    DELETE DATA_PACKAGE WHERE /bic/ydpbasfs = 0 AND /bic/yoplqty = 0.
    ENDFORM.
    Where the delete statement deletes the records when the field /bic/yverbr noe equals to 'V2' or deletes it when /bic/ydpbasfs equals zero.
    If the explanation is not suffecient, pls post further
    Regards
    Sriram

Maybe you are looking for

  • Looking for windows Virtual Iron 4.3.8

    we are trying to get caught up to the current version but need to upgrade to 4.3.8 before we can upgrade to 4.5.16. We have the 4.5 installer but we are unable to locate the 4.3. Does anybody have an archive copy of this that we could use? Any upgrad

  • Fault in autentication wit x509 certificate

    I am configuration a webservice in oc4j using jdeveloper. Using x509. import the client key in server keystore; when execute the client show: WARNING: Subject Key ID extension not found.Using BST Referencing scheme javax.xml.rpc.soap.SOAPFaultExcepti

  • My BEFWS114 v4 is messed up...

    I don't know what's wrong with it, but it's no longer recieving an IP from the modem that is plugging into it.  But I know that my modem is fine because works just fine plugging it right in.  Any ideas?

  • Epson scan documents but cant select area!

    Epson Stylus CX5500 Snow Leopard latest 10.6.1 I can scan some pages but but some pages the software that comes with snow leopard selects an area and only scans that. I turned off detect area and makes no difference. If I go to the show details page

  • Trouble launching iTune.

    Hi everyone, I have recently downloaded iTune 8 but failed to launched the program. Don't know why, I have tried reading the troubleshooting site but did not help me. Can anyone kindly guide me through the process of fixing it. I am currently running