Function (ABAP) to select Max of the avaliable dates

Hi,
Every Employee will have a health Insurance Policy which is valid for 6 six months.
From Source System i am getting
Employee and his policy Start date,Based on Policy Start Date in Transformations i am calculacting the Policy Expiry date (Policy Start date + 6 Months)(Ex:If Policy Start Date is 01/Nov/2007 then Exp date is 01/May/2008)
My report is to Show employees who doesn't had a valid policy on the day report executed (Sys Date)
For that i created a Customer Exit Variable on Policy Expiry Date
(If Policy Expiry date is < Sys Date)
IF i_step = 2.
CLEAR l_s_range.
l_s_range-low = sy-datum.
l_s_range-sign = 'I'.
l_s_range-opt = 'LT'.
APPEND l_s_range TO e_t_range.
ENDIF.
Problem:
Data in the cube
Employee--Policy Start date-Policy Expiry Date
1--01/01/2008-----30/06/2008
1--01/07/2007-----31/12/2007
1--01/01/2007-----30/06/2007
When i execute the report i should expect the Emp 1 shouldn't be displayed as he had valid policy which is going to expir in June 2008....but the above exit is displaying the below 2 records
Can i include any changes in the above exit that will select the Max Policy Expire date and then it will check with the Sys Date
Please update me on how to proceed
Thanks

Hello,
You can do this in couple of ways:
(1) Select <..> from <Table> into Itab ORDER BY expiry_date. Then read internal table to know the validity.
(2) Select <..> from <Table> into itab where expiry_date > SY-DATUM. You will get only unexpired records.
Thanks,
Venu

