Write ABAP routine in transformation rule

Dear all,
I am very new to ABAP. Currently I would like to transfer some data from cube A to cube B. The problem is
Cube A and B have different Unit of Mesure. The product standard cost is based on each Item's UOM. For example:
Cube A data:
ItemNo }      UOM   }     Standard cost
ABC     }      P5      }            30
Cube B data:
ItemNo }      UOM        }     Standard cost
ABC     }      EACH      }            5  (30/5)
In transformation rule, I plan to use ABAP routine to calculate each record to new Stand cost if Cube A has different UOM than Cube B.
Can I call a program in this ABAP routine?
In ABAP routine, how can I delare other source table and fields?
Thanks for you help!

The preferable method, if you're on BI 7 or later, is to create a filter in the DTP so that the records where 0CLR_DOC_NO is blank aren't even passed into the Transformation.
If not, then you can add the following code into the Start Routine of your Transformation.
DELETE
  source_package
WHERE
  clr_doc_no EQ ' '.

Similar Messages

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

  • Need to write ABAP Routine at infopackage Selection Options

    Hi All,
    I need to write ABAP Routine at Info Package Selection Options.
    Requiremnet i need to bring  some Sales Document Types (Sales Orders Types) only from R/3.
    Ex I need OrderTypes ZQT,ZSIV etc
    Can any body help to resolve this.
    Regards,
    P.C.V.

    Hi P.C.V,
    If the order type field is already available in the Data Selection Tab of the InfoPackage, then you just need to place your selections there (e.g. order type = ZQT, ZSIV) without the need to use ABAP routines.
    If ever you really need an ABAP routine, here is an example ABAP routine. The most important concept is to modify the range table l_t_range so that the selection reflect what you need.
    data: l_idx like sy-tabix.
    data: w_startdate like sy-datum,
          w_startweek like scal-week,
          w_maxdate like sy-datum,
          w_maxweek like scal-week.
      w_startdate = sy-datum.
      w_maxdate = w_startdate + 104 * 7.
    * Calculate horizon for extraction
      CALL FUNCTION 'DATE_GET_WEEK'
        EXPORTING
          DATE         = w_startdate
        IMPORTING
          WEEK         = w_startweek
        EXCEPTIONS
          DATE_INVALID = 1
          OTHERS       = 2.
      CALL FUNCTION 'DATE_GET_WEEK'
        EXPORTING
          DATE         = w_maxdate
        IMPORTING
          WEEK         = w_maxweek
        EXCEPTIONS
          DATE_INVALID = 1
          OTHERS       = 2.
              read table l_t_range with key
                   fieldname = 'CALWEEK'.
              l_idx = sy-tabix.
              l_t_range-sign = 'I'.
              l_t_range-option = 'BT'.
              l_t_range-low = w_startweek.
              l_t_range-high = w_maxweek.
              modify l_t_range index l_idx.

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

  • Convert Date to Week - ABAP Routine in transformation

    Hi all,
    I am trying to convert a date to a week using ABAP in a transformation.
    The date is coming from an external database and has the format YYYYMMDD.  I want to convert this into the standard 0CALWEEK format.
    I thought that converting the date to the SAP internal format, and then running DATE_GET_WEEK on it, would work.  Firstly I am running the FM 'CONVERSION_EXIT_PDATE_OUTPUT' to get the date into the DDMMYYYY format then running DATE_GET_WEEK on the result of the first FM.
    This works up until the end of the first step; the internal date format is returned.  However, the code fails when it hits the 'DATE_GET_WEEK' FM.
    I would be really grateful if someone could tell me where I am going wrong.  Thanks, Mischa
    My code so far is:
    DATA:
    WEEK(6) TYPE C,
    CS_DT(8) TYPE C,
    TEMP_DT TYPE D,
    RESULT1 TYPE D.
    CLEAR RESULT.
    CLEAR RESULT1.
        CS_DT = SOURCE_FIELDS-CASE_DT.
    CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
      EXPORTING
        INPUT         = CS_DT
    IMPORTING
       OUTPUT        = TEMP_DT
    MOVE TEMP_DT TO RESULT1.
    CALL FUNCTION 'DATE_GET_WEEK'
      EXPORTING
        DATE               = RESULT1
    IMPORTING
       WEEK               = WEEK
    EXCEPTIONS
      DATE_INVALID       = 1
      OTHERS             = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    RESULT = WEEK.

    Hi all,
    Thanks for your replies, but the automatic conversion doesn't work.  I assume this is because the source field is a CHAR field with 8 characters, rather than a Date field as recognised by SAP.  Literally the field contains 8 characters YYYYMMDD for example 20090601. 
    If I try to assign directly, I get the error
    "Automatic time conversion is not possible for source field CASE_DT
    Cannot establish automatic time conversion to 0CALWEEK for source field CASE_DT. The source is a DataSource and consists of fields, not InfoObjects. Time conversion can only be performed automatically for InfoObjects."
    This is why I assumed I needed some ABAP code.  I  have tried assigning the time char 0CALDAY to my source field CASE_DT in the transformation, and this is not accepted either - I get the message
    "The properties of the InfoObject selected, 0CALDAY, do not match the properties of the available source field."
    Again, grateful for any help.
    Mischa

  • ABAP routine in Transformations syntax fix

    Hi
    As i am beginner in ABAP please correct the Start/End routine which i have written in Transformations for the below requirment
    DSO1------->DSO2
    While load data to DSO1-->DSO2 in need a look that refer active table of DSO3 and perform if condition to fill value to a field in DSO2
    DSO1 (SOURCE FIELDS)
    Field X
    Field Y (X,Y are Key fields)
    Field Z
    Field W
    DSO2 (Result Field)
    Field P (The field which i want to update with Value by routine)
    DSO3 (Look up)
    Field A
    Field B (A,B are Key fields) (A=X,B=Y)
    Field C
    Requirement:
    While loading data from DSO1-->DSO2...We should read active table of DSO3 and pass it to Internal Table (A,B,C)with a key (A=X,B=Y)
    and in the end routine
    First check wether if Field C is not initial...then Result Field P should be updated with E
    ELSE CHECK SOURCE FIELD Field Z = 1..then Result Field P should be updated with F
    ELSE CHECK SOURCE FIELD Field W = T..then Result Field P should be updated with G
    else if all the above conditions are not met .then Result Field P should be updated with H
    Syntax i wrote (Not working correctly)
    GLOBAL DECLARATION:
    TYPES:
    BEGIN OF ty_sou,
    W           TYPE /bi0/W,
    Z            TYPE /bi0/Z,
    END OF ty_sou,
    BEGIN OF ZDSO_3,
    A          TYPE     /bi0/oiA,
    B          TYPE     /bi0/oiB,
    C          TYPE     /bi0/oiC,
    END OF ZDSO_3.
    DATA : ty_ZDSO_3_wa           TYPE   ZDSO_3,
                 ty_ZDSO_3_tab          TYPE   TABLE OF ZDSO_3,
                 ty_ZDSO_3_tab_temp     TYPE   TABLE OF ZDSO_3.
    DATA : ty_sou_tab            TYPE   TABLE OF ty_sou,
                ty_sou_wa             TYPE   ty_sou.
    START ROUTINE
    $$ begin of routine - insert your code only below this line        -
        LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.
          IF  <source_fields>-XIS NOT INITIAL AND
              <source_fields>-Y  IS NOT INITIAL.
            ty_ZDSO_3_wa-A = <source_fields>-X.
            ty_ZDSO_3_wa-B = <source_fields>-Y.
            ty_sou_wa-Z =  <source_fields>-Z.
            ty_sou_wa-W  =  <source_fields>-W.
            COLLECT ty_sou_wa INTO ty_sou_tab.
            COLLECT ty_ZDSO_3_wa INTO ty_ZDSO_3_tab.
          ENDIF.
        ENDLOOP.
    *Select Statement to select values from ZDSO_3 Active Table
        SELECT A B C
        FROM /bic/aZDSO_300 INTO TABLE ty_ZDSO_3_tab_temp   FOR ALL
        ENTRIES IN
             ty_ZDSO_3_tab WHERE A = ty_ZDSO_3_tab-A.
        SORT ty_ZDSO_3_tab BY A B.
    END ROUTINE
    LOOP AT RESULT_PACKAGE ASSIGNING <result_fields> .
    Read table ty_ZDSO_3_tab_temp into ty_ZDSO_3_wa with key
    A = <result_fields>-P
    B = <result_fields>-Q
    binary search.
    If sy-subrc = 0.
    IF ty_ZDSO_3_wa-C IS NOT INITIAL.
    <result_fields>-/BIC/P = 'E'.
    ELSEIF
    ty_sou_wa-Z = 1.
    <result_fields>-/BIC/P = 'Fu2019.
    ELSEIF ty_sou_wa-W= 'T'.
    <result_fields>-/BIC/P = 'G'.
    ELSE.
    <result_fields>-/BIC/P = 'H'.
    ENDIF.
    Endif.
    ENDLOOP.
    But this is not working...i tried to debug but as i am a learner in ABAP i am not familiar....
    Please advise me where or what is wrong with my code and greatful if you can make changes

    Routine End
    LOOP AT RESULT_PACKAGE ASSIGNING<RESULT-FIELD>-/ . 
    Read table ty_ZDSO_3_tab_temp into ty_ZDSO_3_wa
    with key A = -P B = -Q binary search. 
    If sy-subrc = 0. 
    IF ty_ZDSO_3_wa-C IS NOT INITIAL.
    <RESULT-FIELD>-/BIC/P = 'E'.
    ELSEIF ty_sou_wa-Z = 1.
    <RESULT-FIELD>-/-/BIC/P = 'Fu2019.
    ELSEIF ty_sou_wa-W= 'T'.
    <RESULT-FIELD>-/-/BIC/P = 'G'.
    ELSE. 
    <RESULT-FIELD>-/-/BIC/P = 'H'.
    ENDIF.
    Endif.
    ENDLOOP.

  • ABAP Routine in Transformations Syntax Correction

    Hi,
    As i am beginner in ABAP please correct the Start/End routine which i have written in Transformations for the below requirement
    DSO1------->DSO2
    While load data to DSO1-->DSO2 in need a look that refer active table of DSO3 and perform if condition to fill value to a field in DSO2
    DSO1 (SOURCE FIELDS)
    Field X
    Field Y (X,Y are Key fields)
    Field Z
    Field W
    DSO2 (Result Field)
    Field P (The field which i want to update with Value by routine)
    DSO3 (Look up)
    Field A
    Field B (A,B are Key fields) (A=X,B=Y)
    Field C
    Requirement: While loading data from DSO1-->DSO2...We should read active table of DSO3 and pass it to Internal Table (A,B,C)with a key (A=X,B=Y) and in the end routine First check wether
    if Field C is not initial...then Result Field P should be updated with E
    ELSE CHECK SOURCE FIELD Field Z = 1..then Result Field P should be updated with F
    ELSE CHECK SOURCE FIELD Field W = T..then Result Field P should be updated with G
    else if all the above conditions are not met .then Result Field P should be updated with H 
    Syntax i wrote (Not working correctly) 
         Declaration-Global
    TYPES: BEGIN OF ty_sou,
                   W TYPE /bi0/W,
                   Z TYPE /bi0/Z, END OF ty_sou,
    BEGIN OF ZDSO_3,
    A TYPE /bi0/oiA,
    B TYPE /bi0/oiB,
    C TYPE /bi0/oiC, END OF ZDSO_3. 
    DATA : ty_ZDSO_3_wa TYPE ZDSO_3,
    ty_ZDSO_3_tab TYPE TABLE OF ZDSO_3,
    ty_ZDSO_3_tab_temp TYPE TABLE OF ZDSO_3. 
    DATA : ty_sou_tab TYPE TABLE OF ty_sou,
                 ty_sou_wa TYPE ty_sou. 
    Routine Start
    LOOP AT SOURCE_PACKAGE ASSIGNING .
    IF -XIS NOT INITIAL AND -Y IS NOT INITIAL.
         ty_ZDSO_3_wa-A = -X.
         ty_ZDSO_3_wa-B = -Y.
      ty_sou_wa-Z = -Z.
      ty_sou_wa-W = -W. 
    COLLECT ty_sou_wa INTO ty_sou_tab.
    COLLECT ty_ZDSO_3_wa INTO ty_ZDSO_3_tab.
    ENDIF.
    ENDLOOP. 
    *Select Statement to select values from ZDSO_3 Active Table 
    SELECT A B C FROM /bic/aZDSO_300 INTO TABLE ty_ZDSO_3_tab_temp FOR ALL ENTRIES IN ty_ZDSO_3_tab WHERE
    A = ty_ZDSO_3_tab-A. 
    SORT ty_ZDSO_3_tab BY A B. 
    Routine End
    But this is not working...i tried to debug but as i am a learner in ABAP i am not familiar.... Please advise me where or what is wrong with my code and greatful if you can make changes
    Edited by: SAP7593 on Jan 21, 2010 7:56 AM
    Edited by: SAP7593 on Jan 21, 2010 7:56 AM

    Routine End
    LOOP AT RESULT_PACKAGE ASSIGNING<RESULT-FIELD>-/ . 
    Read table ty_ZDSO_3_tab_temp into ty_ZDSO_3_wa
    with key A = -P B = -Q binary search. 
    If sy-subrc = 0. 
    IF ty_ZDSO_3_wa-C IS NOT INITIAL.
    <RESULT-FIELD>-/BIC/P = 'E'.
    ELSEIF ty_sou_wa-Z = 1.
    <RESULT-FIELD>-/-/BIC/P = 'Fu2019.
    ELSEIF ty_sou_wa-W= 'T'.
    <RESULT-FIELD>-/-/BIC/P = 'G'.
    ELSE. 
    <RESULT-FIELD>-/-/BIC/P = 'H'.
    ENDIF.
    Endif.
    ENDLOOP.

  • Explain me the (ABAP) Routine in Transformation

    Hi,
    Can any one explain me what this code doing
    This is written  to cal age of emp based on DOB as a routine in Transpormation
    if i_week ne SOURCE_FIELDS-/bic/week_kbc.
    clear: i_period, i_year, i_date, i_week.
    i_week = SOURCE_FIELDS-/bic/week_kbc.
    i_year = SOURCE_FIELDS-/bic/week_kbc(4).
    concatenate '0' SOURCE_FIELDS-/bic/week_kbc+4(2) into i_period.
    CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
      EXPORTING
        I_GJAHR              = i_year
      I_MONMIT             = 00
        I_PERIV              = 'TM'
        I_POPER              = i_period
      IMPORTING
      E_DATE               = i_date.
    endif.
          IF NOT SOURCE_FIELDS-/bic/emp_dob IS INITIAL.
        RESULT = i_date0(4) - SOURCE_FIELDS-/bic/emp_dob0(4).
        IF i_date4(4) LT SOURCE_FIELDS-/bic/emp_dob4(4).
          RESULT = RESULT - 1.
        ENDIF.
        endif.

    This is calculating the age of the employee based on the field Zweek_kbc.

  • Start/Field Routine in Transformations (ABAP)

    Hi Experts
    Please update me on how to proceed and ABAP Code required.
    DSOFULL->CUBE
    DSO Active Table: /BIC/AEMPPED00
    Data In DSO
    Emp_ID--Emp_SDATE--Emp_TDate
    1-----01.01.2008
    1---01.01.2008--01.06.2008
    1-----01.01.2008
    Data Expected in CUBE
    Emp_ID--Emp_SDATEEmp_TDate-----Ter_Date
    1---01.01.2008--
    01.06.2008
    1---01.01.200801.06.2008---01.06.2008
    1---01.01.2008--
    I need a start routine or field routine that
    Will loading data from DSO to CUBE the code should look for employee latest record and if it find Emp_TDatevalue then it should populate both recordsTer_date in cube with  Emp_TDate
    Please advise

    Hi,
    i am providin you a sample code please modify it (field name and tables name's as per your requirement).
    Please write the code in transformation rule of field Emp_TDate.
    Map field Emp_SDATE  to the target field for Emp_TDATE .
        SELECT * FROM /BIC/AEMPPED00
                        WHERE Emp_SDATE NE ' '.
    if sy-subrc is initial.
    result = source_field-Emp_SDATE.
    else.
    result = ' '.
    endif.
    Please replace the emp_SDATE field with the source field name.
    But still i have some question...
    1. On what basis u decide the latest record ??
    Can u please explain scenarion bit mroe clearly.
    Thanks
    Dipika
    Edited by: Dipika Tyagi on Jun 24, 2008 8:47 AM

  • ABAP Logic/Structure for a Start and Field Routine in Transformations

    My Requirment is to export data from Data Target to Application Server.
    And for that purpose i built a APD...
    In Transformations to read data from MAster Data Table i had written below Global & Field Routine.
    Start Routine:
    Glodal Declaration
    DATA: it_dep   type standard table of /BI0/MDEPT,
          is_dep   type /BI0/MDEPT.
    LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.
    if not SOURCE_PACKAGE[] is initial.
    SELECT * FROM /BI0/MDEPT INTO TABLE it_dep for all entries in
    SOURCE_PACKAGE
    WHERE depLOYEE    = SOURCE_PACKAGE-dep      AND
          OBJVERS     = 'A'                     AND
          DATETO     GE SY-DATUM.
    ENDIF.
    ENDLOOP.
    FIELD ROUTINE
    Clear:is_dep.
        Read table it_dep into is_dep with key
        depLOYEE = SOURCE_FIELDS-deployee binary search.
        if sy-subrc = 0.
          RESULT = is_dep-USERNAME.
        endif.
    Now for another field 'Manager' name.......
    My requirment
    Start Routine:
    (Sub Detp is an attribute to Dept and Sub Dept is referenced on dept)
    First it should copy all the Sub depts for the corresponding depts in the source field to a Temperoray table (TEMP1)
    For all sub depts in TEMP1 table it should copy manager names from dept master data table to a Temp2 table
    In start routine i need to first read temp1 and result from temp1 should be passed to temp2 and the result from tem2 can be passed to result field
    Please update

    Hi,
    i am providin you a sample code please modify it (field name and tables name's as per your requirement).
    Please write the code in transformation rule of field Emp_TDate.
    Map field Emp_SDATE  to the target field for Emp_TDATE .
        SELECT * FROM /BIC/AEMPPED00
                        WHERE Emp_SDATE NE ' '.
    if sy-subrc is initial.
    result = source_field-Emp_SDATE.
    else.
    result = ' '.
    endif.
    Please replace the emp_SDATE field with the source field name.
    But still i have some question...
    1. On what basis u decide the latest record ??
    Can u please explain scenarion bit mroe clearly.
    Thanks
    Dipika
    Edited by: Dipika Tyagi on Jun 24, 2008 8:47 AM

  • 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

  • ABAP (Routine) Error in BW Transformations

    Hi Experts,
    As i am new(Learner) to BW Please advise me on how can i achieve this and update me with Releavent Start Routine and Field Routine....please
    My Requirment is
    Employee is Compounded on Location.
    On Weekly or Monthly basis (dependending on Employee Payroll run) Employee will be assigned with the Wage Type and Amount for that Wage Type and Payroll Date (When the payroll was run)
    Data Currently i have/Data comming from Source System
    Loc_ID--Emp_IDWage_IDPayroll_Date-Amount
    -1--99900108.08.2008-----100.00
    -1--99908808.08.2008-----560.00
    -1--99934508.08.2008-----437.00
    -1--99900108.07.2008-----654.00
    -1--99908808.07.2008-----389.00
    -1--99934508.07.2008-----893.00
    -1--99926408.06.2008-----600.00
    -1--99934508.08.2008-----365.00
    (Employee may have Different Wage_ID and Amount for each payroll)
    My requirment is to include a new key figure 'Previous_Amount' which will be populated previous Wage_ID Amount.
    Loc_ID--Emp_IDWage_IDPayroll_Date-Amount---Previous_Amount
    -1--99900108.08.2008---100.00-----654.00
    -1--99908808.08.2008---560.00--
    389.00
    -1--99934508.08.2008---437.00--
    893.00
    -1--99900108.07.2008---654.00--
    0
    -1--99908808.07.2008---389.00--
    0
    -1--99934508.07.2008---893.00--
    365.00
    -1--99926408.06.2008-----600.00
    -1--99934508.08.2008-----365.00
    As i am a starter in BW i am struggling to write start routine in transformations (DSO-->CUBE) to transfer the data in DSO Active Table to a internal table and a field routine to update Previous_Amount field by sorting the internal table data and to pick employee's latest record less than the current payroll for that particular wage_id and populate that amout to Previous_Amount field.
    Please make necessary corrections to the start routine by fixing where i went wrong and update me with the required field routine (which will read data from internal table used in start routine.
    With the help of Vamsi i can able to write this code,But still the Previous Price is filled with 0
    Please correct me where it went wrong
    Start Routine
    Global declaration
    Types :
    Begin of ITABtype,
    ORG               TYPE /BIC/OIZORG,
    CYEMPNO           TYPE /BIC/OIZCYEMPNO,
    HED_ID           TYPE /BIC/OIZHED_ID,
    RHED_ID           TYPE /BIC/OIZRHED_ID,
    CHNG_DTE          TYPE /BIC/OIZCHNG_DTE,
    HED_AMT           TYPE /BIC/OIZHED_AMT,
    HED_PAMT          TYPE /BIC/OIZHED_PAMT,
    End of ITABtype.
    Data : ITAB type standard table of ITABtype
    with key
    ORG
    CYEMPNO
    HED_ID
    RHED_ID
    CHNG_DTE
    HED_AMT
    HED_PAMT,
    wa_itab like line of itab.
    Data : ITAB1 type standard table of ITABtype
    with key
    ORG
    CYEMPNO
    HED_ID
    RHED_ID
    CHNG_DTE
    HED_AMT
    HED_PAMT,
    wa_itab1 like line of itab1.
    *Create an internal table with all the field types with u want to have
    *in the output */
    Data : wa_SOURCE_PACKAGE type tys_SC_1.
    Data : tmp(2) type n value 1.
    \ The above loop is to get all the values into the internal table*/
    Loop at SOURCE_PACKAGE into wa_SOURCE_PACKAGE.
    Move wa_SOURCE_PACKAGE-/BIC/ZORG to wa_itab-ORG.
    Move wa_SOURCE_PACKAGE-/BIC/ZCYEMPNO to wa_itab-CYEMPNO.
    Move wa_SOURCE_PACKAGE-/BIC/ZHED_ID to wa_itab-HED_ID.
    Move wa_SOURCE_PACKAGE-/BIC/ZHED_ID/BIC/ZRHED_ID to wa_itab-RHED_ID.
    Move wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE to wa_itab-CHNG_DTE.
    Move wa_SOURCE_PACKAGE-/BIC/ZHED_AMT to wa_itab-HED_AMT.
    *Move wa_SOURCE_PACKAGE-/BIC/ZHED_PAMT to wa_itab-HED_PAMT.
    Append wa_itab to itab.
    Endloop.
    Sort itab by
    ORG       Ascending
    CYEMPNO   Ascending
    HED_ID    Ascending
    RHED_ID   Ascending
    CHNG_DTE  Descending.
    Sort SOURCE_PACKAGE by
    /BIC/ZORG                   Ascending
    /BIC/ZCYEMPNO               Ascending
    /BIC/ZHED_ID                Ascending
    /BIC/ZHED_ID/BIC/ZRHED_ID   Ascending
    /BIC/ZCHNG_DTE              Descending.
    Loop at itab into wa_itab.
    tmp = '1' .
    Loop at SOURCE_PACKAGE into wa_SOURCE_PACKAGE from tmp.
    If wa_itab-ORG = wa_SOURCE_PACKAGE-/BIC/ZORG.
       wa_itab-CYEMPNO  = wa_SOURCE_PACKAGE-/BIC/ZCYEMPNO.
       wa_itab-HED_ID   = wa_SOURCE_PACKAGE-/BIC/ZHED_ID.
       wa_itab-RHED_ID  = wa_SOURCE_PACKAGE-/BIC/ZHED_ID/BIC/ZRHED_ID.
    wa_itab-CHNG_DTE = wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE.
       wa_itab-HED_PAMT = wa_SOURCE_PACKAGE-/BIC/ZHED_AMT.
      wa_itab-CHNG_DTE gt wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE.
    tmp = tmp + 1.
    Exit.
    Endif.
    Endloop.
    Modify itab from wa_itab.
    Endloop.
    itab1[] = itab[].
    Sort itab1 by
    ORG       Ascending
    CYEMPNO   Ascending
    HED_ID    Ascending
    RHED_ID   Ascending
    CHNG_DTE  Descending.
    Delete adjacent duplicates from itab1 comparing
    ORG
    CYEMPNO
    HED_ID
    RHED_ID
    CHNG_DTE.
    Loop at itab1 into wa_itab1.
    wa_itab-HED_PAMT = '0'.
    Modify itab1 from wa_itab1.
    Endloop.
    Loop at itab into wa_itab.
    Loop at itab1 into wa_itab1.
    If wa_itab1-ORG = wa_itab-ORG.
       wa_itab1-CYEMPNO = wa_itab-CYEMPNO.
       wa_itab1-HED_ID  = wa_itab-HED_ID.
       wa_itab1-RHED_ID = wa_itab-RHED_ID.
       wa_itab1-CHNG_DTE = wa_itab-CHNG_DTE.
       wa_itab1-HED_PAMT = wa_itab-HED_PAMT.
    Exit.
    Endif.
    Endloop.
    Modify itab from wa_itab.
    Endloop.
    Field Routine
    Read table ITAB into wa_itab
    with key
    ORG       = SOURCE_FIELDS-/BIC/ZORG
    CYEMPNO   = SOURCE_FIELDS-/BIC/ZCYEMPNO
    HED_ID    = SOURCE_FIELDS-/BIC/ZHED_ID
    RHED_ID   = SOURCE_FIELDS-/BIC/ZHED_ID/BIC/ZRHED_ID
    CHNG_DTE  = SOURCE_FIELDS-/BIC/ZCHNG_DTE.
    if sy-subrc = 0.
    RESULT = wa_itab-HED_PAMT.
    endif.
    Please update me where it was wrong
    Thanks in advance

    Hi again,
    i don't have a BW system available now so the code is more as a how to and needs corrections but i hope you will figure out the logic.
    declare an internal table and working area similar with the ods object.
    data itab type table of ods_type.
    data wa_itab type ods_type.
    declare a working area for the source package.
    data wa_source type type_source_package.
    data l_tabix like sy-tabix.
    select all active entries from ods .
    if you figure out a performance issue here move this select into the loop and use where clauses or use for all entries in source_package
    select * from ods_object into table itab .
    sort source_package by payroll_date descending.
    loop at source_package into wa_source.
    l_tabix = sy-tabix.
    read table itab into wa_itab with key Loc_ID = wa_source_package-loc_id
                                          Emp_ID = wa_source_package-emp_id
                                          wage_id = wa_source_package-Wage_ID.
    wa_source-previous_amount = wa_itab-amount.
    modify source_package from wa_source index l_tabix.
    endloop.
    This code should be in the start routine of the ods update.
    Hope this helps
    Kostas

  • Abap Routines in BW

    Hai,
    Where the Abap Routines are used in BW side? How many routines are there in bW? Can any send me the Doc's on this to my mail id [email protected]
    full points  assured.
    thanks n Regards
    prashanth k

    Hi
    You can write  abap routines in
    1. Update rule
    2.Transfer rule
    3.Process chain
    4. Start routine in update rule
    5. Start routine in update rule
    here is some example codings
    https://www.sdn.sap.com/irj/sdn/advancedsearch?query=abap%20routines&cat=sdn_all
    helpful
    real time changing of logic for keyfigures, how to do it..
    Message was edited by:
            Kalpana M

  • (ABAP) Code in Transformation--Modification

    Hi Experts,
    As i am new(Learner) to BW Please advise me on how can i achieve this and update me with Releavent Start Routine and Field Routine....please
    My Requirment is
    Employee is Compounded on Location.
    On Weekly or Monthly basis (dependending on Employee Payroll run) Employee will be assigned with the Wage Type and Amount for that Wage Type and Payroll Date (When the payroll was run)
    Data Currently i have/Data comming from Source System
    Loc_ID--Emp_IDWage_IDPayroll_Date-Amount
    -1--99900108.08.2008-----100.00
    -1--99908808.08.2008-----560.00
    -1--99934508.08.2008-----437.00
    -1--99900108.07.2008-----654.00
    -1--99908808.07.2008-----389.00
    -1--99934508.07.2008-----893.00
    -1--99926408.06.2008-----600.00
    -1--99934508.08.2008-----365.00
    (Employee may have Different Wage_ID and Amount for each payroll)
    My requirment is to include a new key figure 'Previous_Amount' which will be populated previous Wage_ID Amount.
    Loc_ID--Emp_IDWage_IDPayroll_Date-Amount---Previous_Amount
    -1--99900108.08.2008---100.00-----654.00
    -1--99908808.08.2008---560.00--
    389.00
    -1--99934508.08.2008---437.00--
    893.00
    -1--99900108.07.2008---654.00--
    0
    -1--99908808.07.2008---389.00--
    0
    -1--99934508.07.2008---893.00--
    365.00
    -1--99926408.06.2008-----600.00
    -1--99934508.08.2008-----365.00
    As i am a starter in BW i am struggling to write start routine in transformations (DSO-->CUBE) to transfer the data in DSO Active Table to a internal table and a field routine to update Previous_Amount field by sorting the internal table data and to pick employee's latest record less than the current payroll for that particular wage_id and populate that amout to Previous_Amount field.
    Please make necessary corrections to the start routine by fixing where i went wrong and update me with the required field routine (which will read data from internal table used in start routine.
    With the help of Vamsi i can able to write this code,But still the Previous Price is filled with 0
    Please correct me where it went wrong
    Start Routine
    Global declaration
    Types :
    Begin of ITABtype,
    ORG               TYPE /BIC/OIZORG,
    CYEMPNO           TYPE /BIC/OIZCYEMPNO,
    HED_ID           TYPE /BIC/OIZHED_ID,
    RHED_ID           TYPE /BIC/OIZRHED_ID,
    CHNG_DTE          TYPE /BIC/OIZCHNG_DTE,
    HED_AMT           TYPE /BIC/OIZHED_AMT,
    HED_PAMT          TYPE /BIC/OIZHED_PAMT,
    End of ITABtype.
    Data : ITAB type standard table of ITABtype
    with key
    ORG
    CYEMPNO
    HED_ID
    RHED_ID
    CHNG_DTE
    HED_AMT
    HED_PAMT,
    wa_itab like line of itab.
    Data : ITAB1 type standard table of ITABtype
    with key
    ORG
    CYEMPNO
    HED_ID
    RHED_ID
    CHNG_DTE
    HED_AMT
    HED_PAMT,
    wa_itab1 like line of itab1.
    *Create an internal table with all the field types with u want to have
    *in the output */
    Data : wa_SOURCE_PACKAGE type tys_SC_1.
    Data : tmp(2) type n value 1.
    \ The above loop is to get all the values into the internal table*/
    Loop at SOURCE_PACKAGE into wa_SOURCE_PACKAGE.
    Move wa_SOURCE_PACKAGE-/BIC/ZORG to wa_itab-ORG.
    Move wa_SOURCE_PACKAGE-/BIC/ZCYEMPNO to wa_itab-CYEMPNO.
    Move wa_SOURCE_PACKAGE-/BIC/ZHED_ID to wa_itab-HED_ID.
    Move wa_SOURCE_PACKAGE-/BIC/ZHED_ID/BIC/ZRHED_ID to wa_itab-RHED_ID.
    Move wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE to wa_itab-CHNG_DTE.
    Move wa_SOURCE_PACKAGE-/BIC/ZHED_AMT to wa_itab-HED_AMT.
    *Move wa_SOURCE_PACKAGE-/BIC/ZHED_PAMT to wa_itab-HED_PAMT.
    Append wa_itab to itab.
    Endloop.
    Sort itab by
    ORG       Ascending
    CYEMPNO   Ascending
    HED_ID    Ascending
    RHED_ID   Ascending
    CHNG_DTE  Descending.
    Sort SOURCE_PACKAGE by
    /BIC/ZORG                   Ascending
    /BIC/ZCYEMPNO               Ascending
    /BIC/ZHED_ID                Ascending
    /BIC/ZHED_ID/BIC/ZRHED_ID   Ascending
    /BIC/ZCHNG_DTE              Descending.
    Loop at itab into wa_itab.
    tmp = '1' .
    Loop at SOURCE_PACKAGE into wa_SOURCE_PACKAGE from tmp.
    If wa_itab-ORG = wa_SOURCE_PACKAGE-/BIC/ZORG.
       wa_itab-CYEMPNO  = wa_SOURCE_PACKAGE-/BIC/ZCYEMPNO.
       wa_itab-HED_ID   = wa_SOURCE_PACKAGE-/BIC/ZHED_ID.
       wa_itab-RHED_ID  = wa_SOURCE_PACKAGE-/BIC/ZHED_ID/BIC/ZRHED_ID.
    wa_itab-CHNG_DTE = wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE.
       wa_itab-HED_PAMT = wa_SOURCE_PACKAGE-/BIC/ZHED_AMT.
      wa_itab-CHNG_DTE gt wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE.
    tmp = tmp + 1.
    Exit.
    Endif.
    Endloop.
    Modify itab from wa_itab.
    Endloop.
    itab1[] = itab[].
    Sort itab1 by
    ORG       Ascending
    CYEMPNO   Ascending
    HED_ID    Ascending
    RHED_ID   Ascending
    CHNG_DTE  Descending.
    Delete adjacent duplicates from itab1 comparing
    ORG
    CYEMPNO
    HED_ID
    RHED_ID
    CHNG_DTE.
    Loop at itab1 into wa_itab1.
    wa_itab-HED_PAMT = '0'.
    Modify itab1 from wa_itab1.
    Endloop.
    Loop at itab into wa_itab.
    Loop at itab1 into wa_itab1.
    If wa_itab1-ORG = wa_itab-ORG.
       wa_itab1-CYEMPNO = wa_itab-CYEMPNO.
       wa_itab1-HED_ID  = wa_itab-HED_ID.
       wa_itab1-RHED_ID = wa_itab-RHED_ID.
       wa_itab1-CHNG_DTE = wa_itab-CHNG_DTE.
       wa_itab1-HED_PAMT = wa_itab-HED_PAMT.
    Exit.
    Endif.
    Endloop.
    Modify itab from wa_itab.
    Endloop.
    Field Routine
    Read table ITAB into wa_itab
    with key
    ORG       = SOURCE_FIELDS-/BIC/ZORG
    CYEMPNO   = SOURCE_FIELDS-/BIC/ZCYEMPNO
    HED_ID    = SOURCE_FIELDS-/BIC/ZHED_ID
    RHED_ID   = SOURCE_FIELDS-/BIC/ZHED_ID/BIC/ZRHED_ID
    CHNG_DTE  = SOURCE_FIELDS-/BIC/ZCHNG_DTE.
    if sy-subrc = 0.
    RESULT = wa_itab-HED_PAMT.
    endif.
    Please update me where it was wrong
    Thanks in advance

    hi
    First loop fetches value from source_package into itab like thiss
    ITAB
    Hed_id    chng_date           Hed_Amt         Hed_Pmat
       001       08.08.2008            100                         NO VALUE YET
       001       08.07.2008            654                         NO VALUE YET                     
       088      08.08.2008             560                         NO VALUE YET
       088      08.07.2008              389                        NO VALUE YET
    Source_package
    Hed_id    chng_date           Hed_Amt        
       001       08.08.2008            100                        
       001       08.07.2008            654                                                     
       088      08.08.2008             560 
       088      08.07.2008              389
    That loop compares the itab and source_package by nrigning one record after another into wa_itab and wa_source_packageu2026.
    Wa_itab-chng_date > wa_odurce_package-chng_date and wa_itab-hed-id  = wa_source_package-hed_id
          1)       08.08.2007          >  08.08.2008               101    =101     false
           It will loop for second iteration in source_package outer loop it is at first record only.
         2)      08.08.2007        >   08.07.2008                  101   = 101    true
                   So wa_itab-zhed_pamt = wa_source_package-price ( right we has to get that value only )
                              Wa_itab-zhed_pamt = 654 (wa_source_package-amt).
                   So exit that loop and modify the itab
              So ur itab first record becomes
                    001       08.08.2008            100                654
    3) and it continues in the inner loop and finds no record with the sameu2026.
    So after this entire looping
    ITAB
    Hed_id    chng_date           Hed_Amt         Hed_Pmat
       001       08.08.2008            100                         654
       001       08.07.2008            654                         NO VALUE YET                     
       088      08.08.2008             560                         389
       088      08.07.2008              389                        NO VALUE YET
    Next itab1 = itab  so
    ITAB1
    Hed_id    chng_date           Hed_Amt         Hed_Pmat
       001       08.08.2008            100                         654
       001       08.07.2008            654                         NO VALUE YET                     
       088      08.08.2008             560                         389
       088      08.07.2008              389                        NO VALUE YET
    For the  001  08.07.2008 we has to get previous amount 0 for that
    Sort and delte adjacent steps after iot becomes like this
    ITAB1
    Hed_id    chng_date           Hed_Amt         Hed_Pmat
    001       08.07.2008            654                         NO VALUE YET     
    088      08.07.2008              389                        NO VALUE YET
    Next loop modify and add zero to previous amount  to these values
    ITAB1
    Hed_id    chng_date           Hed_Amt         Hed_Pmat
    001       08.07.2008            654                         0
    088      08.07.2008              389                        0
    Next loop we will modify these values to the internal table
    Hed_id    chng_date           Hed_Amt         Hed_Pmat
       001       08.08.2008            100                         654
       001       08.07.2008            654                         0                     
       088      08.08.2008             560                         389
       088      08.07.2008              389                        0
    Next using field routine suppose incoming record has hed_id 101 and change_date  08.08.2008             then the previous value corresponding to it is read from the itab
    U try to do debugging and know those more ......
    Regards
    vamsi

  • Read filter values of DTP by ABAP routine

    I am trying to read the filter values of a DTP by ABAP routine in transformation.
    I could do it in the past by using the code
    DATA: t_filter_values TYPE rsbk_th_range.
        t_filter_values = p_r_request->get_th_range( ).
    After patching (SAPKW70019), the code does not seem to work.
    Are there any other ways to retrieve the DTP filter values in ABAP?

    Thank you Simon.
    Table RSSELDTP contains the filter values comma separated.
    But it would be really dirty to read the values from there.
    I would have to split the comma separated values. Furthermore, low and high value are just concatenated by a minus sign. I would have to split these values as well.
    Is there a better solution to the problem?

Maybe you are looking for

  • How to create an automatic email when a new announcement is created

    Hi, In Sharepoint 2013, how can I configure it to automatically send an email to all users when a new announcement is created? Regards, Stephen.

  • Setting Up Multiple iPhones On One iTunes Account

    Our business supplies iPhones to our technicians out in the field and I've set each phone up under the same iTunes account. Can someone please help me out on the below things that I need to be able to manage? I need to be able to back up each iPhone

  • How can i get my password if i cant connect to itunes

    so i changed my passcode to my i-pod because  my brother found out what it was and i know i put taylor gang (without spacing) as my passcode but i have big hands so when i put the passcode i must have pressed a wrong button because and now i cant get

  • Silverfast AI Studio crashing PSCS3 in Snow Leopard

    Photoshop CS3 has been working just fine in Snow Leopard, but I wondered what would happen when I fired up my scanner.  Finally tried it today.  I have used LaserSoft Silverfast, a pretty nice scanner driver, for years.  Silverfast attempts to load,

  • Default header for portfolios?

    Is there a way to specify a "default header" for a PDF portfolio? As in, whenever a new portfolio is created, either by hand or through the right-click context menu, can it be generated with the same image/text header each time?