07-26-2007 1:37 PM
Hello every one.
Can any body help me in solving this please:
The year must be entered in 4 digit format for EX...2005 but the dbtab-year is in 8digit format(20050923).
parameters: p_year type dbtab-year
select * from dbtab
into corresponding fields of table it_tab where year = p_year
How could I limit the year in the entry screen to 4 digits but it could still be used in the where condition referring to dbtab-year(dbtab-year is in 8digits).
I would really much appreciate and help. Thank you all in advance.
Nina.
07-26-2007 1:41 PM
not sure if this will work in a where condition, but you could try:
select * from dbtab
into corresponding fields of table it_tab where year(4) = p_year
07-26-2007 1:44 PM
Hi,
parameters: p_year(4) type c.
based on the P_year you will get the exact date i mean the 8 digit charecter date then use the below one .
select * from dbtab
into corresponding fields of table it_tab where year = p_year123.
Regards
sudheer
07-26-2007 1:46 PM
Hi,
You need to select a range of date if the only information you have is the year. So, just do this :
parameters : p_year type gjahr.
data : l_date_low like sy-datum,
l_date_high like sy-datum.
l_date_low(4) = p_year.
l_date_low+4(4) = '0101'.
l_date_high(4) = p_year.
l_date_high+4(4) = '1231'.
select * from dbtab into corresponding fields of table it_tab where year between l_date_low and l_date_high.
Regards,
Nicolas.
07-26-2007 1:46 PM
Hello Nadin Ram,
Use this...
data: p_year1(4).
p_year1 = p_year+0(4).
Then you will get only year into p_year1.
Use p_year1 in where in condition.
Reward if helpful
Regards
--
Sasidhar Reddy Matli.
Message was edited by:
Sasidhar Reddy Matli
07-26-2007 1:47 PM
but if u specify yar in selection screen, how will u know for which date this should be executed in where condition.... the date can be anything within 365 days.... so atleast u need to mention month in selection screen and try using either first day or last day for the year and month combination... there are FM to fetch the dates.
07-26-2007 1:50 PM
define input as
DATA year TYPE DBTAB-YEAR.
PARAMETES : p_year TYPE BKPF-GHAJR .
year = p_year.
select * from dbtab
into corresponding fields of table it_tab where year = year.
07-26-2007 2:47 PM
Thank you all for your respond. But the issue is still to be resolve. Below is my complete coding.
SELECTION-SCREEN: BEGIN OF BLOCK blk00 WITH FRAME TITLE text-000.
PARAMETERS: p_year TYPE gjahr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk00
SELECT * FROM DBtab
INTO CORRESPONDING FIELDS OF TABLE it_tab
where year = p_year.
The lenght of field DBtab-year is 8 digits(e.g 20050925) but the year must be entered in 4digts for example 2005. After you enter the year 2005 all data in that year(all months with data in 2005) will be displayed. I haven't been able to achieve this. Any help will be more then appreciated.
Nadin
07-26-2007 2:57 PM
SELECTION-SCREEN: BEGIN OF BLOCK blk00 WITH FRAME TITLE text-000.
PARAMETERS: p_year TYPE gjahr OBLIGATORY.
SELECTION-SCREEN end of block blk00 .
ranges r_year FOR dbtab-year .
r_year-sign = 'I'
r_year-option = 'BT' .
CONCATENATE p_year '01' '01' INTO r_year-low .
CONCATENATE p_year '12' '31' INTO r_year-high .
APPEND r_year .
SELECT * FROM dbtab
INTO CORRESPONDING FIELDS OF TABLE it_tab
WHERE year IN r_year .
Message was edited by:
Pawan Kesari
07-26-2007 4:58 PM
Hi Pawan,
Thank you but no success. I couldn't understand why you use this two statements:
CONCATENATE p_year '01' '01' INTO r_year-low .
CONCATENATE p_year '12' '31' INTO r_year-high
.
I did use them though but I can't get any day if I just entered the year e.g. 2002 etc.
I think some one might have this same problem. Any help will be really appreciated.
Thank you all. Please help.
Nadin.
07-26-2007 5:05 PM
Hi,
Check this
parameters : p_year type gjahr.
data : l_date_from like sy-datum,
l_date_to like sy-datum.
concatenate p_year '0101' into l_date_from.
concatenate p_year '1231' into l_date_to.
select * from dbtab into corresponding fields of table it_tab where year >= l_date_from and year <= l_date_to.
07-28-2007 7:05 PM
This last code did help me alot:
parameters : p_year type gjahr.
data : l_date_from like sy-datum,
l_date_to like sy-datum.
concatenate p_year '0101' into l_date_from.
concatenate p_year '1231' into l_date_to.
Thank you all for participating.
Nadin