Application Development 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: 

How do I calculate some date?

Former Member
0 Kudos

Hello,

I need a variable that should keep the <next_tuesday>.

Not a certain one, but a general one.

Any clues?

Thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Use DAY_IN_WEEK to pass a date and get the day of the week. 1 is Monday, 2 is Tuesday and 7 is Sunday. Once you know one Tuesday's date, then you can always add 7 days to it, to get the next Tuesday. So if I am executing my program today (Thrusday), using this function module gives me a 4, that way I know that today is Thrusday and I go back 2 days to get the date of Tuesday and then add 7 to get the next Tuesday, or you can just add 5.

8 REPLIES 8

Former Member
0 Kudos

Hi Anda,

Use function module <b>DAY_ATTRIBUTES_GET</b> to get the attributes of dates for the specified range of dates for a factory/holiday calendar.

Give the DATE_FROM as a date and give the DATE_TO as 7 days to the DATE_FORM. Query on the DAY_ATTRIBUTES table for your requirement.

Thanks,

Vinay

former_member194669
Active Contributor
0 Kudos

Hi,

Can you please give some more details of your requirement

Former Member
0 Kudos

Hi,

try this:

DATA: DATE LIKE SY-DATUM.

DATA: DAY LIKE SCAL-INDICATOR.

DATA: DAY_TEXT LIKE RNPB2-DAY_TXT.

*

DATe = SY-DATUM.

*

DO.

*

CALL FUNCTION 'ISH_GET_DAY_OF_WEEK'

EXPORTING

DATE = DATE

IMPORTING

DAY = DAY

DAY_TXT = DAY_TEXT.

*

IF DAY = 2.

WRITE: / DATE, DAY, DAY_TEXT.

EXIT.

ENDIF.

*

DATE = DATE + 1.

*

ENDDO.

regards, Dieter

Former Member
0 Kudos

HI,

data : lv_today like sy-datum,

lv_7days like sy-datum.

data : it_days like standard table of CASDAYATTR,

x_days like casdayattr.

lv_today = sy-datum.

lv_7days = sy-datum + 7.

call function 'DAY_ATTRIBUTES_GET'

exporting

DATE_FROM = lv_today

date_to = lv_7days

TABLES

DAY_ATTRIBUTES = it_days.

if sy-subrc eq 0.

read table it_days into x_days where WEEKDAY = 2 weekday_s = 'TU'.

<b>now x_days will contain the next tuesday.</b>

endif.

Former Member
0 Kudos

I have to write a message that gives the expiration date and time , but the date should be always <next_tuesday> , because the process that gives the message when is done is weekly .

So I should put my <next_tuesday> in a parameter and calculate it somehow..I think .

0 Kudos

HI,

with the above code you will have the date in x_days-DATE field.. then you can wirte a message.

message e000(Messageclass) with 'Expiration date is ' x_days-date .

Thaks

mahesh

Former Member
0 Kudos

Use DAY_IN_WEEK to pass a date and get the day of the week. 1 is Monday, 2 is Tuesday and 7 is Sunday. Once you know one Tuesday's date, then you can always add 7 days to it, to get the next Tuesday. So if I am executing my program today (Thrusday), using this function module gives me a 4, that way I know that today is Thrusday and I go back 2 days to get the date of Tuesday and then add 7 to get the next Tuesday, or you can just add 5.

0 Kudos

Hi,

May be this way


call function 'DAY_ATTRIBUTES_GET'
exporting
DATE_FROM = sy-datum
date_to = sy-datum
TABLES
DAY_ATTRIBUTES = it_days.
if sy-subrc eq 0.
read table it_days into x_days index 1.
if sy-subrc eq 0.
  if x_days-weekday > 2.
      v_diffdays = 9 - x_days-weekday.
  else.
      v_diffdays = 2 - x_days-weekday.
  endif.
  next_tuesday = sy-datum + v_diffdays
endif.
endif.