Similar Messages

  • How to Include in Customer Exit to select max of the date

    Hi,
    Every Employee will have a health Insurance Policy which is valid for 6 six months.
    From Source System i am getting
    Employee and his policy Start date,Based on Policy Start Date in Transformations i am calculacting the Policy Expiry date (Policy Start date + 6 Months)(Ex:If Policy Start Date is 01/Nov/2007 then Exp date is 01/May/2008)
    My report is to Show employees who doesn't had a valid policy on the day report executed (Sys Date)
    For that i created a Customer Exit Variable on Policy Expiry Date
    (If Policy Expiry date is < Sys Date)
    IF i_step = 2.
          CLEAR l_s_range.
          l_s_range-low = sy-datum.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'LT'.
          APPEND l_s_range TO e_t_range.
        ENDIF.
    Problem:
    Data in the cube
    Employee--Policy Start date-Policy Expiry Date
    1--01/01/2008-----30/06/2008
    1--01/07/2007-----31/12/2007
    1--01/01/2007-----30/06/2007
    When i execute the report i should expect the Emp 1 shouldn't be displayed as he had valid policy which is going to expir in June 2008....but the above exit is displaying the below 2 records
    Can i include any changes in the above exit that will select the Max Policy Expire date and then it will check with the Sys Date
    Please update me on how to proceed
    Thanks

    Hi thomos,
    Thanks for the update
    Bit Confused.....could you please explain me
    "Your variable (intervall) should be based on the Policy Expiry Date
    l_s_range-low = '10000101'.
    l_s_range-high = 'sy-datum - 1.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'
    How this is going to solve my problem....
    As i got 3 records on a employee one of which got expiry date greater tha sys date
    Thans

  • Adding one more selection field in the standard data source

    Hi SAP Gurus,
    I'd like to know how to add one field as a selection field for the data source.I used 0FI_GL_4 Datasource .It has 2 selection.Now I want to add one more field as a selection field .How to mark that field as selection?I tried by using RSA6 ,But I'm unable to change the previous selection.
    Please let me know how to fix it?
    I'll assign the points ...
    Thanks & regards
    Raja

    Pradip,
      when ever you create any Generic DS, you can find generic DS(I checked this), comming append fields(it's happend to me)... there is no meaning.. as we know... we will extract the data for append fields using existing DS.
    Comming Raju:
    to my knowledge, you should not add that field as selection enabled(wait for others posts). I had seen many posts for working on this... by updating the Table ROOSFIELD table for the respective DS. I never implemented this... if you update this using any custom program be careful. Ihave ccreated the program for append fields not for Standard Extractor.
    Try to search any SAP Notes: 571985
    All the best.
    Regards,
    Nagesh Ganisetti.

  • Newbie: how to create a dynamic select list of the current date + 5 years

    Hi - I'm a JSP newbie (coming from a PHP background), and am trying to create a select list that contains the current year, plus 5 years. So, the list when generated (today), would display:
    2007
    2008
    2009
    2010
    2011
    2012
    Obviously, the code would need to generate inside the option tags, as well as in the value property of the option tag.

    function addit(){
              var val = 2012; //you can take this from js date object and strip it off
              for (var i=2007; i <= val;++i){
                   addOption(document.getElementById("mycombo"), i, i);
    function addOption(selectbox,text,value)
         var optn = document.createElement("OPTION");
         optn.text = text;
         optn.value = value;
         selectbox.options.add(optn);
    }without hardcoding:
    function addit(){
              var dd = new Date();
              var yearnow = dd.getFullYear();
              for (var i=yearnow; i <= yearnow + 5 ;++i){
                   addOption(document.getElementById("mycombo"), i, i);
    function addOption(selectbox,text,value)
         var optn = document.createElement("OPTION");
         optn.text = text;
         optn.value = value;
         selectbox.options.add(optn);
    in your jsp:
    <body onload="addit();">
    <form>
    <select name="mycombo">
    <option> Select year</option>
    </select>
    </form>
    </body>
    Message was edited by:
    skp71
    Message was edited by:
    skp71

  • Is SELECT MAX(*) Supported?

    I'm trying to grab the latest date from our table in a DB Read step.
    Reading the Step Reference documentation, it indicates that only SELECT COUNT(*) and SELECT MIN(*) are not supported functions. So SELECT MAX(*) should work, right?
    When I do my Reactive Script, that step fails with that blank pop up.
    So is SELECT MAX(*) not allowed?
    How would I go about grabbing the latest date?
    Do I need to put my values in an array and then use expressions to grab the max?
    I'm looking with my other DB admin to see if there's an alternate SQL query we can use.

    Hi,
    I guess (almost) everything is supported, as long as you make the UCCX believe it sees the right column.
    First, create a dummy table or view - one column would do, in this case. For instance:
    CREATE TABLE mytable (myData INT)
    Then map the UCCX step to this dummy table - even though there's no data.
    The only thing to remember is to use the correct column alias, from that dummy table, in this case, myData. Like this:
    SELECT MAX(column) AS [myData] FROM table WHERE foo=bar
    G.

  • Selective copying/mo​ving of data from Citadel

    Programming platform : LabVIEW DSC 6.1
    Operating System : Windows NT 4.0 with SP 6.0
    I have about a months data in Citadel. I want to make a copy/move data of selected time period from the entire citadel data base. Iam not able to copy/move selected part of the Citadel data but the entire data is copied or moved to the new location. Please give me a clue.

    In LabVIEW DSC 6.1 there is a new function called "Archive Database.vi". This vi performsa destructive or non-destructive archival operation on a Citadel database. You can also set a time range for the data to be archived.You can find this vi in the Historical Data subpalette.
    Jochen Klier
    Application Engineering Group Leader
    National Instruments Germany

  • How to build the  FM data I_header and I_orgdata

    hi all,
    I’m working on the conversion program for AVL using the following function modules
    BBP_PD_AVL_GETLIST
    BBP_PD_AVL_CREATE
    BBP_PD_AVL_UPDATE
    BBP_PD_AVL_SAVE
    In the function module BBP_PD_AVL_CREATE , how to build the FM data  I_HEADER and I_ORGDATA.
    I'm giving 3 input in Export parameter in BBP_PD_AVL_GETLIST  and E_pdlist should contain data .
    but e_pdlist is not getting data...any suggestion..
    after execution it was showing  "Buffer table is not up to date"
    with regards,
    P.lokesh

    Hi Lokesh,
    We are also encountering same problem.
    How did you solve your problem?
    Would really appreciate your help.
    Thanks,
    Kezia

  • How to do the latest date?

    Hi,
    I have multiple lines of purchase history for 1 item, what i want to select is:
    if the purchased date is the latest one and the memo='Y',
    Invoice# cost purchased_date memo
    1234 $50 02/11/06 Y
    2222 $50 01/15/05 N
    3333 $60 09/05/04 N
    how do i do?

    Something like this:
    SQL> SELECT COUNT(*)
      2  FROM emp e
      3  WHERE e.empno = 7369 ;
      COUNT(*)
         32768
    1 row selected.
    SQL> set autotrace on explain
    SQL> SELECT *
      2  FROM
      3    (SELECT *
      4     FROM emp e
      5     WHERE e.empno = 7369
      6     ORDER BY hiredate DESC)
      7  WHERE rownum = 1;
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 21-DEC-3236        800                    20
    1 row selected.
    Execution Plan
    Plan hash value: 3738945388
    | Id  | Operation                      | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                  |     1 |    87 |     2   (0)| 00:00:01 |
    |*  1 |  COUNT STOPKEY                 |                  |       |       |            |          |
    |   2 |   VIEW                         |                  |     1 |    87 |     2   (0)| 00:00:01 |
    |   3 |    TABLE ACCESS BY INDEX ROWID | EMP              |     1 |    37 |     2   (0)| 00:00:01 |
    |*  4 |     INDEX RANGE SCAN DESCENDING| IDX_EMP_EMPNO_DT |  1835 |       |     8   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM=1)
       4 - access("E"."EMPNO"=7369)
    SQL>

  • Using Select Statement in the decoe function in Oralce Form10 g

    Hello All:
    Is it possible to call another Select Statement inside the Decode Function in Oracle Form? I tested the SQL on PL/SQL Plus, it ran without giving any errors. However, I got the following errors when I tried to compile the procedure in the Oracle Form right after the where condiction at the first select statement....
    Error 103 at line number....
    Encountered the symbol "," when expecting one of the following
    ) intersect minus order union .....
    Select a.col1
    a.col2,
    decode((select min(test_date) pa_closr_date from table_name c where a.col1 = c.col1), null, a.col3,(select min(test_date) pa_closr_date from table_name c where a.col1 = c.col1)) test_date,
    a.col4,
    from table_name a;
    thanks ahead for any help.
    KMD

    You don't need the Select within the decode. In SQL Plus, I tried your SQL using this:
    Select
        a.col1,
        a.col2,
        decode( (select min(test_date) pa_closr_date
                   from table_name c where a.col1 = c.col1), null, a.col3,
                (select min(test_date) pa_closr_date
                   from table_name c where a.col1 = c.col1)
              ) test_date
      from table_name a;And this gives the same result:
    Select
        a.col1,
        a.col2,
        decode(c.pa_closr_date, null, a.col3, c.pa_closr_date ) test_date
      from table_name a,
           ( select col1, min(test_date) pa_closr_date
             from table_name
             group by col1 ) c
      where c.col1(+) = a.col1;

  • SQL query problem - select max (case... aggregate function)

    Hi,
    I have a problem with below sql query, it gives me problem/error message 'ORA-00937: not a single-group group function', why?
    select sag.afdeling, sag.sagsnr, to_char(sag.start_dato, 'yyyy-mm-dd'), sag.stat, BOGF_TRANS.TRANSTYPE,
    max (case when BOGF_TRANS.TRANSTYPE = 'K' then sum(bogf_trans.belobdkk) end) + -- as "TRANSTYPE K",
    max (case when BOGF_TRANS.TRANSTYPE = 'D' then sum(bogf_trans.belobdkk) end) as "TRANSTYPE K & D",
    max (case when BOGF_TRANS.TRANSTYPE = 'S' then sum(bogf_trans.belobdkk) end) as "SUM TRANSTYPE S"
    from sag
    join bogf_trans on sag.selskab = bogf_trans.selskab and sag.sagsnr = bogf_trans.sagsnr and sag.afdeling = bogf_trans.afdeling
    where SAG.SELSKAB=37 and SAG.AFDELING = 'SUS' AND SAG.SAGSNR = 10876
    group by sag.afdeling, sag.sagsnr, sag.start_dato, sag.stat, BOGF_TRANS.TRANSTYPE
    If I exclude (columns) as below it give me correct summations (max (case... sum(...)) but then I miss some important info that I need
    select
    max (case when BOGF_TRANS.TRANSTYPE = 'K' then sum(bogf_trans.belobdkk) end) + -- as "TRANSTYPE K",
    max (case when BOGF_TRANS.TRANSTYPE = 'D' then sum(bogf_trans.belobdkk) end) as "TRANSTYPE K & D",
    max (case when BOGF_TRANS.TRANSTYPE = 'S' then sum(bogf_trans.belobdkk) end) as "SUM TRANSTYPE S"
    from sag
    join bogf_trans on sag.selskab = bogf_trans.selskab and sag.sagsnr = bogf_trans.sagsnr and sag.afdeling = bogf_trans.afdeling
    where SAG.SELSKAB=37 and SAG.AFDELING = 'SUS' AND SAG.SAGSNR = 10876
    group by sag.afdeling, sag.sagsnr, sag.start_dato, sag.stat, BOGF_TRANS.TRANSTYPE
    Any ideas?

    Moved to more sutable forum, sorry.

  • Functional area(FKBER field in the selection screen of the report painter))

    Hi,
    I have a requirement to add functional area field in the selection screen for a report painter report. This report using library 1VK and table 'CCSS'. I added functional area field in the general data selection . After the execution of report with functional area field filled with value. report not giving any output. do i need to maintain any setting to achieve?
    Regards,
    Palani

    1. Call GR22 and click "Characteristics".
    2. Check FKBER and assign a position number to it.
    3. Save and close the library.
    4. Call your report in GRR2 and you should now see FKBER as an available characteristic.
    5. Use it in the General Data Selection or as a Lead Column, as per requirement.
    Or,
    1. Call GR21 and create a custom library. Provide a name and description and also provide a library you can copy from (scan for the best-fit library).
    2. Now follow the steps 2 through 5 above to achieve your result.
    Hope this helps.
    Cheers.

  • Selective Deletion of the Cube contents in Abap Program of the PChain

    Dear Experts
    I need to selectively delete the contents in Basic Infocube using Process Type - ABAP Program in the Process Chain in BW 3.5
    For this I have to give the Variant and Program name in the Process Type - ABAP Program in the Process Chain
    The ABAP Program for this purpose can be generated automatically by the system in the the below navigation
    info cube> Manage>contents > system menu(in the Top)> Status
    but this abap program is changing dynamically every time and hence in the Process chain ABAP Program node is failing with error saying that that program is not available
    I have tried the same way  in the selective deletin navigation path also in the cube manage
    Please let me know how to get the system generated program to use in the Process type-ABAP Program in Process Chain
    Thanks for all in advance
    KSR

    Hi KSR,
    Try this.. start a selective deletion on the cube. you will get a background job running. Get the job name from SM37.
    Now write a ABAP program with the below code.
    parameter: p_Job_Name type sysuuid_c.
    CALL METHOD cl_rscrmbw_bapi=>exec_rep_in_batch
    EXPORTING i_barepid = l_jobnam.
    Execute the above program. Pass the job name which you got from SM37.
    Create a variant with that job name.
    Now schedule this newly created program. This should solve your issue.
    Note : The job name might vary from one server to another (Dev / Qual / Prod). So if you are planning to move your process chain from Dev, then pass the Job name (in prod) as the variant in yr Dev system and then transport it.
    Cheer,
    Balaji Venugopal

  • Delaying a function so ADF will get all the selected rows and run only 1 time ?

    Hello,
    I'm using JDeveloper 12.1.2.0.0.
    I have a group of functions that are executed after i click on one or more rows, which is called:
    public void onDimProjectSelect(SelectionEvent selectionEvent)
    Whenever i shift-click some rows (lets say, for the purpose of this example, that i shift-click the 1st row to the 5th row, so i shift select and i get selected the rows: 1,2,3,4 and 5).
    I did notice that what happens is that the function onDimProjectSelect will execute with the 1st row, and after it runs all the functions, it will run again the function onDimProjectSelect with the 1, 2, 3, 4 and 5 rows as it should in the first place.
    Why is this happening? I've tried to add a delay but i did not work.
    This is really a pain because its spending time executing a function without all of the rows that is suppose to have, so it will run again.
    I think the problem here is how ADF does the selections for the function but i don't know how to change it.
    Any ideia of why is this happening? What can i do to correct this?
    Regards,
    Frederico.

    Hey Frank,
    I mean that my function onDimProjectSelect has other functions inside that need to be executed so when i say that is runs all the functions i mean the functions that are suppose to execute when onDimProjectSelect is executed.
    Maybe the problem is my implementation approach but it was required to use the selection. But the funny part is that i select with the shift-click and he knows that, since it will run the function with all the rows that are selected but firstly he will execute the function with just the first selected row.

  • Select Max record for the report

    Post Author: ROMZILBER
    CA Forum: WebIntelligence Reporting
    Hello,
    Here is our problem we have history data on a table like
    Example
    Data:
    11111   bbb       12/31/2004
    11111   nnn       12/31/2005
    11111   ddd       12/31/2007
    On a report we only need to display the most current record (based on a date).
    11111   ddd       12/31/2007
    How can we do that, we have try to create subquery but it does not allowed to enter logic for the max date for the same id.  So we are kind of stuck, I am more then sure this would be a very common conditions specially for data warehousing.
    we are on Oracle 10g
    Thank you for all your help.

    Post Author: ROMZILBER
    CA Forum: WebIntelligence Reporting
    To create a view is not a problem, supporting it is a different story
    But we have find a solution, you were correct about the filter.  I just did not know you can put the whole subselect in a  filter
    but here is a logic for the filter if someone would come up with the same problem
    tablename.NNNN_PROOF_DT = (SELECT MAX(X.NNNN_PROOF_DT) FROM tablename X  WHERE tablename.NNNN_CLAIM_NUMBER = X.NNNN_CLAIM_NUMBER AND   tablename.NNNN_LINE_CD = X.NNNN_LINE_CD)
    please let me know if you have any questions.
    sorry I am new to this so please do not take any offense

  • Use a package function inside a select of the same package

    Hi.
    How can i use a function defined inside a package, with a select used inside that same package ?
    Example
    ... package example
    CREATE OR REPLACE PACKAGE BODY pkg_example
    AS
         FUNCTION sum_two_values(p_val1 NUMBER,p_val2 NUMBER) RETURN NUMBER
         IS
         BEGIN
         RETURN p_val1 + p_val2;
         END sum_two_values;
         FUNCTION use_another_function_example RETURN VARCHAR2
         IS
         v_value NUMBER;
         BEGIN
         SELECT sum_two_values(2,2) INTO v_value FROM dual;
         RETURN 'waaaazzzzupppppp'
         END use_another_function_example;
    END pkg_example;
    This will not work
    -- SELECT sum_two_values(2,2) INTO v_value FROM dual;
    How can i call a function inside a select statement, a function of the same package where the query is being called.
    (i have Oracle 9.2x)
    Cheers.

    are you sure? you are not using package1, you are using pack1
    SQL> CREATE OR REPLACE PACKAGE package1
      2  IS
      3     FUNCTION f1
      4        RETURN NUMBER;
      5 
      6     FUNCTION f2
      7        RETURN NUMBER;
      8  END;
      9  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY package1
      2  IS
      3     a   NUMBER;
      4 
      5     FUNCTION f1
      6        RETURN NUMBER
      7     IS
      8     BEGIN
      9        RETURN 1;
    10     END;
    11 
    12     FUNCTION f2
    13        RETURN NUMBER
    14     IS
    15     BEGIN
    16        SELECT package1.f1
    17          INTO a
    18          FROM DUAL;
    19 
    20        RETURN a;
    21     END;
    22  END;
    23  /
    Package body created.
    Why not just this
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE PACKAGE BODY package1
      2  IS
      3     a   NUMBER;
      4     FUNCTION f1
      5        RETURN NUMBER
      6     IS
      7     BEGIN
      8        RETURN 1;
      9     END;
    10     FUNCTION f2
    11        RETURN NUMBER
    12     IS
    13     BEGIN
    14        a:= f1;
    15 RETURN a;
    16     END;
    17* END;
    SQL> /
    Package body created.formatted
    Message was edited by:
    devmiral

Maybe you are looking for