‎2009 Aug 20 6:58 AM
Hello Experts,
Please solve my Problem,
In database table i have records like this.
PERNR BEGDA
1 27.07.2006
1 01.04.2007
1 01.01.2008
Now in Report in selection Screen if i give s_Begda as 01.08.2007.
Then it should fetch data of 01.04.2007 that is second row.
if i will give 01.02.2008 t should again fetch only third row that is 01.01.2008.
I tried to use compare Pattern But it is not working,
Please tell me how i can get data in my internal table.
‎2009 Aug 20 7:12 AM
just simple.
Select * from table into table where pernr = pernr Begda <= pn-begda.
endselect.
sort itab by endda descending.
Read table with index 1.
Then you will have the just adjacent record what you want Hope it helps
Regards
sas
Edited by: saslove sap on Aug 20, 2009 8:12 AM
‎2009 Aug 20 7:12 AM
just simple.
Select * from table into table where pernr = pernr Begda <= pn-begda.
endselect.
sort itab by endda descending.
Read table with index 1.
Then you will have the just adjacent record what you want Hope it helps
Regards
sas
Edited by: saslove sap on Aug 20, 2009 8:12 AM
‎2009 Aug 20 7:51 AM
No it is not Working,
suppose i have given date 01022008. It will fetch all three records.
Now u wrote sort it by begda.
Record will come like this.
a 27072006
a 01042007
a 01012008.
as i have selected 01022008 in s_begda.
If i will do read idata index 1.
it will read data of 27072007. Where as i want data of 01012008.
I have done like this:
After fetching Records from Ztabe where begda LE s_begda
delete idata where begda+0(4) ne s_begda+0(4).
‎2009 Aug 20 8:02 AM
‎2009 Aug 20 8:05 AM
Malik Check what soumaya saying "Descending:"
Sort itab by begda by descending.
Regards
sas
‎2009 Aug 20 7:14 AM
from what logic does this work? you want to fetch a record whose begda is just less than or equal to the s_begda?
a way can be:
select pernr begda from ztable into table gt_table where begda LE s_begda.
sort gt_table by begda descending. " this will make the highest record on top.
read table gt_table into gs index 1. " now this holds the data which you want.check the logic and revert back.
you also can try using
select pernr max(begda) from xyz into table gt_table where begda LE s_begda.
‎2009 Aug 20 8:28 AM
Hi Shelly,
Here, it_itab = Internal table that wil hold all the required firlds.
wa_itab = work area for it_itab.
SELECT-OPTIONS s_begda FOR IT_itab-begda.
loop at it_itab into wa_itab.
SELECT (fields to be selected or *) FROM TABLE
INTO wa_itab
WHERE begda = s_begda.
append wa_itab to it_itab.
endselect.
endloop.
Regards,
Sana.