Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

problem while calculating date based on the selection

Former Member
0 Likes
775

Hi friends,

On my selection screen i have 2 fields

a) 1 WEEK

b) 2 weeks

now when the user enters value yes in 1 week it should display the data which are less than one week old from current date and if user enters yes in 2weeks field then it should display the data which are less than 2 weeks old from the current date.

ie : in my internal table i have a date field zdate

now i should check if the ZDATE is within one week range ( for 1WEEK FIELD ) it should display only that data.

similary i should check for ( 2week field on the selection scree)

How can i do that...

Any function modules available for the above requirment.

Thanks in advance.

Regards

Kumar

6 REPLIES 6
Read only

Former Member
0 Likes
743

HI,

1. Create a variable of type date .

2. Populate the variable l_var = sy-datum -7 or sy-datum - 14 depending on 1 week or 2 week is filled.

3. Create a range table Sign = E, option = BW , low = sy-datum, high = l_var.

4. delete i_tab where zdate in l_var.

Check this

Read only

0 Likes
743

Anurag..

SY-DATUUM - X does not work when the month and year changes..

for example if the current date is 02/01/2010

now if i say sy-datum - 7 , the system will not recognise the month and year change here...

for that reason iam looking for a function module which reterns the date if i enter the current date ie : what is the 7 days before date for 1 week and what is the 14 days week for 2 weeks.

Please let me know if any such function modules exists

Regards

Kumar

Read only

0 Likes
743

Hi Kumar,

SY-DATUUM - X does not work when the month and year changes..

for example if the current date is 02/01/2010

now if i say sy-datum - 7 , the system will not recognise the month and year change here...

I'm not sure what you're saying here is accurate. I created the following piece of code to check;


data l_var type datum.

l_var = '20100102'.

l_var = l_var - 7.

Write: / L_var.

The value of l_var at the end was 26.12.2009, which seems to work for me. Anurag's answer seems to be correct.

Regards,

Nick

P.S. Your question actually breaks the forum rules, questions on manipulating dates have been asked many times before and the answers typically only require basic arithmatic

Read only

Former Member
0 Likes
743

You can check if the ZDATE field lies in between the 2 dates as ...

"p_date = 1 week or 2 weeks. <--- depends on your selection

loop at <internal table> where ZDATE between p_date and sy-datum.

endloop.

Read only

0 Likes
743

Any update on this...

Does any such function module exists..?

Regards

Kumar

Read only

Former Member
0 Likes
743

Helpfull answer