ABAP Routine in the Infopackage data selection

All,
I have requirement where i need to write a routine on a Date field(Activity Year Month) which has to return values from the first to the last day of the Previous month in the data selection of the infopackage.
I know that on Date there is a STD that can be used but my requirement is on Year Month.
there are 3 vartypes available
5. free temporal selection
6. ABAP routine
7. OLAP variable
when i pick ABAP routine it asks me to create a routine i need some help with the code here
Can someone help.
Thanks

Hi there
If the Data field is 0FISCPER you can use the OLAP variable 0P_PRFP1. If you have developed the field yourself i think you need to write code. The code could look something like this.
DATA:  sysdat TYPE d.
  sysdat = sy-datum.
  sysdat4(2) = sysdat4(2) - 1.
  IF sysdat+4(2) = '0'.
    sysdat+4(2) = '12'.
    sysdat(4) = sysdat(4) - 1.
  ENDIF.
  CONCATENATE sysdat(4) '0' sysdat+4(2) INTO l_t_range-low.
  MODIFY l_t_range INDEX l_idx.
  p_subrc = 0.
This code returns the previous months as a single value.
Chris

Similar Messages

  • ABAP routine in the infopackage for Multiple Selection

    Hi experts,
    I want to include a abap routine in the infopackage for Multiple Selection so that I can fetch only the required Material Numbers when the InfoPackage is schedule. As I have the constraints that I have to select certain Material Numbers only, that are not in series - so I cannot select"BT' fuction. Tell me what ABAP Code will work in this scenario.
    Kind regards,
    Rajesh Giribuwa

    Hi,
    The Routine will have to use 'EQ' operator and Append each selections to the Structure.
    ABAP Routine
    InfoPackage definition for Bespoke SIS Structure
    Infopackage routine !
    Regards
    Happy Tony

  • ABAP Routine in the InfoPackage

    Hello,
    I need to write an ABAP Routine in the infopackage to populate the selection conditions automatically. Coding is for Fiscal year/Period and it should be populated as LOW - Pervious period and HIGH - Current period.
    I tried to do the coding myself but couldn't able to fetch the current and previous periods. I would be grateful if some one can share the code with me.
    Best Regards,
    Nene.

    Hello,
    Try this.
    1) Identify the current period by inputting sy-datum to function module  'DATE_TO_PERIOD_CONVERT'.
    2) Find the first day of current period using function module
        'FIRST_DAY_IN_PERIOD_GET'
    3) Minus one day from the first day of current period to get previous period last date.
    4) Call the same function module 'DATE_TO_PERIOD_CONVERT' by inputting the previous period last date (derived in step 3).
    5) Pass the values to the infopackage code.
    $$ begin of routine - insert your code only below this line        -
    data: l_idx like sy-tabix.
      read table l_t_range with key
           fieldname = '<field name>.
      l_idx = sy-tabix.
      l_t_range-SIGN   = 'I'.
      l_t_range-OPTION = 'BT'.
      l_t_range-LOW    = <previous period> (refer step 4)
      l_t_range-HIGH   =  <current period>  (refer step 1)
      modify l_t_range index l_idx.
    Thanks
    Viswa
    (Assign points if helpful).

  • NOT EQUAL in the InfoPackage Data Selection

    Hello,
    <u><b>I need to build a NE, NOT EQUAL <>  in an InfoPackage</u></b>
    I need to exclude some DataSets from beeing loaded.
    The DataSets to be excluded can be distinguished by a
    certain value of a an InfoObject.
    For example:
    All DataSets with  0COMPANY_CODE NOT EQUAL "0001" should not
    be loaded.
    How can I set in the InfoPackage DataSelection a filter
    to exclude some DataSets ?
    Thank You
    Martin Sautter

    Hello Chitrarth Kastwar ,
    basically it would be a trivial task in SQL ....to code :
    <i>
    SELECT *
    FROM
    WHERE  0COMP_CODE not in '0001'
    </i>
    or
    <i>
    SELECT *
    FROM
    WHERE  0COMP_CODE =  '0030'
    OR          0COMP_CODE =  '0040'
    OR          0COMP_CODE =  '0050'
    </i>
    .. but thats BW  - It generates much turnaround for consultants :).
    Thread
    /community [original link is broken] threadID=507511&tstart=0
    seems to be something like this.
    ...I get the following Conversion Routine for Type 6:
    <i>
    program conversion_routine.
    Type pools used by conversion program
    type-pools: rsarc, rsarr, rssm.
    tables: rssdlrange.
    Global code used by conversion rules
    $$ begin of global - insert your declaration only below this line  -
    TABLES: ...
    DATA:   ...
    $$ end of global - insert your declaration only before this line   -
        InfoObject      = ZVPUNITH
        Fieldname       = /BIC/ZVPUNITH
        data type       = CHAR
        length          = 000045
        convexit        =
    form compute_/BIC/ZVPUNITH
      tables   l_t_range      structure rssdlrange
      using    p_infopackage  type rslogdpid
               p_fieldname    type rsfnm
      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 = '/BIC/ZVPUNITH'.
              l_idx = sy-tabix.
              modify l_t_range index l_idx.
              p_subrc = 0.
    $$ end of routine - insert your code only before this line         -
    endform.
    </i>
    Because I have to exclude 1 value out of 5 I can also include 5 values in the
    selection criteria connected with OR
    This means I have to use an OR only.
    Is it possible with l_t_range to state this and how ?
    Thank You
    Martin Sautter

  • Infopackage Data Selection

    Hi Experts,
    I have a infopackage 000 version fullload. When we load version 000 based on the current period we need to go back 12 months and go forward 6 months. This should be done via a ABAP routine in the infopacakge.  I have included the ABAP routine in the infopackage.  Loaded data based on current period when i refresh the workbook it has displayed empty results.  I check with R/3 system for 000 version data is available. 
    Regards
    Prasad

    Hi,
    First Check if the Routine in the IP is working good by using the Test tab in selection Screen.
    If you find OK then Check if the selections used in the Wkbook are a subset of data loaded.
    Also do some minor checks like request rolledup or not.
    Thanks,
    Prasad

  • How to debug a ABAP Routine which is in Infopackage Data selection Tab

    Hi ,
       Please let me know How to debug a ABAP Routine which is in Infopackage Data selection Tab.

    Hi,
    You can try to create infinite loop:
    DATA: STOP.
    WHILE STOP IS INITIAL. ENDWHILE.
    Start InfoPackage and then go to SM50 and swich on debugging for your process. Then in debugger you can change value of STOP variable to skip the loop.
    Krzys

  • Abap routing in infopackage data selection

    Hi guys
    I'm using an ABAP routin for the Data selection in my infopackage. I want to fetch all the records which is having value Less than 'IN14' for company code.I have modifuied the l_t_range as shown
              l_t_range-sign = 'I'.
              l_t_range-option = 'LT'.
              l_t_range-low = 'IN14'.
              modify l_t_range index l_idx.
    But while executing, its giving the followinf error message.
    "For sel. field 'COMP_CODE', no selection with SIGN = 'I'; OPTION 'LT' allowed"
    Does anybody knows what should be done for this?
    Regards
    Sriram

    Hi Sriram,
    Instead use an OLAP variable to achieve the results you want.
    But first check what are the selection oprions supported by your data source in the table <b>ROOSFIELD</b> in your source system.
    Bye
    Dinesh
    Message was edited by: Dinesh Lalchand
    Message was edited by: Dinesh Lalchand

  • Routine in Infopackage data selection doesnt give appropriate results...

    Hi Gurus,
    I need to pull data into PSA (BW 3.5) based on a certain selections in the Infopackage. Selection is based on specific values of Infoobject 0PLANT , however, as these values are multiple and do not fall in a specific range I have written a routine to derive these values.
    The routine  does the following steps :
    - creates an internal table from /bio/mplant and deletes the plant values that I do not wish to consider in the extraction.
    - delete data from l_t_range for fieldname = 'PLANT'
    - Appends data from the internal table to l_t_range.
    However, when I execute the infopackage, the extraction is done for ALL the 0PLANT values i.e it includes the data for 0PLANT value which have been delete from the internal table.
    My routine is :
    $$ end of global - insert your declaration only before this line   -
        InfoObject      = 0PLANT
        Fieldname       = PLANT
        data type       = CHAR
        length          = 000004
        convexit        =
    form compute_PLANT
      tables   l_t_range      structure rssdlrange
      using    p_infopackage  type rslogdpid
               p_fieldname    type rsfnm
      changing p_subrc        like sy-subrc.
          Insert source code to current selection field
    $$ begin of routine - insert your code only below this line        -
    TYPES ls_range like l_t_range.
    data: l_idx like sy-tabix.
    DATA: lt_plant like /bi0/mplant OCCURS 0 with header line.
              SELECT PLANT from /bi0/mplant into lt_Plant WHERE objvers = 'A
              ENDSELECT.
              delete lt_plant WHERE plant = 'W206'.
              delete lt_plant WHERE plant = 'WF11'.
              delete lt_plant WHERE plant = 'W945'.
              DELETE lt_plant WHERE plant = 'W530'.
              read table l_t_range with key
                   fieldname = 'PLANT'.
              l_idx = sy-tabix.
              DELETE l_t_range where fieldname = 'PLANT'.
              Loop at lt_plant.
                    l_t_range-sign = 'I' .
                    l_t_range-low = lt_plant-plant.
                    l_t_range-OPTION = 'EQ'.
                    append l_t_range.
              endloop.
              modify l_t_range index l_idx.
              p_subrc = 0.
    $$ end of routine - insert your code only before this line         -
    endform.
    Any bugs in the routines ?

    try this one:
    Loop at lt_plant.
    if lt_plant-plant ne 'WF11' or lt_plant-plant ne 'W945' or lt_plant-plant ne 'W530'.
    l_t_range-sign = 'I' .
    l_t_range-low = lt_plant-plant.
    l_t_range-OPTION = 'EQ'.
    append l_t_range.
    endif.
    endloop.
    or
    don't use a table with header ( use a standard table and use a work area to access the table ) and do an other select like this:
    SELECT PLANT from /bi0/mplant
    into corresponding fields of table lt_Plant
    WHERE objvers = 'A
    and plant ne 'WF11'
    and plant ne 'W945'
    and plant ne 'W530'.
    I hope it helps...
    Kind regard.
    Tobias
    Edited by: Tobias Kreuser on Aug 23, 2010 11:34 AM

  • Routine in Infopackage Data selection Tab

    HI,
    I am having one InfoObject (marital staus) in InfoPackage Data selection Tab.
    Now I want to write a ABAP routine for that infoObject in Infopackage to select only those records of  marital status = ‘SINGLE’.
        I am new to ABAP . please let me know what code should I write in this routine.

    Hi Kris,
    You would do it like this:
    data: l_idx like sy-tabix.
              read table l_t_range with key
                   fieldname = 'MARITAL_STATUS'.
              l_idx = sy-tabix.
              move: 'I'      to l_t_range-sign,
                    'EQ'     to l_t_range-option,
                    'SINGLE' to l_t_range-low.
              modify l_t_range index l_idx.
    Thanks,
    Joseph

  • Routine at the Infopackage level-Urgent

    Hi,
    My requirement is I need to write an routine at the infopackage level for the fiscal period which should have the low value as the current period and the high value as current period +12 months.
    For example.
    As per the system date the
    low value should be 2007.09
    and the high value shoudl be 2008.09.
    Could anyone help me with the ABAP code.Points would be assigned.
    Regards,
    vamsi

    data: l_idx like sy-tabix.
              read table l_t_range with key
                   fieldname = 'FISCPER'.
              l_idx = sy-tabix.
    data: l_year                like T009B-BDATJ,
          l_period              like T009B-POPER,
          today                 like SY-DATUM.
    data: l_fiscperlow like l_t_range-low.
    data: l_fiscperhigh like l_t_range-high.
          today = SY-DATUM.
            CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
              EXPORTING
                I_DATE               = today
              I_MONMIT             = 00
                I_PERIV              = 'Z1'
              IMPORTING
                E_BUPER              = l_period
                E_GJAHR              = l_year
            EXCEPTIONS
              INPUT_FALSE          = 1
              T009_NOTFOUND        = 2
              T009B_NOTFOUND       = 3
              OTHERS               = 4
            IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
            concatenate l_year l_period+1(2) into l_fiscperlow.
          l_t_range-low = l_fiscperlow.
          l_t_range-high = l_fiscperlow+12.
          l_t_range-option = 'BT'.
          l_t_range-sign = 'I'.
          modify l_t_range index l_idx.
          p_subrc = 0.
              modify l_t_range index l_idx.
              p_subrc = 0.
    This is the code which i had written but when i execute the infopackage i am aboe to see only the low value 200709 in the infopackage selections and unable to see the high value,Could any one suggest me if i missed something in the code.
    regards,
    Vamsi

  • Routine at the infopackage

    Hi,
    If i write a routine at the infopackage level and if i specify the selection criteria for other infoobjects,they are not taken into consideration while the data is getting loaded.
    Could anyone of you help me as how to handle this.
    Regards,
    Subha

    Hi,
    The selections in the infopackage are the selctions in my routine.
    the code is
      tables /BIC/TZCS_GROUP.
    *data: v_year(4) type c.
      clear l_t_range.
      clear l_t_range[].
      v_year = sy-datum+0(4).
      l_t_range-iobjnm = '0CS_VERSION'.
      l_t_range-fieldname = 'CS_VERSION'.
      l_t_range-sign = 'I'.
      l_t_range-option = 'EQ'.
      l_t_range-low = '100'.
      l_t_range-high = SPACE.
      append l_t_range.
      l_t_range-iobjnm = '0FISCYEAR'.
      l_t_range-fieldname = 'FISCYEAR'.
      l_t_range-sign = 'I'.
      l_t_range-option = 'EQ'.
      l_t_range-low = 2007.
    *l_t_range-low = v_year.
      l_t_range-high = SPACE.
      append l_t_range.
       l_t_range-iobjnm = '0FISCPER3'.
      l_t_range-fieldname = 'FISCPER3'.
      l_t_range-sign = 'I'.
      l_t_range-option = 'EQ'.
      l_t_range-low = 001.
      l_t_range-high = SPACE.
      append l_t_range.
      select * from /BIC/TZCS_GROUP.
        if /BIC/TZCS_GROUP-/BIC/ZCS_GROUP cs 'GROUP'
      or /BIC/TZCS_GROUP-/BIC/ZCS_GROUP cs 'SUBS'
       or /BIC/TZCS_GROUP-/BIC/ZCS_GROUP cs 'WORLD'.
          l_t_range-iobjnm = 'ZCS_GROUP'.
          l_t_range-fieldname = '/BIC/ZCS_GROUP'.
          l_t_range-sign = 'I'.
          l_t_range-option = 'EQ'.
          l_t_range-low = /BIC/TZCS_GROUP-/BIC/ZCS_GROUP.
          l_t_range-high = space.
          append l_t_range.
        endif.
      endselect.
      l_t_range-iobjnm = 'ZCS_GROUP'.
      l_t_range-fieldname = '/BIC/ZCS_GROUP'.
      l_t_range-sign = 'I'.
      l_t_range-option = 'EQ'.
      l_t_range-low = space.
      l_t_range-high = 'XXXXXX'.
      append l_t_range.
      p_subrc = 0.
    or please help me handle this funtionality at the update rule level.
    Points will be assigned
    Regards,
    Subha

  • Infopackage Data Selection Problem

    Hi All,
    When i load master data from source system, in Infopackage data selection tab i give some criteria (e.g Customer number = 1000) But in infopackage the data load with all customer.(Not only 1000)
    How can i solve this problem??

    Hello Ozan,  
    Please check the datasource in RSA3 and make sure that its working for the same selection.
    Is there any routine in your infopackage and what is your source system?
    [Thanks|http://chandranonline.blogspot.com/]
    [Chandran|http://chandranonline.blogspot.com/]

  • Filed not reflecting in infopackage data selection screen

    Hello Gurus,
    I have added a time stamp fiield in generic datasource in R3 and selected that field,but when i replicate the data source in BI and go to infopackage data selection screen,i dont see that field.I tried all the possible things but its not working.
    Please help me.
    Thanks in advance.
    Regards,

    Hi,
    Did you select that  Time stamp field as Selection field in RSA6? If not then select it as selection field and activate and then replicate the DS in BW and then check if that comes in Infopackage level.
    Hope this helps..
    Murali

  • Several single value selection in InfoPackage Data selection using Routine

    Hi,
    I am trying to extract data from a table(containing Ticket data) in R/3 using Generic extractor with table. As the table is not supporting the delta functionality i have to do daily full load for more than 5 lak records.
    I dont want all the tickets from R/3, i just need the tickets which are open. Unfortunately there is no field in R/3 table which indicates Ticket status. But in BW i have a DSO where i can get the tickets along with their status.
    Now what i want to do is:
    in the Infopackage i want to give the dataselection for ticket, whose status is open which will be calculated in ABAP code by lookup to the DSO. Is this possible?
    I know that in ABAP routine for Data selection we can give single values and range values. but here i just want to give several single values. That means if suppose i have 4 tickets T1,T2,T3,T4 in the DSO and if T1 and T4 are open tickets, then i have to get the data from R/3 just for T1 and T4.
    in the above case if we use range then the low and high values in the range will be T1 and T4 respectively and the data pulled from R/3 will be from T1 - T4 ie all T1,T2,T3 & T4. but i need just T1 and T4.
    Please share your ideas. also please send the code as i am not an ABAPer.
    If Several single value selection is not possible at least send the code for the range values.
    Thanks,
    Cnu.

    you can write a code like this in the ABAP routine in data selection in front of ticket characteristic
    types: Begin of s_ticket,
         ticket type <type of ticket characterisitcs>,
          End of s_ticket.
    data: l_idx like sy-tabix,
          wa_ticket type s_ticket,
          it_ticket type standard table of s_ticket,
          l_s_range type rsrdrange.
    You can declare
    read table l_t_range with key
         fieldname = '<your field name for ticket>'.
    l_s_range-infoobject = '<infoobject name>'.
    l_s_range-fieldname = '<field name of ticket cahracteristics>'.
    l_s_range-sign = 'I'.
    l_s_range-option = 'EQ'.
    select * from <ODS active table> into table it_ticket where status = <value for open status>.
    if sy-subrc = 0.
         loop at it_ticket into wa-ticket.
              l_s_range-low = wa_ticket-ticket.
              append l_s_range to l_t_range.
         endloop.
    end if.
    p_subrc = 0.
    you need to modify it as per your requirements, i hope this might help you.

  • Infopackage-Data Selection Tab Values Get Populated Automatically.

    Hi All,
    In infopackage dataselection tab currently we are entering manually values for 0version info object and process has to be done for 4 differenct infopackagewe are getting a ticket for doing this process for every month.So 0version values would not be unique values ,all the values are different,for instancec10,c99,c11.
    user community felt that this one is a time consuming take they want to customize it and they want to enter the value on their own thorug some custom sap screen.
    we cannot give access to the user for the infopackage selection and all .we have figured out like we have to create a custom t code and give acces to the user for that t code alone.
    If the user enter the 0version value in the front end of it should get reflected in  infopackage dataselection tab.
    It would be really grateful if u have shared ur thought on the same.
    Regards,
    Sakthivel S

    Hi,
    You could use the TVARVC table instead of creating a Z-control table, and allow the users to enter the data into TVARVC via the tcode you are creating.
    So for instance the table entries could be as follows.
    NAME
    SIGN
    OPT
    LOW
    HIGH
    IP_1
    I
    EQ
    V1
    IP_2
    I
    BT
    V3
    V4
    IP_3
    I
    EQ
    V9
    Now, in the first InfoPackage, write the ABAP routine to read the data from TVARVC where the NAME = IP_1. Based on the results the InfoPackage restrictions will be populated by the routine. 
    In the second InfoPackage you read based on NAME = IP_2. And so on. Rest of the routine code is same as in the first InfoPackage.
    This way you can be assured that the different IPAKs will not have overlapping criteria as long as the table entries are correctly maintained.
    Regards,
    Suhas

Maybe you are looking for