ABAP routine in DTP

hi,
I need some help withe ABAP routine in the DTP selection
I have requirement to load the data for specific company codes on a specific days.
If the current date is monday then it should pick Taiwan  or
if the current date is Tuesday the it should pick Australia and Korea or
if the current date is sunday then it should pick CHINA and Vietnam.
I want to use only one DTP for this requirement. Please help me with the code for Info Object 0COMP_Code.
Regards,
Raghu

hi,
I have tried the code and it is not populating any value in the selection.
Please check
data: l_idx like sy-tabix.
data: day like SCAL-INDICATOR.
*Finding out the day
  clear day.
  CALL FUNCTION 'DATE_COMPUTE_DAY'
    EXPORTING
      DATE = sy-datum
    IMPORTING
      DAY  = day.
  read table l_t_range with key
       fieldname = 'COMP_CODE'.
  l_idx = sy-tabix.
case day.
    when 1.                                 "Monday
      l_t_range-low = '0711'.
      l_t_range-high = ' '.
      l_t_range-option = 'EQ'.
      l_t_range-sign   = 'I'.
      modify l_t_range index l_idx.
    when 2.                                 "Tuesday
      l_t_range-low = '0355'.
      l_t_range-high = ' '.
      l_t_range-option = 'EQ'.
      l_t_range-sign   = 'I'.
      modify l_t_range index l_idx.
    when 3.                                 "Wednesday
     l_t_range-low = '0211'.
      l_t_range-high = ' '.
      l_t_range-option = 'EQ'.
      l_t_range-sign   = 'I'.
      modify l_t_range index l_idx.
   when 4.
   when 5.
   when 6.
   when 7.
     l_t_range-low = 'China'.
     l_t_range-high = ' '.
     l_t_range-option = 'EQ'.
     l_t_range-sign   = 'I'.
     modify l_t_range index l_idx.
endcase.
p_subrc = 0.

