‎2007 Sep 03 12:00 PM
hi experts
we have an ztable(zvcustomer),in that ztable there are 2 fileds customer id and transaction time",one customer may have multiple "transaction time",based on customer id i have to pick the maximum or minimum "transaction time". plse help me how to fetch the data.
‎2007 Sep 03 12:04 PM
select distinct cusid from zvcustomer into corresponding fields of table itab.
loop at itab.
select max(ttime) from zvcustomer into itab-maxtime where cusid = itab-cusid.
select min(ttime) from zvcustomer into itab-mintime where cusid = itab-cusid.
modify itab.
endloop.then write the data
i am just guessing your field names
ttime -> the database field for your transaction time
cusid -> the database field for your customer id
declare the internal table itab with
1. customer id like zvcustomer-cusid
2. maxtime like zvcustomer-time
3. mintime like zvcustomer-time
Message was edited by:
Kris Donald
‎2007 Sep 03 12:08 PM
Get the data first - for a particular user-
SELECT *
from ZTABLE
into i_tran
where userid = p_user.
now do a sort DESCENDING if you want to have the max.
SORT i_TRAN by TRAN_TIME DESCENDING .
READ TABLE I_TRAN INDEX 1. "Fetching the Max value of Tran time.
or
SORT i_TRAN by TRAN_TIME ASCENDING .
READ TABLE I_TRAN INDEX 1. "Fetching the Min value of Tran time.
Hope it helps.
SKC
‎2007 Sep 03 12:22 PM
hi serma......
here is the coding:
data:
begin of wa,
id TYPE <dbtab-fieldname>,
maxtime TYPE <dbtab-fieldname>,
mintime TYPE <dbtab-fieldname>,
END OF wa,
it like STANDARD TABLE OF wa.
select max( ttime ) min( ttime ) FROM <dbtab> INTO TABLE it where
cid = '<customer id>'.