ABAP code in transformation

Hello,
I have a transformation routine as follows:
DATA:l_lifnr1 TYPE /BI0/MBATCH-VENDOR,
         l_greybatch TYPE /BI0/MBATCH-BATCH,
         oref   TYPE REF TO cx_root,
          l_num type i,
          l_len  type i,
          l_len1(2)  type c.
    l_len = strlen( SOURCE_FIELDS-/BIC/ZBAT_SUP ).
    l_len1 = ( l_len - 1 ).
    try.
        concatenate SOURCE_FIELDS-/BIC/ZBAT_SUP+0(l_len1) 'G' into
        l_greybatch.
      catch CX_SY_CONVERSION_NO_NUMBER INTO oref.
    ENDTRY.
=============
this transformation is between a infosource and infoobject. When i run the DTP, it gives an error at the line "concatenate SOURCE_FIELDS-/BIC/ZBAT_SUP+0(l_len1) 'G' into l_greybatch."
This -/BIC/ZBAT_SUP is calculated using a routine in the transformation between the datasource and the infosource. The same DTP is used for both load across both these transformations.
what is wrong? any suggestions?

Hello Siegfried,
Thank you very much.
As you rightly pointed out -/BIC/ZBAT_SUP is not filled.
But i didnt want to fill it in the second transformation(between the infosrc and infoobject) becoz, this is used for populating 2 differnt objects for which there are different rules. I will have to run the logic(for populating -/BIC/ZBAT_SUP) twice in these 2 rules.
Hence i was trying to populate it in the first transformation(between the datasrc and the infosrc) and then use this value in the 2 rules in the second transformation.
Can you give me some other logic to do the same with the necessary ABAP code?
Following is the routine use to populate -/BIC/ZBAT_SUP in the first transformation:
$$ begin of routine - insert your code only below this line        -
DATA: l_charg TYPE /BIC/AZMM_O0100-BATCH.
      SELECT SINGLE /BIC/ZBAT_SUP FROM /BIC/AZMM_O0100
      into l_charg
          WHERE BATCH = SOURCE_FIELDS-CHARG.
     RESULT = l_charg .
$$ end of routine - insert your code only before this line         -
  ENDMETHOD.                    "compute_ZBAT_SUP
====================================================
The second transformation populates 2 different vendor fields in 2 different rules. Both the rules use the follwing 2 routines:
$$ begin of routine - insert your code only below this line        -
    DATA:l_lifnr1 TYPE /BI0/MBATCH-VENDOR,
         l_greybatch TYPE /BI0/MBATCH-BATCH,
         oref   TYPE REF TO cx_root,
          l_num type i,
          l_len  type i,
          l_len1(2)  type c.
    l_len = strlen( SOURCE_FIELDS-/BIC/ZBAT_SUP ).
    l_len1 = ( l_len - 1 ).
      try.
          concatenate SOURCE_FIELDS-/BIC/ZBAT_SUP+0(l_len1) 'G' into
          l_greybatch.
     move SOURCE_FIELDS-/BIC/ZBAT_SUP(l_len1) to l_greybatch.
     move 'G' to l_greybatch+l_len1(1).
        catch CX_SY_CONVERSION_NO_NUMBER INTO oref.
      ENDTRY.
*Populating Supplying(finished) batch vendor
      select single VENDOR from /BI0/MBATCH
      into l_lifnr1
      where BATCH = l_greybatch.
      RESULT = l_lifnr1.
$$ end of routine - insert your code only before this line         -
  ENDMETHOD.                    "compute_0VENDOR
=====================================================
METHOD compute_ZVENDOR.
  IMPORTING
    request     type rsrequest
    datapackid  type rsdatapid
    SOURCE_FIELDS-/BIC/ZBAT_SUP TYPE /BIC/OIZBAT_SUP
   EXPORTING
     RESULT type tys_TG_1-/BIC/ZVENDOR
    DATA:
      MONITOR_REC    TYPE rsmonitor.
$$ begin of routine - insert your code only below this line        -
DATA:l_lifnr1 TYPE /BI0/MBATCH-VENDOR.
*Populating Supplying(finished) batch vendor
            select single VENDOR from /BI0/MBATCH
            into l_lifnr1
            where BATCH = SOURCE_FIELDS-/BIC/ZBAT_SUP.
     RESULT = l_lifnr1.
