Max,min value

Hi all
create table temptable(MSISDN int,topupvalue float,topupdate date)I want to fetch msisdn,max(topupvalue),topupdate,min(topupvalue),topupdate from temptable
insert into temptable values (13212324,12.00,'11-JAN-2012');
insert into temptable values (13212324,5.00,'10-JAN-2012');
insert into temptable values (13212324,6.00,'8-JAN-2012');
insert into temptable values (13212324,7.00,'1-JAN-2012');
insert into temptable values (13212324,1.00,'16-JAN-2012');
insert into temptable values (13212325,11.00,'11-JAN-2012');
insert into temptable values (13212325,35.00,'10-JAN-2012');
insert into temptable values (13212325,56.00,'8-JAN-2012');
insert into temptable values (13212325,77.00,'1-JAN-2012');
insert into temptable values (13212325,81.00,'16-JAN-2012');I want to get msisdn it's max topup value and corresponding topupdate ,min topup value and it's corresponding topupdate

try this [not tested]
select
     msisdn,
     max(max_topupvalue) max_topupvalue,
     max(max_topupvalue) max_topupvalue,
     max(min_topupvalue) min_topupvalue,
     max(min_topupdate) min_topupdate
from
     select
          msisdn,
          maxtv max_topupvalue,
          case when topupvalue=maxtv then topupdate else null end max_topupdate,
          mintv min_topupvalue,
          case when topupvalue=mintv then topupdate else null end min_topupdate
     from
          select
               msisdn,
               topupvalue,
               max(topupvalue) over (partition by msisdn) maxtv,
               topupdate,
               min(topupvalue) over (partition by msisdn) mintv
          from
               temptable
group by msisdn

