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

Report

Former Member
0 Likes
697

Hi all,

I have one requirement.

The requirement is

1)get the present data (sy-datum)

2) Now i want to find out the name of the day for that date and find the date for the friday which is coming after that date.

eg : if sy-datum = 20.12.2006 then name of tha day = wednesday

then date for friday is 22.12.2006.

plz tell me what are function modules required for this requirement and how to do this.

thanks in advance to all,

regards,

Shoban

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
665

Hi

To get the the day use the FM

RH_GET_DATE_DAYNAME

8 REPLIES 8
Read only

Former Member
0 Likes
666

Hi

To get the the day use the FM

RH_GET_DATE_DAYNAME

Read only

Former Member
0 Likes
665

try this FM

RH_GET_DATE_DAYNAME

regards

shiba dutta

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
665

Hi,

Check these fm

DATE_COMPUTE_DAY Returns day of the week for a particular date(1=Monday, 5=Friday etc.)

DATE_TO_DAY Returns day of the week for a particular date('Monday', 'Friday', 'Sat.')

Read only

athavanraja
Active Contributor
0 Likes
665

use FM

RH_GET_DATE_DAYNAME to get the day name and day number

for example 20.12.2006 it will return

3 and wednesday

now

reduce one from day number and add that to current date 20.12.2006

you will get the following friday date

Regards

Raja

Read only

Former Member
0 Likes
665

Use DATE_COMPUTE_DAY...this returns number.

If 1 then monday

if 2 then tuesday

if 3 wednesday

if 4 thursday

if 5 friday

if 6 saturday

if 7 sunday....so...

if 1.

date = sy-datum + 4.

elseif 2.

date = sy-datum + 3.

elseif 3.

date = sy-datum + 2.

elseif 4.

date = sy-datum + 1.

elseif 5.

date = sy-datum + 0.

elseif 6.

date = sy-datum + 6.

elseif 7.

date = sy-datum + 7.

endif.

Read only

0 Likes
665

Hi,

Use this FM;

DATE_TO_DAY

just give the date and u will get the day

Thanks

Shiva

Read only

anversha_s
Active Contributor
0 Likes
665

hi,

just copy this code

DATA : day LIKE SCAL-INDICATOR,
         attr LIKE TABLE OF CASDAYATTR WITH HEADER LINE,
         wa_date type sy-datum.

CALL FUNCTION 'DATE_COMPUTE_DAY'
  EXPORTING
    date          = sy-datum
 IMPORTING
   DAY           = day
          .
WRITE : day. "wednesday

 
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = sy-datum
days = 2 --------------------> give ur required date
months = 0--------------------> give ur required month
years = 0
signum = '+'
importing
calc_date = wa_date.
 
write :/ wa_date.  " friday date

Regards

Anver

Read only

Former Member
0 Likes
665

Hi,

Use the FM RH_GET_DATE_DAYNAME ,

this gives as output the Day(DAYTXT) and also a value (DAYNR) indicating the day of week .

So Friday will have value 5 , to get the date of friday comming after this day all you need to do is substract the value of DAYNR from 5 and then add the result to your current date.

E.G.

data : v_one type PDAYNR ,
       v_two type TAGBEZ ,
       v_diff type i ,
       v_date type sy-datum.

START-OF-SELECTION.

CALL FUNCTION 'RH_GET_DATE_DAYNAME'
  EXPORTING
    LANGU                     = SY-LANGU
    DATE                      = SY-DATUM
*   CALID                     =
 IMPORTING
   DAYNR                     = v_one
   DAYTXT                    = v_two
*   DAYFREE                   =
* EXCEPTIONS
*   NO_LANGU                  = 1
*   NO_DATE                   = 2
*   NO_DAYTXT_FOR_LANGU       = 3
*   INVALID_DATE              = 4
*   OTHERS                    = 5
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
.
v_diff = 5 - v_one.

v_date = sy-datum + v_diff.

write:/ v_date , v_two.

Regards

Arun