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

Function module on date

Former Member
0 Likes
487

HI!

IS there any function module existing wherein I give the Date(eg 09/09/2005) and daytext( eg: monday --etc.

The function module should return the date for Monday ( this date should be after 09/09/2005)

eg : date - 09/10/2005 ( mm/dd/yyyy)

daytext - tuesday

the function module should return me the tuesdays date ( 09/13/2005)

3 REPLIES 3
Read only

Former Member
0 Likes
449

Hi,

There is no FM that suits your requirement.

But you can use DATE_COMPUTE_DAY , which will return the weekday of the date . Say 1 For Monday , 2 for Tuesday .

You can use this to get your date of desired Day .

Cheers

Read only

andreas_mann3
Active Contributor
0 Likes
449

Hi ,

try that:

REPORT zforum51 .

PARAMETERS:date LIKE sy-datum DEFAULT '20050909',
           day LIKE t246-langt DEFAULT 'Tuesday',
           sprsl LIKE t246-sprsl DEFAULT 'EN'.

DATA i .
DATA z TYPE p DECIMALS 0.


SELECT SINGLE wotnr  FROM  t246 INTO i
       WHERE  sprsl  = sprsl
       AND    langt  = day.

IF sy-subrc <> 0.
  MESSAGE e001(00) WITH 'false input'.
ENDIF.

CALL FUNCTION 'DAY_IN_WEEK'
     EXPORTING
          datum = date
     IMPORTING
          wotnr = z.

WHILE i <> z.
  ADD 1 TO date.

  CALL FUNCTION 'DAY_IN_WEEK'
       EXPORTING
            datum = date
       IMPORTING
            wotnr = z.
ENDWHILE.

WRITE: day, 15 date.

Andreas

Read only

0 Likes
449

use this to get the nth day of the week

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

datum = date

IMPORTING

wotnr = z.

Use this to name of the day

CALL FUNCTION 'DAY_NAMES_GET'

EXPORTING

LANGUAGE = SY-LANGU

TABLES

DAY_NAMES = DAY_NAMES

EXCEPTIONS

DAY_NAMES_NOT_FOUND = 1

OTHERS = 2.

Read table DAY_NAMES with key WOTNR = z.

day_name_short_text = DAY_NAMES-KURZT.

day_name_long_text = DAY_NAMES-LANGT.

regards

gv