Similar Messages

  • How to find out the max/min value of one field corresponding to a second field in HANA through graphical way.

    Hi,
    I am trying to find out the latest delivery date(EINDT)  for each purchasing document (EBELN) through graphical way.
    The view contains other fields apart from the above mentioned two fields.
    When only the two fields (EBELN, EINDT) are there, then in semantics, I can select 'Max' as aggregation to get the maximum value for each document.
    If I do like this, then I need to join more than 3 views and also so many joins in calculation view. Taking so much time for data preview.
    Hence , please help me in getting the solution while the view contains other fields also.
    Thanks in advance.
    Thanks,
    Jyothirmayi

    Hi Sreehari/Vinoth,
    Thank you for your replies.
    if only two fields are then I can get the max/min values of one field corresponding to other field.
    But more than two fields are there with different values, then let me know how to find out the max/min value of a particular filed corresponding to the 2nd field with other fields also should be in the output.
    I hope you understood my issue.Please revert in case of questions.
    Thanks & Regards,
    Jyothirmayi

  • Is there an easy way to make JSpinner wrap around at max/min values?

    I have several pages with a couple dozen JSpinners to set various values - mostly numeric, but some are not.
    I would like to make them wrap around when either the max or min values are reached.
    Is there an easy way to do this?
    I was hoping for something like an "enableWraparound" property, but I haven't found such an animal.
    I suspect I could add value change listeners to all the components and do it by brute force,
    but there are too many spinners scattered around to make that an option I would like to take.
    Any suggestions?
    Thanks.

    Ok, it looks like custom spinner models are the way to go.
    Hopefully, I can create a couple that are generic enough to meet my requirements without too much pain.
    It looks like the ones I have already created will be easy enough to modify.
    Thanks for the feedback.

  • Displaying Max/Min values with time for analog signals.

    I am sampling analog inputs. I simply want to display the max and min values with the time they occurred. This seems simple but I am new to LabView and can't find a Vi to do this.

    Here's the code. When you run the demo program, you'll see three traces: Green is the max so far, Red is the min so far, and White is the current signal value.
    As the input value cycles, you'll see the two limit values track its extremes. If you have any questions about how it works, just holler.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps
    Attachments:
    min-max_plotter.vi ‏82 KB
    min-max_tester.vi ‏37 KB

  • Max & min value date wise

    I have Table test with columns
    name     value     values_date
    A     40     01/08/2010
    A     10     02/08/2010
    A     10     03/08/2010
    A     10     04/08/2010
    A     20     03/08/2010
    A     50     02/08/2010
    A     50     03/08/2010
    A     50     04/08/2010
    B     100     01/08/2010
    B     10     02/08/2010
    B     20     03/08/2010
    B     10     01/08/2010
    B     100     11/08/2010
    B     100     12/08/2010
    B     100     13/08/2010
    insert into test values('A','40','1/8/2010');
    insert into test values('A','10','2/8/2010');
    insert into test values('A','10','3/8/2010');
    insert into test values('A','10','4/8/2010');
    insert into test values('A','20','3/8/2010');
    insert into test values('A','50','2/8/2010');
    insert into test values('A','50','3/8/2010');
    insert into test values('A','50','4/8/2010');
    insert into test values('B','100','1/8/2010');
    insert into test values('B','10','2/8/2010');
    insert into test values('B','20','3/8/2010');
    insert into test values('B','10','1/8/2010');
    insert into test values('B','100','11/8/2010');
    insert into test values('B','100','12/8/2010');
    insert into test values('B','100','13/08/2010');
    I want OP like
    name     min_value     min_value_date     max_value     max_value_date
    A     10          02/08/2010     50          04/08/2010     
    B     10          01/08/2010     100          13/08/2010

    Santosh.Minupurey wrote:
    Hi.....
    try dis,
    SQL> SELECT A.NAME,A.VALUE,MIN(A.V_DATE),B.VALUE,MAX(B.V_DATE)FROM TEST A,TEST B WHERE
    2  (A.NAME,A.VALUE) IN (SELECT NAME,MIN(VALUE) FROM TEST GROUP BY NAME) AND
    3  (A.NAME,B.VALUE) IN (SELECT NAME,MAX(VALUE) FROM TEST GROUP BY NAME) GROUP BY A.NAME,A.VALUE,B.VALUE;
    NAME            VALUE MIN(A.V_DATE)        VALUE MAX(B.V_DATE)
    A                  10 2/8/2010                50 4/8/2010
    B                  10 1/8/2010               100 13/08/2010Regards,
    Santosh.MinupureyHere is another way using the FIRST and LAST functions
    SQL>select name,
      2  min(value) min_value,
      3  min(v_date) keep (dense_rank first order by value) min_value_date,
      4  max(value) max_value,
      5  max(v_date) keep (dense_rank last order by value) max_value_date
      6  from test
      7  group by name;
    N        MIN_VALUE MIN_VALUE_D        MAX_VALUE MAX_VALUE_D
    A               10 02-AUG-2010               50 04-AUG-2010
    B               10 01-AUG-2010              100 13-AUG-2010For more info, check http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/analysis.htm#i1007059

  • Find the abs(max/min) value error.

    Hi,  SAP experts
    Now I want to find the Abs(max) and Abs(min), (you know, for the displacement, if we want to find the max and min, we have to consider it both "+" and "-"), I use the code:
    local numbervar i;
    local currencyVar min;
    local currencyVar max;
    For i := 1 to GetNumRows-1 do
        If i = 1 then
            min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
            max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
        else
            If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) <= Abs(min) then
                min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
            If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) >=  Abs(max) then
                max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
    if CurrentFieldValue In [max, min] then
        crBold
    else
        crRegular
    But it seems not correct, why?

    Hi Hu,
    See if this works:
    local numbervar i;
    local currencyVar min;
    local currencyVar max;
    For i := 1 to GetNumRows-1 do
        If i = 1 then
            min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
            max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
        else
            If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) <= Abs(min) then
                min := Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex));
            If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) >=  Abs(max) then
                max := Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex));
    if Abs(CurrentFieldValue) In [max, min] then
        crBold
    else
        crRegular
    -Abhilash

  • New solution for Limit the value in JSpinner with changable max/min value

    I have ever stuck with a problem like that :
    1. My application need to get two int value A and B that user input.
    I use two JSpinner with Number format model.
    named in jSpinnerFrom (A value get from) jSpinnerTo (B value get from)
    2. The request is that :
    two value can be any Integer, But the value of (B - A) can not more than 1000.
    I use changeListener added into the JSpinner, when use set value make (B-A) larger than 1000, I set value back.
    But when user press mouse on arrow button, the value will be increase automaticaly, and at last the value can not set back that make (B-A) not larger than 1000.
    3. So I get the BasicArrowButton of the jSpinnerFrom and jSPinnerTo,
    and add a mouselistener on the arrowbutton. When mouseReleased, then chen the value (B-A), if it is larger than 1000, then set it back the proper value.
    Thus I can make the min/max value in the JSpinner be changable, and limit the two input value be in range of 1 - 1000
    Post this wish be help for any one has thus familar request.
    Good Luck!!

    Something like this might work
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    class Spin extends JFrame implements ChangeListener
      JSpinner spinner1;
      JSpinner spinner2;
      JPanel jp;
      public Spin()
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(200,75);
        setLocation(400,300);
        spinner1 = new JSpinner(new SpinnerNumberModel(1000, 1000, 9999, 5));
        spinner1.addChangeListener(this);
        spinner2 = new JSpinner(new SpinnerNumberModel(0, 0, 1000, 5));
        jp = new JPanel();
        jp.add(spinner1);
        jp.add(spinner2);
        getContentPane().add(jp);
      public void stateChanged(ChangeEvent ce)
        int s1 = ((Integer)spinner1.getValue()).intValue();
        jp.remove(spinner2);
        spinner2 = new JSpinner(new SpinnerNumberModel(s1-1000, s1-1000, s1, 5));
        jp.add(spinner2);
        validate();
      public static void main(String[] args) {new Spin().setVisible(true);}
    }

  • Finding MAX/MIN value

    Hi!
    There are different records in PSA.
    When I load to DSO I need only max value for key figure.
    For example, data in PSA:
    Char| KF
    1| 2
    1| 5
    1| 3
    2| 1
    If I use Overwrite then result is:
    1| 3
    2| 1
    If I use Sum then result is:
    1| 10
    2| 1
    But I need followed reult:
    1| 5
    2| 1
    How can I find max value for KF without using FM or Programs?

    Hi,
    You can do this in a Start routine.
    Sort the source package and copy the records with the max value to another internal table which has the same structure as your source package.
    In the end of the routine, over write records in source package with the records in the internal table.
    THis will help.
    - Jaimin

  • How to dynamic to add +/- 10 to the y axis based on returned data value max/min

    Hi,
    We have two ways to extract/present the data/chart. One is using SQL Reporting and one is using EXCEL. However, we hardcoded the max/min value on y asix to various data set so the chart looks good. However, SQL reporting seems using auto on the y asix so
    when some values are 0, it just overlapped with the x-asix as dipicture below (left hand side is SQL reporting and right hand size is EXCEL) 
    Please advise how to add an +/- interval on the y asix based on the max/min returned data value (e.g if the max returned value is 100 and min returned value is 0, the max value on y asix would be 110 and min value of y asix would be -10)
    Thanks

    Hi kkcci88888,
    According to your description, there is a chart in the report, you want to set vertical axis range and interval dynamically. For example, if the max value of the column is 100 and min value is 0, the max value on y axis would be 110 and min value of y axis
    would be -10. If that is the case, please refer to the following steps:
      1. In design surface, right-click Y axis and open Vertical Axis Properties dialog box.
      2. In Axis Options pane, click (fx) button next to Minimum and type the expression like below:
    =Min(Fields!num.Value)- 10
      3. Click (fx) button next to Maximum and type the expression like below:
    =Max(Fields!num.Value)+ 10
      4. Set Interval to 10, Interval type to Number.
    The following screenshots are for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu

  • How do you create a max/min for a series of input in labview 2010

    with labview is there a way to get max/min values from a series of inputs? I want it to graph the data and keep track of what the highest and lowest values were. I am using Labview 2010

    While you don't really define what you mean by a "Series of inputs", maybe Array Min&Max PrByPt might be of interest.
    (For better help, attach a simplified VI that shows typical data.)
    LabVIEW Champion . Do more with less code and in less time .

  • Record the coordinate point of the max y value on chart

    I am trying to figure out how to get labVIEW to record the x and y values at the coordinate point of the location of the max y value.  In other words, at the max y value, record the x and y values at that point.  I though of using the max and min fn under signal processing but it only records the maximum value on one axis.  I am using labVIEW 8.6.  Any suggestions?  Also I am very new to LabVIEW so I appologize if this is a really simple problem.

    What do you mean by : "My max/min array does not seem to store the max/min values."
    An array is a serie of numbers, so unless they are all the same there has to be a minimum and a maximum. 
    What do you mean by : "...return to zero within a second or two..."
    Does your vi hang for a second or two or what? 
    What do you mean by : '...to stay at the max value until I exceed it?"
    Exceed what? A loop that acquire data continuously or what?  
    The solution provided by smercurio is ok for a static array but I start thinking that you acquire data and want to find the maximum value over different blocks of data.
    Is that it?
    If yes then you need a shift register that retain the maximum of passed blocks. With each new block compare the maximum of that block with the shift register value. If it's larger keep this one as a new maximum. If it isn't larger keep the original value.
    Message Edited by Alain S on 07-03-2009 07:17 PM

  • How to Programmatically Set the limit (max, min input) of a control inside a cluster?

    I want to programmatically set the limit (max, min input) of a control inside a cluster. (see attached VI).
    The max, min value will be read from a file. The input of the control must be within the range defined by the max and min value.
    Can anyone tell me how to do it?
    Thanks a lot for your kind help.
    Xiaogang

    Accessing the properties of a cluster (or array) is not a trivial operation until you have done it once. It's a two step (at least) process : first, ask for a reference (array of...) to the objects contained in the cluster, then tell LV what kind of object you are adressing.
    See the attachment.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    How to set limit[1].vi ‏52 KB

  • How to get the MAX,MIN from the below table...

    Hi,
    Database is SQL2012 R2 Express and I have a table and would like to dig out the MAX,MIN value of a specifiied date (e.g 2014-11-03)
    Thanks

    Nope... It still output more than 1 value on the same date...
    DL-01-BAT 13.00753 13.00753 10/10/2014
    DL-01-BAT 13.01342 13.01342 10/10/2014
    DL-01-BAT 13.02706 13.02706 10/10/2014
    DL-01-BAT 13.03485 13.03485 10/10/2014
    Raw data is
    DL-01-BAT 13.00753 13.00753 10/10/2014 20:00
    DL-01-BAT 13.01342 13.01342 10/10/2014 21:00
    DL-01-BAT 13.02706 13.02706 10/10/2014 22:00
    DL-01-BAT 13.03485 13.03485 10/10/2014 23:00
    You mean after applying my suggestion?
    I dont think so
    See illustration below
    declare @t table
    Item VARCHAR(10), Reading VarChar(50),DateTimeReading DATETIME)
    INSERT @t
    VALUES
    ('DL-01-BAT', 13.00753,'10/10/2014 20:00'),
    ('DL-01-BAT', 13.01342,'10/10/2014 21:00'),
    ('DL-01-BAT', 13.02706,'10/10/2014 22:00'),
    ('DL-01-BAT', 13.03485,'10/10/2014 23:00')
    DECLARE @Date datetime = '20141010'
    SELECT Item,
    MAX(Reading) AS [Max],
    MIN(Reading) AS [Min],
    DATEADD(dd,DATEDIFF(dd,0,DateTimeReading),0) AS [Date]
    FROM @t
    WHERE DateTimeReading >= @Date
    AND DateTimeReading < DATEADD(dd,1,@Date)
    GROUP BY Item, DATEADD(dd,DATEDIFF(dd,0,DateTimeReading),0)
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Query Designer in BI - How to cumulate value and get the Max and Min value.

    I want to create a report with  query designe of BI 7r. is it possible. the data from the cube will be
    Year ,           Exposed Quantity
    1999 ,             200
    2000 ,            100
    2001 ,            -100
    2002 ,             300
    2003 ,           - 200
    2004 ,             100
    2005 ,            -200
    Calculation should be - Refer the cumulative value field
    Year  ,          Exposure Quantity ,   Cumulative value
    1999  ,            200   ,                             200
    2000  ,            100  ,                              300
    2001  ,           -100 ,                               200
    2002  ,            300  ,                              500
    2003  ,          - 200  ,                              300
    2004  ,            100  ,                              400
    2005  ,           -200  ,                              -200
    An the out put of the report  should be Max value ie 500 and Min Value -200.
    My question is that is it possible to do in the front end ie in the Query Designer (BI 7) If so how.
    Edited by: Parakadavil Chacko Mathew on Oct 8, 2009 3:52 AM

    Hi there,
    Create 4 column,
    1st will show regular values for the key figure,
    2nd will show Cumulative value, in Query Designer, Just right click on the this 2nd key figure properties, calculation tab there you can check on Cumulated option, and define the calculation direction as Calculate along the Column.
    3rd will show Minimum value , Just right click on the this 2nd key figure properties, calculation tab calculate single valuea as minimum.
    4th will show Minimum value , Just right click on the this 2nd key figure properties, calculation tab calculate single valuea as Maximum.
    Regards,
    Rajdeep Rane.

  • Min value is appearing same as Max value

    Hi Experts
    I am not getting the correct min value in my report, it is displaying the same from max.
    Can anyone tell me how to get the min value please.
    equipment range
    date range
    unit of measurement
    REPORT Z_ESLP_FUEL LINE-SIZE 200 LINE-COUNT 75
    NO STANDARD PAGE HEADING.
    TABLES : equi,
    equz,
    imptt,
    imrg,
    eqkt,
    iloa.
    Type Declaration
    TYPES: BEGIN OF ty_data ,
            equnr type equnr, " Euipment no
            eqktx type eqkt-eqktx, " Equipment Text
            eqfnr type iloa-eqfnr, " Equipment Sort field
            idate type imrg-idate, " Measuring Date
            recdu type imrg-recdu, " Unit of measuring ='KM','L','H'
            recdv type imrg-recdv, " Counter reading data
          END OF ty_data.
    TYPES: BEGIN OF ty_final,
            equnr type equnr, " Equipment no
            eqktx type eqkt-eqktx, " Equipment Text
            eqfnr type iloa-eqfnr, " Equipment Sort field
            min_date type imrg-idate, " Min Date
            min_km type p decimals 2, " Max Km
            max_km type p decimals 2, " Min km
            t_max_min_km type i, " Total min_km-max_km
            max_date type imrg-idate, " Max Date
            min_hr type imrg-recdv, " Max hr
            max_hr type imrg-recdv, " Min hr
            t_max_min_hr type i, " Total min_hr-max_hr
            min_lit type imrg-recdv, " Max lit
            max_lit type imrg-recdv, " Min lit
            t_max_min_lit type i, " Total min_lit-max_lit
            fuel_con type p decimals 2, " Total_hrs / t_max_min_hr
            km_l type p decimals 2, " km / L
            lit_per_hr type i , " fuel comsumed / t_max_min_hr
          END OF ty_final.
    DATA: i_data TYPE TABLE OF ty_data, " internal table
          wa_data TYPE ty_data, " work area
          i_final TYPE TABLE OF ty_final, " internal table
          wa_final TYPE ty_final. " work area
    data: begin of itab occurs 0,
    num type i,
    end of itab.
    data: v_min_1 type i,
    v_max_1 type i,
    min like imrg-recdv,
    max like imrg-recdv,
    max_dt like imrg-idate,
    min_dt like imrg-idate,
    t_ma_mi type p decimals 2,
    V1 LIKE  IMRG-RECDV  ,
    V2 LIKE IMRG-RECDV  .
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: p_equnr FOR equi-equnr ,"no-extension no intervals,
    p_idate FOR imrg-idate, "NO-EXTENSION NO INTERVALS OBLIGATORY,
    p_recdu FOR imrg-recdu. "NO-EXTENSION NO INTERVALS default 'M3'" OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    SELECTION-SCREEN END OF BLOCK blk2.
    SELECTION-SCREEN END OF BLOCK blk.
    TOP-OF-PAGE.
      FORMAT INTENSIFIED ON.
      WRITE:/1(40) ' INVESTMENT LIMITED '.
      WRITE:/50(40) ' FUEL CONSUMPTION REPORT ' CENTERED ,
      2 'Page', sy-pagno.
      FORMAT INTENSIFIED OFF.
      WRITE:/50(40) '----
    ' CENTERED .
      FORMAT INTENSIFIED ON.
      WRITE:/2 sy-datum COLOR 3, sy-uzeit .
      "WRITE:/1 S903-SPMON ."p_yearf.
      ULINE.
      "CENTERED.
      write: /2 'Date From :'.
      write: /2 'Equipment No :'.
      write: /2 'Unit :'.
      SKIP.
      ULINE.
      WRITE:/1 sy-vline,
      2 'EQUIP NO', 10 sy-vline,
      11 'NAME', 40 sy-vline,
      41 'min date', 50 sy-vline,
      51 'max date', 60 sy-vline,
      61 'min km', 70 sy-vline,
      71 'max km' , 80 sy-vline,
      81 't_max_min_km', 90 sy-vline,
      91 'min hr', 100 sy-vline,
      101 'max hr', 110 sy-vline,
      111 't_max_min_hr' , 120 sy-vline,
      121 'min lit', 130 sy-vline,
      131 'max lit', 140 sy-vline,
      141 't_max_min_lit', 150 sy-vline,
      151 'fuel con', 160 sy-vline,
      161 'km_l', 170 sy-vline,
      171 'lit_per_hr', 180 sy-vline.
      FORMAT COLOR 3 ON.
      ULINE.
    END-OF-PAGE.
    START-OF-SELECTION.
      select aequnr deqktx feqfnr eidate erecdu erecdv
      into table i_data
      from equi  AS a
      inner join equz as b
      on aequnr = bequnr
      inner join iloa as f
      on biloan = filoan
      inner join imptt as c
      on aobjnr = cmpobj
      inner join eqkt as d
      on aequnr = dequnr
      inner join imrg as e
      on epoint = cpoint
      where a~equnr in p_equnr
      and
      e~idate in p_idate
      and
      e~recdu in p_recdu.
        LOOP at i_data into wa_data.
             SORT i_data BY  equnr idate descending .
             "Read table i_data into wa_data index 1.
               move wa_data-recdv to max.
             SORT i_data BY  equnr idate ASCENDING .
            "Read table i_data into wa_data index 1.
               move wa_data-recdv to min.
         on change of wa_data-equnr.
         write:/ wa_data-equnr, wa_data-eqktx ,wa_data-eqfnr ,wa_data-idate ,wa_data-recdu ,
         'MAX',max EXPONENT 0 DECIMALS 2,
         'MIN',min EXPONENT 0 DECIMALS 2.  .
         endon.
        endloop.
    regards
    Piroz

    Hi
    I have change the logic for this program , I have created 2 workareas and internal table now I need help to place the data into
         wa_final-max_date = wa_data-idate.
             wa_final-min_date  = wa_data-idate.
             wa_final-max_km  = wa_data-recdv.
             wa_final-min_km  = wa_data-recdv.
             wa_final-max_hR   = wa_data-recdv.
             wa_final-min_hR   = wa_data-recdv.
             wa_final-max_lit  = wa_data-recdv.
             wa_final-min_lit  = wa_data-recdv.
             wa_final-t_max_min_km   = wa_data-recdv.  " min_km - max_km
             wa_final-t_max_min_hr  = wa_data-recdv.   " min_hr - max_hr
             wa_final-t_max_min_lit  = wa_data-recdv.  " min_lit - max_lit.
    so how can I put the logic to the value please correct my program.seeing my program can anyone give some idea ?
    REPORT Z_FUEL_MONTHLY_QTY LINE-SIZE  260 LINE-COUNT 75
             NO STANDARD PAGE HEADING.
    TABLES : equi,
             equz,
             imptt,
             imrg,
             eqkt,
             iloa.
    Type Declaration
    *DATA: BEGIN OF ty_equi occurs 0,
         equnr type equi-equnr,
         END OF ty_equi.
    *DATA: BEGIN of ty_eqkt occurs 0,
         equnr type eqkt-equnr,
         eqktx type eqkt-eqktx,
         END OF ty_eqkt.
    *DATA: BEGIN of ty_iloa occurs 0,
         iloan type iloa-iloan,
         eqfnr type iloa-eqfnr,
         END OF ty_iloa.
    *DATA: BEGIN of ty_imptt occurs 0,
         mpobj type imptt-mpobj,
         END of ty_imptt.
    *DATA: BEGIN of ty_imrg occurs 0,
         idate type imrg-idate,
         recdv type imrg-recdv,
         recdu type imrg-recdu,
         END of ty_imrg.
    TYPES:  BEGIN OF ty_data  ,
             equnr      type equnr,         " Euipment no
             eqktx      type eqkt-eqktx,    " Equipment Text
             eqfnr       type iloa-eqfnr,     " Equipment Sort field
             idate      type imrg-idate,    " Measuring Date
             recdu      type imrg-recdu,    " Unit of measuring ='KM','L','H'
             recdv      type imrg-recdv,    " Counter reading data
           END OF ty_data.
    TYPES: BEGIN OF ty_final,
             equnr           type equnr,            "  Equipment no
             eqktx           type eqkt-eqktx,       "  Equipment Text
             eqfnr           type iloa-eqfnr,       "  Equipment Sort field
             min_date        type imrg-idate,       "  Min Date
             min_km          type p decimals 2,     "  Max Km
             max_km          type p decimals 2,     "  Min km
             t_max_min_km    type i,                "  Total min_km-max_km
             max_date        type imrg-idate,       "  Max Date
             min_hr          type imrg-recdv,       "  Max hr
             max_hr          type imrg-recdv,       "  Min hr
             t_max_min_hr    type i,                "  Total min_hr-max_hr
             min_lit         type imrg-recdv,       "  Max lit
             max_lit         type imrg-recdv,       "  Min lit
             t_max_min_lit   type i,                "  Total min_lit-max_lit
             fuel_con        type p decimals 2,     "  Total_hrs / t_max_min_hr
             km_l            type p decimals 2,     "  km / L
             lit_per_hr      type i           ,     "  fuel comsumed / t_max_min_hr
           END OF ty_final.
    DATA: i_data TYPE TABLE OF ty_data, " internal table
    wa_data TYPE ty_data, " work area
    i_final TYPE TABLE OF ty_final, " internal table
    wa_final TYPE ty_final. " work area
    DATA :  max_date type date ,
             min_date type date,
             max_km TYPE p DECIMALS 2,
             min_km TYPE p DECIMALS 2,
             max_hr TYPE p DECIMALS 2,
             min_hr TYPE p DECIMALS 2,
             max_lit TYPE p DECIMALS 2,
             min_lit TYPE p DECIMALS 2,
             t_max_min_km  TYPE p DECIMALS 2,
             t_max_min_hr TYPE p DECIMALS 2,
             t_max_min_lit TYPE p DECIMALS 2.
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: p_equnr FOR equi-equnr, "no-extension no intervals,
                    p_idate FOR imrg-idate.  "NO-EXTENSION NO INTERVALS OBLIGATORY,
                    "p_recdu FOR imrg-recdu NO-EXTENSION NO INTERVALS ."default 'M3'" OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    SELECTION-SCREEN END OF BLOCK blk2.
    SELECTION-SCREEN END OF BLOCK blk.
    TOP-OF-PAGE.
      FORMAT INTENSIFIED ON.
      WRITE:/1(40) ' INVESTMENT LIMITED  '.
      WRITE:/50(40) ' FUEL CONSUMPTION REPORT ' CENTERED   ,
              2 'Page', sy-pagno.
      FORMAT INTENSIFIED OFF.
      WRITE:/50(40) '----
    ' CENTERED .
      FORMAT INTENSIFIED ON.
      WRITE:/2 sy-datum COLOR 3, sy-uzeit .
      "WRITE:/1 S903-SPMON ."p_yearf.
      ULINE.
      "CENTERED.
      write: /2 'Date From     :'.
      write: /2 'Equipment No  :'.
      write: /2 'Unit          :'.
      SKIP.
      ULINE.
      WRITE:/1 sy-vline,
        2   'EQUIP NO',              10 sy-vline,
        11  'NAME',                  40 sy-vline,
        41  'SORT',                  60 sy-vline,
        61  'MIN DATE',              74 sy-vline,
        75  'MAX DATE',              87 sy-vline,
        88  'MIN KM',                100 sy-vline,
        101  'MAX KM' ,              113 sy-vline,
        114 'TOTALK',                126 sy-vline,
        127  'MIN HR',               139 sy-vline,
        140 'MAX HR',                152 sy-vline,
        153 'TOTALH' ,               167 sy-vline,
        168 'MIN LIT',               180 sy-vline,
        181 'MAX LIT',               193 sy-vline,
        194 'TOTALL',                206 sy-vline,
        207 'FUEL CON',              219 sy-vline,
        220 'KM L',                  232 sy-vline,
        233 'LIT PER KM',            246 sy-vline.
      FORMAT COLOR 3 ON.
      ULINE.
    END-OF-PAGE.
    START-OF-SELECTION.
    select a~equnr d~eqktx f~eqfnr e~idate e~recdu e~recdv
    into table i_data
    from equi AS a
    inner join equz as b
    on a~equnr = b~equnr
    inner join iloa as f
    on b~iloan = f~iloan
    inner join imptt as c
    on a~objnr = c~mpobj
    inner join eqkt as d
    on a~equnr = d~equnr
    inner join imrg as e
    on e~point = c~point
    where a~equnr in p_equnr
    and
    e~idate in p_idate.
    loop  at i_data into wa_data.
    CLEAR: wa_final.
      READ TABLE i_final into wa_final
               with key equnr = wa_data-equnr.
        if sy-subrc EQ 0.
          PERFORM prepare_final_rec USING'M'. " Modify Existing Record
         ElSE.
          PERFORM prepare_final_rec USING'A'. " Append New Record.
        ENDIF.
        ENDLOOP.
        LOOP AT i_final into wa_final.
        WRITE:/1 sy-vline,
    2  wa_final-equnr                                                 , 10 sy-vline,
    11 wa_final-eqktx                                                 , 40 sy-vline,
    41 wa_final-eqfnr                                                 , 60 sy-vline,
    61 wa_final-min_date                                              , 74 sy-vline,
    75 wa_final-max_date                                              , 87 sy-vline,
    88 wa_final-min_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED           , 100 sy-vline,
    101 wa_final-max_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED          , 113 sy-vline,
    114 wa_final-t_max_min_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED    , 126 sy-vline,
    127 wa_final-min_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED          , 139 sy-vline,
    140 wa_final-max_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED          , 152 sy-vline,
    153 wa_final-t_max_min_hr EXPONENT 0 DECIMALS 2  LEFT-JUSTIFIED   , 167 sy-vline,
    168 wa_final-min_lit EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED         , 180 sy-vline,
    181 wa_final-max_lit EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED         , 193 sy-vline,
    194 wa_final-t_max_min_lit EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED   , 206 sy-vline,
    207 wa_final-fuel_con EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED        , 219 sy-vline,
    220 wa_final-km_l EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED            , 232 sy-vline,
    233 wa_final-lit_per_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED      , 246 sy-vline.
    ULINE.
    endloop.
    FORM prepare_final_rec  USING    p_mode TYPE char1.
    SORT i_data BY equnr idate descending .
            if wa_data-recdu = 'KM'.
            max_km = wa_data-recdv.
            min_km = wa_data-recdv.
            endif.
            if wa_data-recdu ='H'.
            max_hr = wa_data-recdv.
            min_hr = wa_data-recdv.
            endif.
            if wa_data-recdu ='L'.
            max_lit = wa_data-recdv.
            min_lit = wa_data-recdv.
           endif.
       at new equnr.
           read table i_final into wa_final index sy-tabix.
           write:/ wa_final-equnr, wa_final-eqktx ,wa_final-eqfnr ,wa_final-idate ,
           'Min KM',min_km EXPONENT 0 DECIMALS 2 color 7 ,
            'Min H',min_hr EXPONENT 0 DECIMALS 2 color 7 ,
             'Min L',min_lit EXPONENT 0 DECIMALS 2 color 7.
       endat.
    *at end of equnr.
           read table i_data into wa_data index sy-tabix.
           write:/ wa_final-equnr, wa_final-eqktx ,wa_final-eqfnr ,wa_final-idate ,
           'Max KM', max_km EXPONENT 0 DECIMALS 2 color 7,
           'Max H', max_hr EXPONENT 0 DECIMALS 2 color 7,
           'Max L', max_lit EXPONENT 0 DECIMALS 2 color 7.
    *endat.
             wa_final-max_date = wa_data-idate.
             wa_final-min_date  = wa_data-idate.
             wa_final-max_km  = wa_data-recdv.
             wa_final-min_km  = wa_data-recdv.
             wa_final-max_hR   = wa_data-recdv.
             wa_final-min_hR   = wa_data-recdv.
             wa_final-max_lit  = wa_data-recdv.
             wa_final-min_lit  = wa_data-recdv.
             wa_final-t_max_min_km   = wa_data-recdv.  " min_km - max_km
             wa_final-t_max_min_hr  = wa_data-recdv.   " min_hr - max_hr
             wa_final-t_max_min_lit  = wa_data-recdv.  " min_lit - max_lit.
      IF p_mode = 'A'.
        wa_final-equnr = wa_data-equnr.
        wa_final-eqktx = wa_data-eqktx.
        wa_final-eqfnr = wa_data-eqfnr.
        APPEND wa_final TO i_final.
      ELSE.
        MODIFY i_final FROM wa_final
          TRANSPORTING
              max_date
              min_date
              max_km
              min_km
              max_hr
              min_hr
              max_lit
              min_lit
              t_max_min_km
              t_max_min_hr
              where equnr = wa_data-equnr.
      ENDIF.
    ENDFORM.                    " PREPARE_FINAL_REC

Maybe you are looking for

  • Can't assign PPD in Print dialog or preset (ID CS5, Mac OS X 10.6)

    I've been having some trouble recently with ID CS5 resetting itself from time to time as if I'd trashed the Preferences: it loses all Recent files, presets, etc. Fortunately I'd exported presets from CS4 when I upgraded, but there are two problems wi

  • How to delete an element in a tree?

    how can i delete element in my tree? after that to refresh the tree?

  • To avaid label print out in 103 Movement type

    Hi, How to avaid the Label Print out in during GR with 103 Movement Type. Thanks Duraisamy

  • RRI report issue

    Hi all, I have 3 rows in Sender and in receiver 3 more rows which gives detailed level of information about the sender rows. I want to design the RRI setting which will jump only from one row not from all the rows/headers. Is it possible to design, c

  • Tdm importer error when opening tdms file

    I am getting a error when trying to open a tdms file that had been opened by labview, written to, and then closed. The error is: USI encountered an exception: (175):Error while initializing interface I can sort of understand this error occuring when