Similar Messages

  • Abap Routine in DTP Filter with selection in a table

    Hi guys,
    I need help please.
    I'm trying include a abap routine in a DTP filter, for this case I need to make a select in a dso table and return a list of criterias.
    Example: for this characteristic 0GL_ACCOUNT i need in a fiter 20 or more 0GL_ACCOUNT of table  "/BIC/DSO_XXX".
    How can I select more than one 0GL_ACCOUNT in a tranparency table  "/BIC/DSO_XXX"... and put in a DTP Fiter.
    DTP FILTER ROUTINE.
    data: l_idx like sy-tabix.
              read table l_t_range with key
                   fieldname = 'GL ACCOUNT'.
              l_idx = sy-tabix.
              if l_idx <> 0.
                modify l_t_range index l_idx.
              else.
                append l_t_range.
              endif.
              p_subrc = 0.

    Try this:
    DATA: lv_rows TYPE n LENGTH 10,
            it_zbw_pl_proj LIKE STANDARD TABLE OF /BIC/DSO_XXX 
            lw_zbw_pl_proj LIKE LINE OF it_zbw_pl_proj .
      SELECT COUNT(*) INTO lv_rows FROM  /BIC/DSO_XXX Where <your condition> .
    SELECT * INTO TABLE it_zbw_pl_proj FROM zbw_pl_proj where <your condition>
      IF lv_rows <> 0.
        LOOP AT it_zbw_pl_proj INTO lw_zbw_pl_proj  .
          l_t_range-iobjnm = '/BI0/GL_ACCOUNT'.
          l_t_range-fieldname = 'GL_ACCOUNT'.
          l_t_range-sign = 'I'.
          l_t_range-option = 'BT'.
          l_t_range-low = lw_zbw_pl_proj-GL_ACCOUNT.
          l_t_range-high = lw_zbw_pl_proj-GL_ACCOUNT.
          APPEND l_t_range.
        ENDLOOP.
      ELSE.
        " No data found for Current Forecast Version.
        p_subrc = 4.
      ENDIF.
    I just copied this data from a DTP routine where i am fetching Versions from a DB table zbw_pl_proj. You may need to change the naming convention and performance tune the code ( like defining internal table only to hold GL_account and then only selecting GL_Account from ODS).
    Hope this helps!
    Regards
    Amandeep Sharma
    Edited by: AmanSharma123 on Jul 14, 2011 2:42 PM

  • ABAP routine for DTP fiscal year/period filter

    Hi All,
    Delta loads are which not possible for when the transformation source is an InfoSet.  To limit the data in these loads, currently a filter is set in the DTPs on fiscal year/period so only load the current month and 2 prior months are loaded.  This filter has to be updated each month for each of the DTPs manually.  To eliminate this monthly task a dynamic filter (routine) needs should be used rather than a static filter. Can anybody help me in providing the logic
    Regards
    Siri

    data: l_idx like sy-tabix.
    read table l_t_range with key
         fieldname = give field name .
         Data : Year(4) type n,
                   period1(2) type n.
                   period2(2)type n.
    Currper = sy-datum+4(2) .
    period1 = currper-1 .
    period2 = currper-2.
    year = sy-datum+0(4).
    concatenate  year currper to P1.
    concatenate  year period1 to P2. // define P1 , P2 , P3 as 0fiscper .
    concatenate  year period2 to P3.
    l_t_range-sign = 'I'.
    l_t_range-option = 'BT'.
    l_t_range-low =  P3.
    l_t_range-high=  P1.

  • Routine in DTP to load data from previous fiscal period - current

    Hi Friends,
    I want to load data for previous & current fiscal period and I want to write a routine in DTP to automate this process, can any one help me with this routine!
    Thanks & Regards,
    vidiyala

    Hi Bilal,
    We cant create ABAP routine in DTP, instaed we can create in Info package.
    $$ begin of routine - insert your code only below this line -
    data : v_date like sy-datum.
    data : v_new_date like sy-datum.
    data: l_idx like sy-tabix.
    read table l_t_range with key
    fieldname = ' '.
    l_idx = sy-tabix.
    v_date = sy-datum.
    l_t_range-low = v_date+0(6).
    CALL FUNCTION 'DATE_CREATE'
    EXPORTING
    *anzahl_jahre =
    anzahl_monate = 8
    *anzahl_tage =
    datum_ein = v_date
    IMPORTING
    datum_aus = v_new_date.
    l_s_range-sign = 'BT.
    l_s_range-opt = 'I'.
    if l_idx 0.
    modify l_t_range index l_idx.
    else.
    append l_t_range.
    endif.
    p_subrc = 0.
    $$ end of routine - insert your code only before this line

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

  • ABAP Routine Variable in DTP filter

    Helllo,
    I am trying to create a routine in the Filter of DTP, so that I can only pass records that are between sy-datum and 12/31/9999 date range. In the filter are of DTP I created ABAP routine with this code:
    form compute_HE_SPCEND
      tables l_t_range structure rssdlrange
      changing p_subrc like sy-subrc.
          Insert source code to current selection field
    $$ begin of routine - insert your code only below this line        -
    data: l_idx like sy-tabix.
              read table l_t_range with key
                   fieldname = 'HE_SPCEND'.
              l_idx = sy-tabix.
              data: v_day type dats.
              v_day = sy-datum.
              l_t_range-sign = 'I'.
              l_t_range-option = 'BT'.
              l_t_range-low = v_day.
              l_t_range-high = '99991231'.
                modify l_t_range index l_idx.
              p_subrc = 0.
    $$ end of routine - insert your code only before this line         -
    endform.
    However, when I execute the DTP I get an ABAP dump TABLE_INVALID_INDEX. Do you see anything wrong with the code?
    Thank you
    Edited by: AG on Jul 10, 2009 2:31 PM

    Thanks Mr V.
    I added that part of code. So now my code looks like this:
    form compute_HE_SPCEND
      tables l_t_range structure rssdlrange
      changing p_subrc like sy-subrc.
          Insert source code to current selection field
    $$ begin of routine - insert your code only below this line        -
    data: l_idx like sy-tabix.
              read table l_t_range with key
                   fieldname = 'HE_SPCEND'.
              l_idx = sy-tabix.
              data: v_day type datum.
              v_day = sy-datum.
              l_t_range-sign = 'I'.
              l_t_range-option = 'BT'.
              l_t_range-low = v_day.
              l_t_range-high = '99991231'.
             if l_idx <> 0.
                modify l_t_range index l_idx.
              else.
                append l_t_range.
              endif.
              p_subrc = 0.
    $$ end of routine - insert your code only before this line         -
    endform.
    I do not get the ABAP dump anymore, but I still have the problem. When I run the DTP, It gets errors. In a log it says that it cannot determine the value:
    @5C@     Incorrect initial value for characteristic 0HE_SPCEND in i_t_range     @35@
    @5C@     Error while extracting from source ZHE_O03 (type DataStore)     @35@
    @5C@     Package 1 / 07/10/2009 14:43:41 / Status 'Processed with Errors'     @35@
    Am I missing something? Looks like the values still do not get assigned to the field in the filter through my routine.
    Thanks

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

  • How to convert the 3.x ABAP Routines into BI 7 ABAP Routines

    Hi All,
    I am trying to convert a BI 3.x data flow into BI 7 data flow suing DTP's.
    But i am stuck at Transformations. We have used several Routines in 3.X data flow and those routines are not converted automatically into the new data flow.
    Is there any other tool or program whcih will convert the ABAP routines automatically into the new ABAP format.
    my sample ABAP 3.x Code looks like this in Start routine,
    LOOP AT DATA_PACKAGE.
        IF (     DATA_PACKAGE-CPPVLC  EQ 0
             AND DATA_PACKAGE-CPPVOC  EQ 0
             AND DATA_PACKAGE-CPSTLC  EQ 0
             AND DATA_PACKAGE-CPQUAOU EQ 0
             AND DATA_PACKAGE-CPSVLC  EQ 0 ).
          DELETE DATA_PACKAGE.
          CONTINUE.
        ENDIF.
    I tried to replace DATA_PACKAGE with SOURCE_PACKAGE, but it did not work.
    any help will be appreciated.
    Cheers
    POPS

    I tried to replace DATA_PACKAGE with SOURCE_PACKAGE, but it did not work.
    When you use SOURCE_PACKAGE it will not have header line so you need to use workarea.
    Use something like
    LOOP AT SOURCE_PACKAGE into WA_SOURCE_PACKAGE.
    Define WA_SOURCE_PACKAGE of type SOURCE_PACKAGE.
    and replace further data_package in the code with WA_SOURCE_PACKAGE
    Hope this helps.
    Edited by: Praveen G on Jan 27, 2009 4:10 AM

  • Populate new fields in DSO (DBTable) with ABAP routine

    Hi,
    I've added a couple of fields to a DSO. The DSO contains a large number of records (60m+) and I have a tight window to cutover so the activation time would be an issue if I use a loop transformation. Therefore, I am looking to populate the additional fields directly in the Active table using an ABAP routine.
    One of the fields is a key figure to be derived from an existing CHAR field so would need to apply some logic during update, such as IF <CHAR_FIELD> CA 'ABC'. <KYF_FIELD> = 1 etc.
    Aside from fairly basic Start Routines my ABAP is very poor so was wondering if anyone can help me with the syntax or, preferably some sample code to achieve this.
    Thanks in advance,
    Ad

    Hi,
       In transformation of the cube, choose routine  for char E.
       There you can assign value in RESULT field. Actually RESULT field is assigned to E, find the code below,
    *--  fill table "MONITOR" with values of structure "MONITOR_REC"
    *-   to make monitor entries
    ... "to cancel the update process
       raise exception type CX_RSROUT_ABORT.
    ... "to skip a record
       raise exception type CX_RSROUT_SKIP_RECORD.
    ... "to clear target fields
       raise exception type CX_RSROUT_SKIP_VAL.
      (* insert your abap code here to find the value of E*.)
         RESULT =                     * assign the value you got for E here.
    rgrs,
    v.sen

  • ABAP Routine in selection of Info package in 3x

    Hello Experts
    We need to load distinct PO data in 3x server.
    I have added this distinct po values in range table of info package abap routine.
    However its not loading for range table values more than two selections/pos.
    If I try to append more than 2 values,only last one is uploaded.
    However after load, in monitor tab-header , selection paramenters I can see all PO values in selection.
    Some how it works only for two inputs (rows) in range table of ABAP routine in infopackage.
    Anybody has faced such issue? any help is appreciated!
    Edited by: Kanchan Angalwar on Jan 30, 2010 9:59 AM

    Hi,
    Please post your ABAP code here

  • Call function in abap routine of infopackage

    Experts,
    Good day. I have a problem concerning the data to be imported in my ods.I can't find a similar thread corcerning my problem. My ‘File date’ field should contain only 2 years and 3months data of recent data. I'm using a call function fima_date_create to filter values of zfile_date.
    CALL FUNCTION 'FIMA_DATE_CREATE'
      EXPORTING
        I_DATE                             = sy-datum
        I_FLG_END_OF_MONTH   = ' '
        I_YEARS                          = 2-
        I_MONTHS                        = 3-
        I_DAYS                             = 0
        I_CALENDAR_DAYS          = 0
        I_SET_LAST_DAY_OF_MONTH       = ' '
      IMPORTING
        E_DATE                             =
        E_FLG_END_OF_MONTH   =
        E_DAYS_OF_I_DATE         =   
    The sy-datum becomes the “High” value and the date generated by this FM will be the “low” value. I already tested this function module and it is what i want. How Should I write the ABAP code for this in the abap routine for my infopackage? Or what steps do I need to take.

    Hi,
    When you choose the option to write a routine for one of the characteristics in the infopackage selections, you get a window to write your code with some prewritten code as below. Modify it as shown below, for your requirement.
    data: l_idx like sy-tabix.
    read table l_t_range with key
         fieldname = 'CALDAY'.
    l_idx = sy-tabix.
    START of YOUR CODE
    <----
    Required logic -
    >
    L_T_RANGE-LOW  = <lower limit of range>.
    L_T_RANGE-HIGH = <upper limit of range>.
         L_T_RANGE-SIGN = 'I'.
         L_T_RANGE-OPTION = 'BT'.
    END of YOUR CODE
    modify l_t_range index l_idx.
    p_subrc = 0.
    Hope this helps.

  • ABAP Routine code for the below logic

    Hello BW Experts ,
    I need to write a complex ABAP routine in BW .
    Following is the detail explaination .
    Can anyone tell me the ABAP code for the below logic?
    It would be a greate help as I am unable to do this
    since last two days.
    WBS Elements are maintained at  IOS and  Warranty levels in R/3 side.
    The IOS WBS is a top level of WBS element and below that the Warranty WBS level.
    The IOS and Warranty WBS elements can be differentiated by means of priority field.
    When priority = i   , WBS Element is known as  IOS Level WBS Element and
    When  priority = Y the WBS element is known as Warranty WBS element.
    The Equipment Number is maintained compulsorily at IOS Level WBS elements only.
    It is not maintained at  Warranty WBS Element.
    But the Cost is maintained at Warranty WBS Elements.
    In BW I need all Warranty WBS ( priority = Y) along with their cost figures and Equipment Numbers.
    But as the Equipment Number is not maintained compulsorily at Warranty WBS level we have asked to
    Copy it from  IOS WBS ( priority = i ) and assign it to Warranty WBS level ( priority = Y ).
    So I have included the Equipment Number in the ODS and in update rules I need to write the routine for it as
    per the above logic.
    The Equipment Number is coming from Master data of  WBS Element.
    The WBS element master data we are loading in BW .
    Also the same WBS Element transaction data is coming from the transaction data data source in BW.
    Following fields / infoobjects and the table names in BW :
    1. Equipment Number : /BIC/ZEQUIPMNT  and table name /BIC/MZWBS_ELEM.
    2. WBS Element       : ZWBS_ELEM  is coming from transaction data data source as well as master data.
                                     In ODS update rules it is coming from  transaction data data source Comm_structure-ZWBS_ELEM.
                                     Also we are loading separetly the master data for ZWBS_ELEM.
                                     The  ZEQUIPMNT is an attribute of ZWBS_ELEM.
    3. Priority                :  PRIORITY     and table name /BIC/MZWBS_ELEM.
                                      The info object name for Priority is 0Priority but in master data table /BIC/MZWBS_ELEM
                                      the field name is    PRIORITY.
                                     When PRIORITY = ' i ' then    ZWBS_ELEM is at IOS Level
                                     When PRIORITY = ' y ' then  ZWBS_ELEM is at Warranty Level.
    4. ODS name :  /BIC/AZCOST00 and same is table name active data table .
    So please tell me the routine Code .
    Best Regards ,
    Amol.

    Hi Dinaker,
    Did you find any solution for this issue. I too have a similar requirement of pulling all the service orders for a specific Purchase Order in the BW report.
    Thanks,
    SAPBWI

  • ABAP Routine in UR Help

    Hi Friends
    We are on BI7 and ECC6.
    We have to get the quantities into BI from ECC for that we are using one field from 2lis_11_vaitm. But we want to count the quantity only when material is a complete package all other values should be 0. Packages are described in the material as for example DMS PACKAGE , DST PACKAGE , DTTS PACKAGE DTTTT PACKAGE.
    Now My thinking is ,Inorder to do that we have to use the offsets in ABAP routine. But the first few letters are not 3 / 4 fixed it may be 3, 4, 5 or 6 letters the PACKAGE will start from the next word..
    Can any one help me how to write the ABAP logic to get the offset for last 11 letters ?
    regards

    F2 & F3 TYPE I.
    F1 = 'DTTS PACKAGE' (F1 contains the value)
    F2 = LENGTH(F1) (F2 determines the length of the field)
    OR
    F2 = STRLEN(F1)
    F3 = F2 - 11 (F3 determines the difference)
    F4 = F1+F3(11) (F4 picks up value based on offset)
    *Not sure if variables are accepted for offsets.

  • ABAP routine in infopackage that runs function in ECC

    Hi All
    I need to have dynamic filter in the info package
    I have program in ECC that brings me the value that I need to filter in my info packege
    I want to use  ABAP routine in infopackage that runs function in ECC and brings the value that was received from the ECC function
    Is that possible?
    Thanks

    Hi All
    my CTO found the following option
    function module that is "remote-enabled module "
    then you call CALL FUNCTION 'Y_FM_IDOC_CATSDB' DESTINATION 'SAP4.7E'
    you need to define it in SM59
    code example
    data: BEGIN OF IT_SOBSL OCCURS 0,
          SOBSL(2),
          END OF IT_SOBSL.
    DATA: ls_range type STANDARD TABLE OF rssdlrange WITH HEADER LINE.
    SELECT /BIC/ZSPEPROCI FROM /BIC/SZSPEPROCI INTO TABLE IT_SOBSL
                          WHERE /BIC/ZSPEPROCI NOT BETWEEN 'AA' AND 'ZZ'
                          AND /bic/zspeproci ne '' .
    BREAK-POINT.
    LOOP AT IT_SOBSL.
    ls_range-IOBJNM = 'SOBSL'.
    ls_range-LOW = IT_SOBSL-SOBSL.
    ls_range-SIGN = 'I'.
    ls_range-OPTION = 'EQ'.
    APPEND ls_range .
    ENDLOOP.
    loop at ls_range.
      append ls_range to l_t_range.
    endloop.

  • ABAP routine in Infopackage

    I am in the process of creating an ABAP routine in the Infopackage to load current month based on system data from one cube in BW to another Cube in BW. I am getting the following error in the load. I am not an ABAPer and would appreciate if you can help or guide me with a sample code.
    Here is the error.
    For sel. field '/BIC/Z_APOSNAP', no selection with SIGN = ''; OPTION '' allowed.
    Thank you
    Neelu

    Hi Neelu,
    U can create a ABAP Routine of the type 6 (ABAP Routine),The field you are trying to populate is a select-option so you have to define both Sign and Option along with Low and High values.
    As u want to load current month, from a system values , u can do it from sy-datum.
    data: l_idx like sy-tabix.
              read table l_t_range with key
                   fieldname = ''/BIC/Z_APOSNAP'.
                l_idx = sy-tabix.
                l_t_range-low = 
                l_t_range-high = 
                l_t_range-sign =
                l_t_range-option =
          modify l_t_range index l_idx.
              p_subrc = 0.
    Just u can fill Sign as 'I' and Option 'EQ'.
    Fill Low and High with values u get from System Data.
    Hope this Helps,
    Thanks,
    Krish
    **awarding points is way of saying thanks in SDN.

Maybe you are looking for

  • When trying to unistall office 2010 my computer restarts itself.... HELP!

    When I try to uninstall office home and student 2010 my computer restarts itself approx. 1 min after. how do I get rid of this? I have a sony vaio t series.....

  • Playing from a jump drive

    Can my friend put some songs purchased from iTunes onto his thumb drive and play them on my computer using my iTunes? I don't want to copy them, just play them.

  • Set custom generated password during create user and email to user

    Hi, In OIM 11g r2, I want to  generate password using some logic and send a notification to the user with the generated password during user creation. Please let me know how to achive that.. can I use some post process event handler?? if yes then how

  • Distribution and Assessment

    Hi, I want to know what is the exact difference between distribution and assessement in CO. What situation we do distribution and assessment. Regards Babu

  • ABAP smart forms integration with CRM

    Hi As our ABAPers created their smartforms, now i need to integrate there designed smartforms with our CRM server. How to do it, what is the procedure...??? To do this process i worked on this following area. That is i went into Content Management in