ABAP Routine  for 0FISCPER  select data in InfoPackage

Hi all,
I need to write a routine which has to return values from the last FISCPER to the current FISCPER in the data selection of the infopackage.
Do somebody already do it?
Thks

Try this:
Global Declarations
CONSTANTS: c_1(1) TYPE n VALUE 1,
           c_fiscvarnt TYPE /bi0/oifiscvarnt VALUE 'Z1',  "Use whatever your default Fiscal Year Variant is"
           c_i(1) TYPE c VALUE 'I',
           c_bt(2) TYPE c VALUE 'BT'.
DATA: l_tabix LIKE sy-tabix,
      l_fiscper3 TYPE /bi0/oifiscper3,
      l_fiscyear TYPE /bi0/oifiscyear,
      l_min TYPE /bi0/oifiscper,
      l_max LIKE /bi0/oifiscper.
Routine
CLEAR: l_fiscper3,
       l_fiscyear.
CALL FUNCTION
  'DATE_TO_PERIOD_CONVERT'
EXPORTING
  i_date  = sy-datum
  i_periv = c_fiscvarnt
IMPORTING
  e_buper = l_fiscper3
  e_gjahr = l_fiscyear.
CONCATENATE: l_fiscyear l_fiscper3 INTO l_max.
l_fiscper3 = l_fiscper3 - c_1.
IF l_fiscper3 LT 1.
  l_fiscyear = l_fiscyear - c_1.
  l_fiscper3 = c_1.
ENDIF.
CONCATENATE: l_fiscyear l_fiscper3 INTO l_min.
READ TABLE
  l_t_range
WITH KEY
  fieldname = 'FISCPER'.
MOVE: sy-tabix TO l_tabix,
      c_i TO l_t_range-sign,
      c_bt TO l_t_range-option,
      l_min TO l_t_range-low,
      l_max TO l_t_range-high.
MODIFY
  l_t_range
INDEX
  l_tabix.
p_subrc = 0.
Edited by: Dennis Scoville on Dec 7, 2009 11:07 AM