$$ end of routine - insert your code only before this line         -
  ENDMETHOD.                    "compute_ZVENDOR
===================================
thank you....

Similar Messages

  • Routine (ABAP Code)  in Transformation error

    Hi Experts
    Please correct the ABAP CODE written as Field routine in Transformations
    Requirment
    If  ZB_AMT = '0.00'
    then result should be '0.00'
    If  ZB_AMT <> '0.00' and
    SOURCE_FIELDS-/BIC/ZB_TPE1 = 'AMOUNT'
    the result should be
    CONCATENATE '$' SOURCE_FIELDS-/BIC/ZB_AMT INTO RESULT.
    If  ZB_AMT <> '0.00' and
    SOURCE_FIELDS-/BIC/ZB_TPE1 = 'PERCENTAGE'
    the result should be
    CONCATENATE  SOURCE_FIELDS-/BIC/ZB_AMT  '%' INTO RESULT.
    The code below is not working as it should please update me where i went wrong
    Source Fields
    SOURCE_FIELDS-/BIC/ZB_AMT (CHAR)
    SOURCE_FIELDS-/BIC/ZB_TPE1 (CHAR)
    CODE
    IF SOURCE_FIELDS-/BIC/ZB_AMT = '0.00'.
          RESULT = '0.00'.
        ELSE.
          IF SOURCE_FIELDS-/BIC/ZB_TPE1 = 'AMOUNT' AND
             SOURCE_FIELDS-/BIC/ZB_AMT <> '0.00'.
            CONCATENATE '$' SOURCE_FIELDS-/BIC/ZBON_AMT INTO RESULT.
            IF SOURCE_FIELDS-/BIC/ZB_TPE1 = 'PERCENTAGE' AND
               SOURCE_FIELDS-/BIC/ZB_AMT <> '0.00'.
              CONCATENATE SOURCE_FIELDS-/BIC/ZB_AMT '%' INTO RESULT.
            ENDIF.
          ENDIF.
        ENDIF.

    Your logic will not work, if your first check on amount is 0.00 fails, the other checks fail as well. I am not sure of the requirement but..try this..
    IF SOURCE_FIELDS-/BIC/ZB_TPE1 = 'AMOUNT' AND SOURCE_FIELDS-/BIC/ZB_AMT = '0.00'.
    CONCATENATE '$' SOURCE_FIELDS-/BIC/ZBON_AMT INTO RESULT.
    ELSEIF SOURCE_FIELDS-/BIC/ZB_TPE1 = 'PERCENTAGE' AND SOURCE_FIELDS-/BIC/ZB_AMT = '0.00'.
    CONCATENATE SOURCE_FIELDS-/BIC/ZB_AMT '%' INTO RESULT.
    ELSEIF SOURCE_FIELDS-/BIC/ZB_AMT = '0.00'.
      RESULT = '0.00'.
    ELSE.
    Do nothing or throw any message
    ENDIF.

  • Not able to remove the ABAP code from Transformation

    Hello Experts,
    We have transformation for DSO in that for one infoobject, field routine is written, Break Point is hard coded there and it's move to production. Now we are trying to remove that break point from development and then move it production.
    we are doing following activity to remove the break point.
    1. Open the transformation.
    2. Open the field routine.
    3. Going to ABAP code in field  routine.
    4. Remove the hard coded Break Point from ABAP code.
    5. Saving the code.
    6. It's taking to again filed routine window.
    7. We close the window and activate the transformation.
    8. When again check the ABAP code in field routine then it shows hard coded Break Point again.
    9. Not able to remove the hard coded break point.
    Can anyone know how to do this.
    Help will be appreciated.
    Thanks

    Hi,
    As pointed above, after point 6 don't simply close the window but click on Transfer Value and then activate your transformation. Refresh the system and check again.
    Regards,
    Arminder

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

  • (ABAP) Code in Transformation--Please explain

    I am getting a strange issue when used the below code
    Target : Charasteristic,Data Type CHAR 5
    Code:
    DATA: years TYPE tfmatage,
    months TYPE tfmatage.
    *DATA: result TYPE c LENGTH 5.(Showing error if included:Result is already declared)
    DATA: l_res TYPE p DECIMALS 2.
    IF source-field-/bic/zdob IS INITIAL.
    result = ''.
    ELSE.
    CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
    EXPORTING
    i_date_from = source-field-/bic/zdob
    i_date_to = sy-datum
    i_flg_separate = 'X'
    IMPORTING
    e_months = months
    e_years = years.
    if months 0.
    l_res = years + months / 100.
    WRITE l_res TO RESULT.
    else.
    write years to RESULT.
    ENDIF.
    ENDIF.
    WRITE / RESULT.
    I am using the above code (given by Mat in SDN) as a field routine in Transformations...can any one please explain me in detail(step by step) whats it doing.
    My requirment is to cal age of the employee in YY:MM format based on his DOB & SY datum.
    FIMA_DAYS_AND_MONTHS_AND_YEARS give Years & Months between 2 dates
    Please update me where i was doing wrong
    If months = 0 the the result should be only years
    Ex: if Months & Years of FM Output is 40Y,0M the i want only 40 to be updated insted of 40.00 so that the reason why i enhanced your code
    But it is giving me strange output
    For Output which got months it is being update correctly but
    for output for which months are 0 it is being update as
    If FM output is 40Y,0M
    then the output being updated is ' 40' (2 spaces before 40)
    In report i need to enter 2 spaces before 40 to retrive values of 40
    Please correct error
    Please ask if you need any info
    Thanks

    Hi,
    Are you using transformations?
    You should not use Result because Result field is a part of SAP generated code.
    Exclude declaration of result and check the code.

  • Routine (ABAP Code) in Transformation for the below sceaniro

    Hi Experts,
    Please update me with the routine (ABAP)(transformations)
    Source Char:
    Policy Start Date: ZSTRT_DTE (CHAR:Data Type: DATS)
    Target Char:
    Policy Expiry Date: ZEXP_DTE (CHAR:Data Type: DATS)
    FM: FIMA_VTBKOND_CALC_DATES
    Months(I_MONTHS) = 6
    Using Policy Start Date as input need to call the FM and months input is 6 MOnths and pass that result to Target char.
    Thanks

    Hi,
    try the following :
        CALL FUNCTION 'FIMA_VTBKOND_CALC_DATES'
          EXPORTING
            i_date   = source_fields-/bic/ZSTRT_DTE
            i_months = '6'
          IMPORTING
            e_date   = result.
    hope it helps...
    regards,
    Raju

  • Help with abap code in Transformation

    Hi Experts,
    we have a scenario where we load delta data from an DSO into a Cube.
    The records in the DSO looks like below.
    Location as (L)
    WorkOrder as (W)
    Startdate(DDMMYYYY)/time (HH:MM:SS) as (S)
    Finishdate/time as (F)
    L1
    W1
    21/04/2009/10:00:00
    21/04/2009/12:00:00
    L1
    W2
    21/04/2009/14:00:00
    21/04/2009/23:00:00
    || L1 ||W3||  21/04/2009/16:00:00 ||21/04/2009/20:00:00 || 
    Total time ( April 2009 ) for above Location L1 should be calculated as a difference between W1 and W2 since W3 is a overlapping record. So the result would be 13 Hrs. Work Orders are summarised, so we dont need work order info in the output.
    Can you experts help me with the code to implement??
    Thanks,
    DV

    For each location, for example L1, move the records to an internal table itab.
    sort itab by startdate.
    read table itab index 1. 
    You will get the first value.
    sort itab by finishdate descending.
    read table itab index 1.
    you will get the second value.
    Calculate the difference and populate it to the internal table.
    finally modify the source package.
    I have just given the logic.  I hope you can build upon this.
    I hope it helps.
    Thanks.

  • (ABAP) Code in Transformation--TO ADD LEADING ZERO FOR VALUES 10

    Hi,
    I am calculacting years and months between 2 given dates by using a Function Module.
    The result of FM will be E_YEARS & E_MONTHS
    as per my requirment i need to present the output in YY.MM format for that reason i am doing the below calculaction
    l_res = years + months / 100.
    WRITE l_res TO RESULT.
    ENDIF.
    (Ex: Y-40 & M-9 the the output will be 40.09 from above calculaction)
    I want to include a condition in above logic if years<10 then i want to add 0 in front of it.
    Ex: Y-9,M-8 THEN the output should be 09.08 (YY.MM)
    pLEASE UPDATE ME WITH THE LOGIC
    tHANKS

    Hello,
    You can format the output like YY.MM
    See this [Formatting Options|http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9e3d35c111d1829f0000e829fbfe/content.htm]
    You can also use USING EDIT MASK Statment
    Date format
    Thanks
    Chandran

  • ABAP code for BI 7.0 transformations start routine

    Hi all,
    I am trying to update data from DSO1 (Source1: transaction data) to Infocube(TARGET)
    In the transformations Start routine, I have to read DSO2(Source2: Master data) for some fields.
    DSO1 has CUSTOMER as part of key
    DSO2 has CUSTOMER (key) and other fields....FIELD1, FILED2, FIELD3
    Infocube to be updated with FIELDS1,2 & 3 WHILE READING DSO2.
    WHERE DSO1 CUSTOMER matches with DSO2 CUSTOMER.
    Also, data NOT TO BE UPLOADED into Infocube if FIELD1 in DSO2= NULL
    Please give me the abap code for the above logic.
    Appreciate any help in this regard.
    Thanks.

    This is a doc from this site:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6090a621-c170-2910-c1ab-d9203321ee19
    Ravi Thothadri

  • 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

  • Needs sample ABAP code for field routine

    Dear Expert,
    There is a field "Pay Scale Group" in my DSO which stores the data in the format
    AA1/B1/CCC2/DD2/EEE1, A1/BB2/CC2/DDD3/EE2 etc. These data has to be transferred to
    InfoCube where "pay Scale Group" in the InfoCube will store the data like EEE1,EE2 etc.
    I need to write a field routine on the transformation between DSO and Cube.
    Can any one please help me with the sample ABAP code for this scenario.
    Some more examples for better understanding of the requirement:-
    Data in DSO(Source)            Data in Cube(Target)
    ===================            ===================
    AA1/B1/CCC2/DD2/EEE1            EEE1
    AAA1/BB2/CC1/DDD3/EE2           EE2
    A2/BBB2/CC2/DDD3/EEE5           EEE5
    AA2/BB1/C1/DDD3/EE3             EE3
    A3/B1/CC2/DDD1/EE4              EE4
    Many thanks in advance.
    Regards,
    Prakash
    Please do not dump your code requirements in SDN
    Edited by: Pravender on May 18, 2011 11:37 AM

    Hi,
    You can use the following code :
    Suppose the technical name of the field coming from DSO is ZPAY_SGRP.
    And also for example let me take one record, that is ZPAY_SGRP = AA1/B1/CCC2/DD2/EEE1 .
    My assumption is that there will always be 4 '/'.
    In the field routine write the below code
    data: V1(5) type c,
              V2(5) type c,
             V3(5) type c,
              V4(5) type c,
             V5(5) type c.
    data : VAR1 TYPE /BIC/OIZPAY_SGRP.
    split VAR 1  at '/' into V1 V2 V3 V4 V5.
    result = V5.
    V5 will be having the characters after the last '/' .That is V5 = EEE1.
    Hope the above reply was helpful.
    Kind Regards,
    Ashutosh Singh
    Edited by: Ashutosh Singh on May 17, 2011 3:53 PM
    Edited by: Ashutosh Singh on May 17, 2011 4:17 PM

  • ABAP code needed to convert from 0calmonth2 & 0calyear to 0calmonth

    Hi SAP GURUS,
    Can anybody give me the ABAP code to convert from 0calmonth2 and 0calyear to 0calmonth.and please suggest me whether i have to write start routine or end routine in transformations.
    Thanks ALL.

    hi,
    in the transformation map 0calmonth2 and 0calyear to the 0calmonth field, and from drop down choose routine.
    there will be an area where it will be mentioned write your piece of code below this line.
    paste the below code:
    Concatenate source_fields-0calmonth2 source_fields-0calyear into result.
    also delete the line result = .
    save the routine and execute the package.
    regards,
    Arvind.

  • 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

  • LOOKUP-Master Data Attribute (ABAP Code)

    Hi,
    My requirment
    ZCOMPANY is an attribute of ZCostcenter
    ZCost center is an attribute ZEMPLOYEE
    zcomp is an attribute of employee
    While Loading attribute data to employee i need to write Lookup/routine in transformations that will
    Based on ZCOSTCENTER data of an employee i has to read setup tables in BW and update ZCOMP of an employee(attribute) from ZCOMPANY  of ZCostcenter
    Please update me with the ABAP Code
    Thanks in advance

    Hi,
    This is the routine written in transformations.
    My requirment is to modify this a bit to include following conditions
    1)source_fields-costcenter
    (It needs to be converted to CAPS)(Bcaz ZCOSTCENTER consists all the caps)
    2)I want to include 'OBJVERS'='A' in the code
    Please update me with the code
    select /bic/zcompany from /bic/mzcostcenter
    into result
    where zcostcenter = source_fields-costcenter.
    end select.
    Thanks

  • APD ABAP Code

    Hi,
    Please help me with quick ABAP code in APD transformation.
    This is the requirement:
    When ever  /BI0/OIG_QVV010  is zero ,  /BIC/OIZENDUSER  value should be blank.
    Here is the code template needs modification:
    REPORT RSAN_WB_ROUTINE_TEMP_REPORT .
    TYPES: BEGIN OF y_source_fields ,
             KYF_0001 TYPE /BI0/OIG_QVV010 ,
             KYF_0001_UNIT TYPE MEINS ,
            CALMONTH TYPE /BI0/OICALMONTH ,
             MATERIAL TYPE /BI0/OIMATERIAL ,
             /BIC/ZENDUSER TYPE /BIC/OIZENDUSER ,
             END OF y_source_fields .
    TYPES: yt_source_fields TYPE STANDARD TABLE OF y_source_fields .
    TYPES: BEGIN OF y_target_fields ,
             KYF_0001 TYPE /BI0/OIG_QVV010 ,
             KYF_0001_UNIT TYPE /BI0/OIG_UVV010 ,
              CALMONTH TYPE /BI0/OICALMONTH ,
              MATERIAL TYPE /BI0/OIMATERIAL ,
             /BIC/ZENDUSER TYPE /BIC/OIZENDUSER ,
           END OF y_target_fields .
    TYPES: yt_target_fields TYPE STANDARD TABLE OF y_target_fields .
    *---- Begin of type definitions -
    *TYPES: ...
    *---- End of type definitions -
    FORM compute_data_transformation
         USING     it_source TYPE yt_source_fields
                   ir_context TYPE REF TO if_rsan_rt_routine_context
         EXPORTING et_target TYPE yt_target_fields .
    *---- Begin of transformation code -
    DATA: ls_source TYPE y_source_fields,
            ls_target TYPE y_target_fields.
      LOOP AT it_source INTO ls_source.
        MOVE-CORRESPONDING ls_source TO ls_target.
        APPEND ls_target TO et_target.
      ENDLOOP.
    *---- End of transformation code -

    How about this?
    LOOP AT it_source INTO ls_source.
      IF ls_source-kyf_0001 EQ 0.
        CLEAR ls_source-/bic/zenduser.
      ENDIF.
      MOVE-CORRESPONDING ls_source TO ls_target.
      APPEND ls_target TO et_target.
    ENDLOOP.

Maybe you are looking for

  • LR4 problem or PS problem?

    When I export an image from LR4 to Bridge for final retouching in PSE9 (as a 16-bit PSD file), the file doesn't show a thumbnail image on Bridge, only static. I can call it up, do editing and change it to 8-bit, but when I try to save it, I get this

  • Im trying to download Final Cut Pro from the App store but I keep getting an error message when I hit "buy app"

    Im trying to download Final Cut Pro from the App store but I keep getting an error message when I hit "buy app" The error message reads: We could not complete your request, please contact Itunes support to complete this option.

  • EXT Display Format LabVIEW bug

    Up for grab, this easy bug (tested in LV 2012.0f3 (32 bit) on Windows XP) From a clean start, create a new VI, drop a "Power of x" function and create control for all input and output. Set the representation of the controls/indicators to be "Extended

  • Restricting a characteristic

    Hi Guys can you please give me advise on how to restrict a characteristic to a certain value in a query i.e. i want the cells with "CE/#" only to show in the report. The characteristic is not a key figure. thanks

  • Find and Replace more then one character

    Hi I need to find and replace more then one character. for example: I need to replace "A" with "a". "B" with "b" and so on. how to do that in one search?