05-26-2009 10:57 AM
Hi experts,
i need to do select from pa0001 where pernr = ....and
begda is the most new date
i mean if there is a row in pa0001 like this:
begda = 1.1.2009
pernr = 1234
begda = 2.2.2009
pernr = 1234
so he take the second row.
any help will be appreciated.
thanks.
Michal.
05-26-2009 11:03 AM
Dear Michal,
You can select record as desending or max(field).
Try with this in your select query. may this will help you solve your problem.
Regards,
vijay
05-26-2009 11:02 AM
hi
first short table by begda decending
now select single where <ur condition>
or select ..........upto 1 rows.
Edited by: mayank jain on May 26, 2009 12:03 PM
05-26-2009 11:02 AM
Hi,
If you want all ways the latest entery for the PA0001 use endda = '99991231'.
else if you want the latest entey of today use begda <= sy-datum AND endda >= sy-datum.
05-26-2009 11:03 AM
Dear Michal,
You can select record as desending or max(field).
Try with this in your select query. may this will help you solve your problem.
Regards,
vijay
05-26-2009 11:09 AM
Try this.
tables pa0001.
select * from pa0001
up to 1 ROWS
order by begda DESCENDING.
write: / pa0001.
endselect.
Thanks,
Mahesh
05-26-2009 11:12 AM
Hi,
Use this select statement.
select max( begda ) from pa0001 into v_begda.
05-26-2009 11:23 AM
hi,
Select all records......... sort BEGDA......... then delete duplicate records.
select * from PA0001
order by begda descending.
delete duplicate comparing PERNR.
ags.
05-26-2009 11:23 AM
Check the code Below
parameters p_pernr like pa0001-pernr.
data:
begin of wa,
pernr like pa0001-pernr,
begda like pa0001-begda,
end of wa.
data v_begda like pa0001-begda.
select max( begda )
from pa0001
into v_begda
where pernr = p_pernr.
if sy-subrc eq 0.
select single pernr begda
from pa0001
into wa
where pernr = p_pernr and
begda = v_begda.
write: wa-pernr,wa-begda.
endif.
05-26-2009 11:38 AM
hi,
just a sample code, try this
data: begin of itab occurs 0,
mblnr type mseg-mblnr,
bwart type mseg-bwart,
flag type c,
end of itab.
select mblnr
bwart
into CORRESPONDING FIELDS OF TABLE itab
from mseg
where mblnr = '0049000000'.
SORT itab by mblnr bwart DESCENDING.
loop at itab.
on CHANGE OF itab-mblnr.
itab-flag = 'N'.
MODIFY itab.
endon.
ENDLOOP.
delete itab where flag is INITIAL.
05-26-2009 12:12 PM
select pernr
from pa0001
where pernr = 'Employee Number' and
begda <= sy-datum and
endda >= sy-datum.
05-26-2009 1:55 PM
Hi,
While selecting itself you can restrict by using the max( ) function.