Similar Messages

  • ABAP Routine  for 0FISCPER  slect options in InfoPackage

    Hi,
    I am trying to write an ABAP Routine for 0FISCPER as select options (range) dynamically.
    Ex:
    0FISCPER selection for this year as 001.2008 to 012.2008
    0FISCPER selection for next year as 001.2009 to 012.2009.
    Now  we are changing InfoPackage every year manually, so I need to write a routine for 0FISCPER in InfoPackage to handle dynamically every year
    Thanks,
    SK.

    Hi
    write an ABAP routine to get that value..But are you getting any planned data(why you want till end of the year...till infopackage runs is o.k i think, if you don't have planned data)...Any way you can check the below code, which can be useful...
    You can see the below code at->your infopackage selections>Ty-->choose variable type as 6 and enter any ABAP routine name( to create) and then there is a button on the application tool bar called 'routine info'..this give you the following information...
    Definition
    You can define complex selections for InfoPackages and control the automatic deletion of requests from InfoCubes in the scheduler, by using routines.
    Routines are processing blocks in ABAP programs that consist of a pre-defined data declaration section and an ABAP subroutine (form routine). In the subroutine you can use all of the ABAP programming functions.
    You can use the following routines for making selections in InfoPackages:
    1. Selection routines for fields, on the Data Selection tab page
    2. Selection routines for file names, on the External Data tab page
    3. Selection Routines for selecting the from and to dates for time-dependent data, on tab page Update
    4. Selection routines for determining old requests to be deleted after successfully loading a new request, on the Data Target tab page
    Program frame:
    After you have called up the Editor for routine maintenance, you get the following program frame:
    1. Selection routines for fields, on tab page Data Selection:
    program conversion_routine.
    '$*$ begin of global - insert your declaration only below this line -
    TABLES: ...
    DATA:   ...
    $$ end of global - insert your declaration only before this line    -
    FORM COMPUTE_<Fieldname>
      tables l_t_range structure rssdlrange
      changing p_subrc like sy-subrc.
    $$ begin of routine - insert your code only below this line       -
      data: l_idx like sy-tabix.
            read table l_t_range with key
                 fieldname = <Fieldname>.
            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.
    2. Selection routines for file names, on tabstrip External Data:
    FORM compute_flat_file_filename
         changing p_filename like rsldpsel-filename
              p_subrc like sy-subrc.
    $$ begin of routine - insert your code only below this line-
              p_filename =
              p_subrc = 0.
    $$ end of routine - insert your code only before this line-
    ENDFORM.
    3. Selection routines for selecting the from and to date for time-dependent data, on tabstrip Update:
    form compute_time_dependent_dates
         changing p_datefrom type d
                  p_dateto   type d
               p_subrc like sy-subrc.
    $$ begin of routine - insert your code only below this line-
              p_datefrom =
              p_dateto   =
              p_subrc = 0.
    $$ end of routine - insert your code only before this line-
    ENDFORM.
    4. Routines for determining the old requests to be deleted after successfully loading a new request, on tab page Data Targets:
    form compute_<InfoCube-Name>
      tables l_t_request_to_delete structure rsreqdelstruc
      using l_request like rsreqdone-rnr
      changing p_subrc like sy-subrc.
    *Insert Source Code to decide if requests should be deleted.
    *All Requests in table l_t_request_to_delete will be deleted
    *from Infocube <InfoCube-Name>.
    *Add new requests if you want to delete more (from this cube).
    *Remove requests you did not want to be deleted.
    $$ begin of routine - insert your code only below this line-
         loop at l_t_request_to_delete.
         endloop.
         clear p_subrc.
    $$ end of routine - insert your code only before this line-
    ENDFORM.
    Note:
    Those fields flagged with <...> are dependent on the selection fields and are filled automatically by the system when you call up the Editor.
    Procedure
    Make the following entries:
    1. Between $$ begin of global ... and $$ end of global ... you can define data declarations. These are the declaration sections for the local data in the routine. This data is only visible in the routines.
    2. The subroutines begin with FORM and end with ENDFORM.
    The subroutines for the particular routines are:
    Selection routines for fields on tab page Data Selection: FORM COMPUTE_<Field name>
    Selection routines for file names on tab page External Data : FORM compute_flat_file_filename
    Selection routines for selecting the from and to dates for time-dependent data on tab page Update: FORM compute_time_dependent_dates
    Routines for determining old requests to be deleted after successfully loading a new request on tab page Data Target: FORM COMPUTE_<InfoCube-Name>
    The subprograms have the following parameters:
    Subprogram FORM COMPUTE_<Field name>:
    l_t_range
    In the table l_t_range the routines for all selection fields that are filled, or have a routine, are made available.
    The routines are executed in the scheduler last of all and therefore, you can change all the selections that you have carried out previously.
    p_subrc
    Using the variable p_subrc you can report errors to the scheduler. p_subrc <> 0 signals an error and means the data request is terminated.
    Subprogram FORM compute_flat_file_filename:
    p_filename:
    You give the name of the file that is to be loaded in parameter p_filename.
    This is useful if your file name contains date dependencies that should be determined by sy-datum and calculated during runtime.
    p_subrc
    You can inform the scheduler of an error with variable p_subrc. p_subrc <> 0 signals an error and means that the data request is terminated.
    Subprogram FORM compute_time_dependent_dates:
    p_datefrom and p_dateto
    Fill these parameters with the from and to dates for time-dependent master data and texts.
    p_subrc
    You can inform the scheduler about an error using variable >LS>p_subrc. p_subrc <> 0 signals an error and means the data request is terminated.
    Subprogram FORM COMPUTE_<InfoCube-Name>:
    l_t_request_to_delete
    You give the request number of the request that is to be deleted in parameter l_t_request_to_delete. You can also delete requests from the table. These are then not deleted.
    p_subrc
    You can inform the scheduler about an error with the variable p_subrc. p_subrc  signals an error and means the data request is terminated.
    3. Insert your program code for the routines between $$ begin of routine ... and $$ end of routine ... so that the respective subprogram variables are supplied with the corresponding values.
    4. Check the syntax of your routine with the Check function.
    5. You can then transfer the routine with the Save function.
    You end routine maintenance when you exit the Editor.
    Hope it helps
    Thanks,
    Teja

  • ABAP routine for loading data of current month in InfoPackage

    Hello experts,
    I want to load data of current month. Therefore I implemented the following ABAP-Routine for field 0CALDAY in the InfoPackage's data selection:
    data: lv_datum_l like sy-datum,
             lv_datum_h like sy-datum. 
      concatenate sy-datum(6) '01' into lv_datum_l.
      call function 'RP_LAST_DAY_OF_MONTHS'
      exporting
      day_in = sy-datum
      importing
      last_day_of_month = lv_datum_h.
      l_t_range-sign = 'I'.
      l_t_range-option = 'BT'.
      l_t_range-low = lv_datum_l.
      l_t_range-high = lv_datum_h.
    But function 'RP_LAST_DAY_OF_MONTHS' cannot be found!
    Any other suggestions for getting last day of current month?
    regards
    hiza

    Hi,
    Add this code. When u complete execution of this code, ZDATE will have ur month end date.
    data : zdate_c(2) type c,
           zyear_c(4) type c,
           zmonth_c(2) type c.
    data :  zdate like sy-datum.
    data :  zday(2) type n.
    zdate = sy-datum
          zyear_c = zdate(4).
          zmonth_c = zdate+4(2).
          zdate_c = '01'.
          concatenate zyear_c zmonth_c zdate_c into zdate.
          CALL FUNCTION 'FIMA_END_OF_MONTH_DETERMINE'
          EXPORTING
            I_DATE         = zdate
          IMPORTING
            E_DAYS_OF_MONTH = NO_OF_DAYS.
          zday = NO_OF_DAYS.
          concatenate zyear_c zmonth_c zday into zdate.

  • Abap Routine for Date selection in Infopackage

    Hi
    I have to write an abap routine for date selections in the infopackage,
    There are two date begda and enda.
    Do i code for BEGDA and fill in the begin date using routine and use another routine to fill the ENDA.
    JPJP

    Hi JP,
      If you have two info objects BEGDA and ENDA in the Info package for selection
      then you will have to write seperate routine for each of them.
      If you want to give single value for each date field then update only the field l_t_range- low otherwise if you want to give range then you can update the internal table fields l_t_range-low and l_t_range-high .
    Regards,
    Prakash

  • Routine for multiple selection in infopackage???

    hello guys
    I thought of creating one routine for Multiple selections aT Infopackage level....in Selections screen in infopackage,I found one option 'Use Conversion routine' with a check box and it is inactive.....Is it here I need to write my routine inorder to get multiple selection for a infoobject....or is it somehwhere else?How to activate thisoption?
    Thanks,
    Regards,
    S

    Hi,
    Conversion routines are used in the BI system so that the characteristic values (key) of an InfoObject can be displayed or used in a different format to how they are stored in the database. They can also be stored in the database in a different format to how they are in their original form, and supposedly different values can be consolidated into one.
    This will be there at info object level.
    Eg : ALPHA: Fills purely numeric fields from the left with zeroes (0).
    For multiple selections at info package , in data selection tab under type , u need to select 6 and write the code to select the value.When info package runs it takes the value from routine dynamically and extracts the data based on selection.
    Eg: There is a field FISCAL PERIOD For data selection, if u write the code to select current fiscal period. then whenever info package runs it extracts the data for current fiscal period from data source to PSA.
    Thanks,
    Joseph.

  • ABAP routine for Top 10 material

    Hi All,
    I want to write an ABAP routine to get the Top 10 material as per their sales data.
    I have written a query where I have put condition (for Top 10).
    But I need to create an APD taking this query as base query. But conditions fail to filter data when it comes into a transactional ODS via an APD.
    So, I want to write a routine for transaformation of data (to get top 10 material based on their sales data) from base query to the transactional ODS.
    Please help me in writing this code.
    I am an amatuer in ABAP.
    Thanks,
    SB

    Hi ,
    You Need to read Data from the ODS for Top 10 Materials. I can give you the Logic but you would need to take the Help of an ABAPPER to convert this into the code
    Lets consider an ODS : ZODS which has a KF for Sales Data (ZKF)
    *****Define Internal Table ****************
    TABLES :
    /BIC/AZODS
    DATA:
    BEGIN of ITAB OCCURS 0,
        0material(18)       TYPE c,
        ZKF           like /bic/AZODS-/bic/ZKF,
    END OF ITAB.
    DATA:
    BEGIN of ITAB1 OCCURS 0,
        0material(18)       TYPE c,
        ZKF           like /bic/AZODS-/bic/ZKF,
    END OF ITAB1.
    Select MATERIAL, /BIC/ZKF from /BIC/AZODS into corresponding fields of ITAB1.
    LOOP AT ITAB1
    ITAB-MATERIAL = ITAB1-MATERIAL
    ITAB-ZKF= ITAB1-ZKF
    COLLECT ITAB.
    ENDLOOP.
    SORT ITAB ZKF.
    ************this will have the materials sorted take the first 10 Material Nos*****

  • How to get the opening balances for lessthan selected date in cubes.

    Hi All,
    my task is to get the opening balances for the selected date.
    Ex: If I select date say 31-1-2013, I should get the sum of values which are less than the selected date.
    in sql:
    select sum(balance) from banktrans where banktrans.transdate < 31-1-2013;
    BankTable                            BankTrans
    BankId                               BankId
                                            balance
                                            transdate
    BankTable (records):
    SCB
    BankTrans(records):
    a) SCB, 15000, 10-02-2013
    b) SCB, 20000, 31-01-2014
    c) SCB, 50000, 21-09-2012
    If I select date as 31-01-2014, I should get the value as 65000 
    If I select date as 10-02-2013, I should get the value as 50000
    Date will be dynamic selection from years months days hirearchy ( time dimension)
    How can i achieve this?  
    any help is much appreciated.
    Thanks,
    Rakesh

    Dear David,
    I've tried the below with static date but i'm not getting the values which are sum of less than the given date.
    I've given 1st jan 2013 as static date and I need to get the sum of values which are less than the 1st jan date.
    CREATE
    MEMBER
    CURRENTCUBE.[Measures].[OPENBALANCE]
    AS
    Sum({Null:[Time].[Years
    Quarters Months Weeks Days].[Days].&[2013-01-01T00:00:00]},[Measures].[AmountCur]]),
    FORMAT_STRING
    = "Standard",
    VISIBLE
    = 1
    can you plz check the above once and guide me.
    Thankyou,
    Rakesh

  • InfoPackage ABAP Routine for Date Range - Only Start Date Extracted

    I am using an ABAP Routine in an InfoPackage to select data for a 2 year period.  The routine converts SY-DATUM into the Current Fiscal Year and Period, and then calculates the Starting and Ending Fiscal Year / Period of a 24 month period.  The Start and End values are passed to the InfoPackage as l_t_range-low and l_t_range-high.
    The Source and Target are both Basic Infocubes.
    The InfoPackage executes successfully, and the Selection values on the Header tab of the monitor reflect a 24 month period.  Unfortunately, on closer review of the data in the cube, only data for the first month appears to have been loaded.  I’m guessing that the extract was only performed with the From value, even though a To value was also provided.
    I created a simple Infopackage and manually input the selection parameter values just to be sure I wasn’t overlooking something. The InfoPackage performed as expected, loading more data which spanned the selection time period.
    I can provide the code if it helps, but the fact that the monitor reflects a Start and End value suggests that the problem is with the InfoPackage, not the ABAP routine.
    Has anybody ever experienced this before ?  Any ideas would be greatly appreciated ?
    Thanks,
    Lyle

    We can write ABAP routine in Infopackage with a range of values (From & To). Make sure you fill all the following information while building the final range information as below,
       l_s_range-sign    = 'I'.
       l_s_range-option  = 'BT'.
       l_s_range-low     = lowvalue.
       l_s_range-high    = highvalue.
      MODIFY l_t_range FROM l_s_range INDEX l_idx.
    As you can see the key is passing the "BT" information for capturing range.
    Hope it helps..
    thanks
    Kumar

  • Using ABAP routines for data selection

    Hello,
    I want to use ABAP routine to determine value range of data selection in Data Package but when I use routine for one field, selection criterias for other fields are ignored, e.g.:
    in Data Package I have two selection fields:
    CPUDT     Accounting Document Entry Date
    AEDAT     Date of the Last Document Change by Transaction
    For CPUDT I wrote ABAP routine
    and for AEDAT I have just typed in period of time.
    I started data extraction and open Monitor for this Data Package.
    At Header tag I checked selections info and there is selection only for CPUDT.
    Could somebody explain me is it normal system behaviour?
    Thanks
    Andrzej

    Thanks for reply but that would be too easy...
    I have tried your advice but nothing changed.
    I think this is data extraction configuration problem.
    Andrzej

  • Excluding Value Range - ABAP Routine at Infopakage Selection

    Hi,
    In Production the volume of data is very high, I m splitting the data based on Material No.
    000000000000 - 4ZZZZZZZZZ,
    500000000000 - 8ZZZZZZZZZ,
    900000000000 - FFFFFFFFFFFFF,
    and the remaining Material No.s.
    I created seperate InfoPaks for the material Ranges for the above three.
    I need to load the remaining Material No. data. For the I need to write the ABAP routine at the Infopakage Selections.
    Can you help me doing so.
    Thanks in Advance.
    Surya.

    Hi,
       analyse the data. total data u can split with the help of Organisational values. take the case in souce system i have 40 million records of sales orders. then i will do like how many sales area's we have in our organization. assume. 4 sales areas then i willl create a infopackage for each. so tat u won't miss any data.
    don't go for Material number, select organisational values.
    all the best.
    Nagesh.

  • ABAP Routine for FISCPER

    Dear members
    Y would like your help to create an abap routine into the infopackage.
    I want to obtain last period from current month (sy-datum), for the characteristic 0fiscper at the infopackage
    those anyone know how to create a routine that do that?
    For example
    2010001 to 2009012
    Thanks
    Ariel

    Give tnis a try:
    Global Declarations
    CONSTANTS: c_1(1) TYPE n VALUE 1,
               c_fiscvarnt TYPE /bi0/oifiscvarnt VALUE 'Z1',  "Use whatever your default Fiscal Year Variant is"
               c_i(1) TYPE c VALUE 'I',
               c_bt(2) TYPE c VALUE 'BT'.
    DATA: l_tabix LIKE sy-tabix,
          l_fiscper3 TYPE /bi0/oifiscper3,
          l_fiscyear TYPE /bi0/oifiscyear,
          l_min TYPE /bi0/oifiscper,
          l_max LIKE /bi0/oifiscper.
    Routine
    CLEAR: l_fiscper3,
           l_fiscyear.
    CALL FUNCTION
      'DATE_TO_PERIOD_CONVERT'
    EXPORTING
      i_date  = sy-datum
      i_periv = c_fiscvarnt
    IMPORTING
      e_buper = l_fiscper3
      e_gjahr = l_fiscyear.
    CONCATENATE: l_fiscyear l_fiscper3 INTO l_max.
    l_fiscper3 = l_fiscper3 - c_1.
    IF l_fiscper3 LT 1.
      l_fiscyear = l_fiscyear - c_1.
      l_fiscper3 = c_1.
    ENDIF.
    CONCATENATE: l_fiscyear l_fiscper3 INTO l_min.
    READ TABLE
      l_t_range
    WITH KEY
      fieldname = 'FISCPER'.
    MOVE: sy-tabix TO l_tabix,
          c_i TO l_t_range-sign,
          c_bt TO l_t_range-option,
          l_min TO l_t_range-low,
          l_max TO l_t_range-high.
    MODIFY
      l_t_range
    INDEX
      l_tabix.
    p_subrc = 0.

  • ABAP OO:  Duplication of selected data in created objects?

    I am new to ABAP OO and I have a conceptual question/concern that I cannot resolve.  Can someone explain what I am missing?
    I would think that selecting and storing (in internal tables) a large amount of data from many related database tables and, at the same time, creating and storing objects from this same data would unnecessarily consume a huge amount of memory.  To avoid this problem, it seems that the selected data and created objects should not be stored in internal tables simultaneously.
    Does this concern make sense?  If so, how is this problem best handled?
    Does it make sense to delete the corresponding data once the objects are created (to free memory)?
    Or does it make sense to keep the data and only temporarily create objects as needed?
    Thanks.

    Hello Matt
    The approach you describe is to select data first and the feed the object instances with them. <b>Why not let the object instances do the data selection themselves?</b>
    I will give you an example what I mean.
    (1) Lets assume I want to write an application that allows to deal with cost center hierarchies. On the selection screen you can choose one or many cost center hierarchies.
    (2) Using the selection criteria I would select all cost center hierarchies but without any details (just the key values).
    (3) Next I would loop over the cost center hierarchies and create a cost center hierarchy instance (a class you have to define yourself) for each key value. The CONSTRUCTOR of this class will have an IMPORTING parameter like <i>id_kostl_hier</i>.
    (4) In the CONSTRUCTOR method I first check if the cost center hierarchy exists (if not raise an exception-class based exception) and then do the selection of the hierarchy details (e.g. the cost centers).
    (5) The instances are collected in an itab of the "frame" application.
    Using this approach you will have little duplication of data within your application. Furthermore, if you really have to deal with huge amounts of data then you could read them only on demand (like in tree controls where the sub-nodes usually are read when the parent node is expanded).
    Hope I could give you some fresh insights into this exciting topic.
    Regards
      Uwe

  • ABAP Routine for Deleting and creating index for ODS in Process chains

    Any pointers for the ABAP Routine code for deleting and creating index for ODS in Process chains.

    Hi Sachin,
    find the following ABAP code to delete ODS ondex.
    data : v_ods type RSDODSOBJECT.
    move 'ODSname' to v_ods .
    CALL FUNCTION 'RSSM_PROCESS_ODS_DROP_INDEXES'
      EXPORTING
        I_ODS = v_ods.
    To create index:
    data : v_ods type RSDODSOBJECT.
    move 'ODSname' to v_ods .
    CALL FUNCTION 'RSSM_PROCESS_ODS_CREA_INDEXES'
      EXPORTING
        I_ODS = v_ods.
    hope it helps....
    regards,
    Raju

  • ABAP routin for geeting previous month

    Hello.......
    I want to writ an ABAP routin at the infopackage level.
    I want to get the previous month ( period ).
    example : if sy-datum is 2007.01.01
    output : 2006.12.01.
    reply.
    Thanks in advance.

    Hi,
    Write this in the start routine of infosource or update rules...
    Try this:
      DATA: L_DATE LIKE SY-DATUM.
      DATA: L_YEAR TYPE I.
      DATA: L_MONTH TYPE I.
      L_DATE = (Here enter your input).
      MOVE '01' TO L_DATE+6(2).
      MOVE L_DATE(4) TO L_YEAR.
      MOVE L_DATE+4(2) TO L_MONTH.
      L_MONTH = L_MONTH - 1.
      IF L_MONTH LT 1.
        L_YEAR = L_YEAR - 1.
        L_MONTH = 12.
      ENDIF.
      MOVE L_YEAR TO L_DATE(4).
      MOVE L_MONTH TO L_DATE+4(2).
      MOVE:  L_DATE TO P_DATE.
    Hope this helps
    PB

  • ABAP routine for ATP check

    Hi all...Is there any existing ABAP routine which does ATP check (material availability and allocation check) ??

    fm 'BAPI_MATERIAL_AVAILABILITY'
    BR< JAcek

Maybe you are looking for

  • Where can I learn more about the Logic Environment?

    I've been using LogicPro for a while now - since version 7 came out - and I'm ready to learn more about the mysterious Logic Environment. Anyone know of a good tutorial or website on this topic? I don't have a specific question - what I need is a gen

  • RMAN parameters - to use more CPU for Backup & Restore

    Hi Friends, I am using RMAN backup on 11g database on windows. RMAN is taking almost 1 hr to restore the database and i could see the CPU usage is very less - less than 10% during restore. so how can i make the RMAN backup and restore faster by using

  • License change windows to mac

    Hello What do I have to do to change my photoshop CS6 windows version to the mac version? Thank You Theo Boesmans

  • IChat unexpectedly quit

    So I use to use iChat a lot but I have not for a few months now. And I've been trying to use it again and I keep getting the message that it has unexpectedly quit. So I relaunch and it gives me the message again. It won't even try to open iChat. I do

  • Apply style at top of frame

    Hello all, I'm placing about 150 pages of continuous text from a Word doc.  The doc is being continually edited and each time I place it to create a draft,  there is a different placement of words, which is fine.  The page size is also different in W