ABAP code (Update rule)

Hi Gurus,
I need to load data from R/3 to infocube A. In update rule  I need to do a small calculation that is A.KF1  x  B.KF1  =  A.ZKF1. B.KF1 is a key figure in Infocube B. In update rule I need to read Infocube B and get B.KF1 and multiply with A.KF1(Infocube A) to fill the value in A.ZKF1. Please help me how to write ABAP code to do this calculation.
Thanks
Liza

Liza,
Check whether the function module RSDPL_CUBE_DATA_READ which will help  to read data from cube B.
I guess, APD will be useful for your scenario.
Thanks
Viswa

Similar Messages

  • ABAP in update rule

    I have one code in the start routine of the update rule which i have copied below .Just to fetch 96000 record , the system is getting hanged.
    select
          /bic/zemployee
          /bic/zevent
          /bic/zmatlsamp
          material
          /bic/zcustomer
          postal_cd
          time
          into table t_seq_ind
          from /bic/azfw_o0200
            for all entries in t_cardnum
            where /bic/zemployee = t_cardnum-/bic/zemployee.
    t_cardnum is an internal table  & /bic/azfw_o0200 is an oDS table which have only 96000 records.How to increase the performance for this query
    Reagdrs,
    Anita

    Hi,
    No need to use that FM. You can create it from the EDIT screen only.
    Refer the link:
    Re: How to create Secondary Index?
    Re: ODS secondary index creation
    With rgds,
    Anil Kumar Sharma .P

  • ABAP in Update rules

    I have an item level ODS object which contains records like this:
    Header
       Item 1
       Item 2
    The header record contains the header status and the items contain the item status.
    I want to add an infoobject to the ODS to hold the header status at item level too.
    I am thinking that the best thing to do would be to modify the update rules to get the header status from the header record rather than modifying the datasource as I already have the data.
    Problem is I am not an ABAPer, can anybody help me with how I can retrieve the header record in the update rules?

    hi Stuart,
    my suggestion is do this in crm side, in user exit zxrsau01
    data : l_s_comp like [0crm_complaints_i extract structure],
           l_tabix like sy-tabix.
    case i_datasource.
    when '0crm_complaints_i'
          l_tabix = sy-tabix.
    if item, item guid not blank
          if not l_s_comp-item_guid is initial.
    look from header data, from crmd_orderadm_h ?
          select [headerstatus] into l_headerstatus
          from crmd_orderadm_h.      
            if sy-subrc = 0.
              l_s_comp-[header status] = l_headerstatus
            endif.
          endif. 
          modify c_t_data from l_s_comp index l_tabix.
    endcase.

  • Find break-points source code (update rules, transfer rules)

    Hi all,
    Is there any effective and efficient way to find (active) break-points in source code, more specfic update rules, transfer rules or other objects where custom code is implemented? Or in other words look for strings in source code or programs.
    I looked and searched everywhere but could not find any answer.
    RSRSCAN1 (does not work)
    RPR_ABAP_SOURCE_SCAN (does not exist)
    We are on SAP BW 3.5 with SAP Basis 640.
    Thanks all.

    Hi,
    Try this
    1)  if you're checking any program from SE38 ..goto Utilities -> find in the source code-> give breakpoint and search.
    2) else. load data , Goto details tab in the monitor and right click on any of the data packages.
    Simulate update -> choose transfer rules or update rules for debuging.-> It will take you debuging screen. -> Create a watch point with key word "break-point" and execute (F8).
    It will go and stop where there is  "break-point"

  • 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

  • Abap Code help in update rule

    Hi Gurus,
    I have  a requiement, that is if there are 5 line items with in a document and each one has diffeerent tax jurisdiction code, then we should be showing only one tax jurisdiction code for a document. Line items are not displayed in report. The condition to pick up tax jurisdiction code is the one which has least ending zeros among all the lime items with in a document.
    Supppose
    Doc1 Item Tax Jurisdiction code
    1800000002 1 CNQC00000000000
    1800000002 2 CNQC00000000000
    1800000002 3 CN0000000000000
    1800000002 4 CNQC00000000000
    1800000002 5 TXJOHNCLEBUR000
    So here the value of Tax Jurisdiction code is TXJOHNCLEBUR000 as it has least ending zeros compared to other values with in a document.
    Any help how to use the string function and acheive the desired result.
    Thanks,
    Raj.

    Hi Anand,
    Thanks for the reply. we don't expect any non-zeros after seeing first zero. Now i have added another z object which will contain only least zeros for a doc. What I am doing is now after loading the data into the cube from ods  i am doing loop back and updating the new z object. Below is the code I am trying to do
    TABLES: /BIC/AZFGLO10100.
    Defining an internal table as ods table****
    Types: BEGIN OF ITAB_01,
    doc_no LIKE /BIC/AZFGLO10100-AC_DOC_NO,
    item_no LIKE /BIC/AZFGLO10100-ITEM_NUM,
    taxjur LIKE /BIC/AZFGLO10100-TAXJURCODE,
    length like num,  ***** this will hold the length of the zeros
    END OF ITAB_01.
    loading the data from active ods table into defined internal table*****
    select AC_DOC_NO ITEM_NUM TAXJURCODE  from /BIC/AZFGLO10100 into table
      Itab_01 where AC_DOC_NO = /BIC/AZFGLO10100-AC_DOC_NO and
      item_num = /BIC/AZFGLO10100-ITEM_NUM.
    sort itab_01 doc_no item_no
    now I want to use code too populate the vlaue of length field in internal table (which shows how many zeros a tax jurisdiction code has for every corresponding line item)
    then in the update rule of z tax jurisdiction i will wirte a routine such that
    select taxjur into result from itab_01 where doc_no = COMM_STRUCTURE-doc_no and length = min(length).
    now I have one more doubt , the number of items in a document will be varying so how to takecare of this...
    If possible can you please provide me with the abap code that you have mentioned in earlier post.
    Any more help on this is really appreciated.
    Thanks,
    Raj

  • 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 Routine - ABAP code

    Hi,
    I am trying to write an update routine to calculate and populate fields in my ODS infoprovider.
    one of the key figure field in my update rules is 'No. of Days'. Based on the 'No. of Days' range, I want to send a key figure(Infoobject:Due amount) value to another infoobject(Bucket1, Bucket2, Bucket3 ect.)in my ODS infoprovider. For example, let's say,
    IF NO. OF DAYS = >0 AND <=30
       THEN TAKE THE DUE AMOUNT PUT IN BUCKET1
    ENDIF.
    ELSE IF
       NO. OF DAYS = >31 AND <=60
       THEN TAKE THE DUE AMOUNT PUT IN BUCKET2
    ENDIF.
    ELSE IF
       NO. OF DAYS = >61 AND <=90
       THEN TAKE THE DUE AMOUNT PUT IN BUCKET3
    ENDIF.
    I think, I know the data flow logic but I don't know how to code in ABAP language. If someone can give me some psuedo like ABAP code, I would appreciate your help with points.

    Hi Roa,
    I would do this in the start routine of the update rule.
    Here is a sample on how do this. You could use a case statement for this code also.
    Loop at Data_Packet.
    IF NO. OF DAYS = >0 AND <=30
    Data_Packet-BUCKET1 = DUE AMOUNT
    ELSEIF
    NO. OF DAYS = >31 AND <=60
    Data_Packet-BUCKET2 = DUE AMOUNT
    ENDIF.
    ELSEIF
    NO. OF DAYS = >61 AND <=90
    Data_Packet-BUCKET3 = DUE AMOUNT
    ENDIF.
    modify data_packet.
    endlloop.
    Cheers! Bill

  • 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

  • ABAP assistance - start routine logic in update rule

    I have used an existing update rule and have based my logic around the same.  The purpose of the rule is to look up customer master data and get a subset of customer numbers from the transaction records so that the values for customer number from the transactional data will not be updated if it does not match with existing master data customer numbers.
    The loads are full and we drop the data before we load.
    I have listed the logic below (the number at the front is to be considered as the line number) and a list of open questions that I have thereafter:
    Start routine logic:
    1  DATA: l_index LIKE sy-tabix.
    2  DATA: BEGIN OF ls_customer,
    3        customer TYPE /BI0/OICUSTOMER,
    4        objver TYPE RSOBJVERS,
    5     END OF ls_customer,
    6      lt_customer LIKE TABLE OF ls_customer.
    7  REFRESH: lt_customer.
    8  LOOP AT DATA_PACKAGE.
    all customers from data package
    9    ls_customer-custno = DATA_PACKAGE-custid.
    10  ls_customer-objver = 'A'
    11    APPEND ls_customer TO lt_customer.
    12   ENDLOOP.
    12  SORT lt_customer.
    13  DELETE ADJACENT DUPLICATES FROM lt_customer.
    14   IF NOT lt_customer[] IS INITIAL.
    15    SELECT /BI0/OICUSTOMER RSOBJVERS
    16      FROM /BI0/PCUSTOMER
    17      INTO CORRESPONDING FIELDS OF TABLE lt_customer
    18      FOR ALL ENTRIES IN lt_customer
    19      WHERE ls_customer-custno = DATA_PACKAGE-custid
    20      AND ls_customer-objver = 'A'
    21    SORT lt_customer BY customer ASCENDING                    
    22  ENDIF.
    Questions
    Line
    1 - what is the purpose of this line? What is it that is being declared
    2 - in some code I have seen this line with OCCURS 0 at the end what does this mean with and without the term?
    4 - I am using the Data Element name is this correct or should I use the field name?
    3 - 5 here I declare an internal structure/table is that correct?
    6 - here I declare a work area based on the internal table is that correct?
    7 - What would happen if I avoided using the REFRESH statement?
    8 - 12 - Is this syntactically correct, I am trying to get a set of data which is the customer numbers which match the master data customers and the master data record is án active version and than appendíng to the work area?
    13 - My understanding is this will reduce the number of records in the work area is this correct and needed?
    14 - 22 I am trying to identify my required set of data but feel I am repeating myself, could someone advise?
    Finally what logic would I actually need to write in the key figure object, could I use something like:
    Result = lt_customer.
    Thanks
    Edited by: Niten Shah on Jun 30, 2008 8:06 PM

    1. This line is not required
    2. OCCURS 0 is the OLD way of defining an internal table with that structure.  As it is, it just defines a flat structure.
    3. Data element is usually best
    3-5 Yes
    6. No.  Here you are declaring a table of the type of the flat structure.  Just as the ABAP says!
    7. Nothing.  But by putting this in, you ensure that you know the state of the table (empty) before you start looping through the data package
    8-12. You can tell if it is syntactically correct by pressing Ctrl-F2 when in the editor.  Looks ok.
    13. Ensures your list of customers contains no duplicated.  The code up to this point is building a list of all the unique customers in the data package.
    14-22. Goes to the database and brings back ONLY those customers which are found in the master data.  Looks ok.
    This is a start routine (that's why you've got a data package).  You don't use result.  You should update the datapackage.  But this you haven't done.  Double click on the table name /BIC/PCUSTOMER to get the correct field names.
    So you have to loop through the data package again, and check if the customer in the datapackage is lt_customer.  If it is, fine, otherwise you blank it and report an error, or set an error message or whatever.
    I wouldn't do it like this.  I'd do something like this:
    STATICS: st_customer TYPE HASHED TABLE OF TYPE /bi0/oicustomer
                                  WITH UNIQUE KEY TABLE_LINE.
    * st_customer retains its value between calls, so only populate if empty
    * In one run of the infopackage, this will mean you do only one read of
    * the master data, so very efficient.
    IF st_customer IS INITIAL.
      SELECT customer FROM /BI0/PCUSTOMER
                              INTO TABLE st_customer
                              WHERE objvers EQ 'A'. " Only active values
    ENDIF.
    * Go through data package
    LOOP AT DATA_PACKAGE.
    * Check whether the customer exists.
      READ TABLE st_customer TRANSPORTING NO FIELDS
                  WITH TABLE KEY table_line = DATA_PACKAGE-custid.
      CHECK sy-subrc IS NOT INITIAL.
    * If you get here, the customer isn't valid.  So I'm just setting it blank
      CLEAR DATA_PACKAGE-custid.
      MODIFY DATA_PACKAGE. " Updates the datapackage record
    ENDLOOP.
    Even this is not fully optimised, but it's not bad.
    I strongly suggest that you get yourself sent on the basic ABAP programming course if you're going to do a lot of this.  Otherwise, read the ABAP documentation in the help.sap.com, and, from the editor, get the cursor on each ABAP keyword and press F1 to read the ABAP help.
    matt

  • ABAP objects for transfer/update rules - does this apply to include stateme

    I have a question about the new requirement for the code in the update/transfer rules to be written in ABAP Objects standards.  Does this still apply if in your update rules you using include programs?  Does this mean that when we upgrade we will have to follow the ABAP Objects standards (ie no header lines)?

    Routines will method based.
    In addition to what Chetan has sent, check this how to also.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6090a621-c170-2910-c1ab-d9203321ee19
    Ravi Thothadri

  • 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

  • Update Rules in ABAP to consolidate two InfoSources into one ODS?

    Hello experts,
    I want to solve the following problem with ABAP update rules (I am a novice in ABAP):
    In an Oracle DB I have two tables TRANSACTIONS and PARTICIPANTS with an 1:n relationship:
    One or many PARTICIPANTS can be assigned to one TRANSACTIONS and
    one TRANSACTION can be assigned to one PARTICIPANT.
    I want an ODS that contains TRANSACTIONS with the number of male and female PARTICIPANTS of each transaction.
    So I created two InfoSources each representing one of the above tables:
    IO_TRANSACTION with COMM_STRUCTURE:
    TRANS_ID
    TRANS_DATE
    TRANS_STATE
    IO_PARTICIPANT with COMM_STRUCTURE:
    PARTIC_ID
    PARTIC_TYPE (1=male and 2=female)
    TRANS_ID
    Now I want to consolidate all male participants into the data field PARTIC_M
    and all female participants into the data field PARTIC_F of the following ODS:
    Key fields:
    TRANS_ID
    TRANS_DATE
    TRANS_STATE
    Data fields:
    PARTIC_M (number of male participants)
    PARTIC_F (number of female participants)
    I tried it with the following lines of ABAB Code in the ABAP routine
    for the datafield PARTIC_M:
    IF COMM_STRUCTURE-/BIC/PARTIC_TYPE = 1.   " 1 is the value for  "male"
       RESULT = 1.
    ELSE.
       RESULT = 0.
    ENDIF.
    But after loading both InfoSources into the ODS the fields PARTIC_M and PARTIC_F are empty!!
    Do I have to do some kind of joint in a start routine in order to connect Participant Information with a specific transaction?? How?
    Thanks a lot
    Of course, solutions will be rewarded
    Axel

    Hi Venkat,
    Thanks for the hint with the common key fields.
    My problem is, that both tables have only the field TRANS_ID in common.
    So when I update TRANSACTIONS with the three Key fields TRANS_ID, TRANS_DATE and TRANS_STATE
    and PARTICIPANTS with the Key field TRANS_ID into the ODS I get data like this:
    TRANS_ID, TRANS_DATE, TRANS_STATE, PARTIC_M, PARTIC_F
    TR01                                                                        1              1
    TR02                                                                        0              3
    But I also need the fields TRANS_DATE, TRANS_STATE to be filld with data!
    any suggestions?
    Axel

Maybe you are looking for

  • Adobe Photoshop Express Organizer - help manual needed

    Please excuse me if I'm posting this request to the wrong forum, but I'm looking for a tutorial on how to use the online Adobe Photoshop Express Organizer, which I access through photoshop.com.   I can't locate a tutorial or instructions on it anywhe

  • How can I find that an URL link is tored in which transparent table in SAP?

    I have a requirment that, I have to display a MSDS( Material Safety Data Sheet ) for every material, that is a line item in any particular sales order. How can I find that in which table this URL link is getting stored, such that I can retrieve this

  • Where is my final bill?

    I have been disconnected by BT by mistake after it mistakenly thought I had underpaid a cheque. It was Bt's fault as the cheque was written properly. So after Christmas and New Year without broadband and telephone, I got a new account number - which

  • Error in running RPTQTA00

    I am receiving following error while running PRTQTA00: 'You have not selected any Generation Rules'. What to do. I configured all setting in Generation rule, Selection rule

  • Siri in spanish

    is siri going to come out in spanish? for now on there is only available in english, french and german. i really hope apple develops siri in spanish