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: 

displaying people's birthday with users selected day

Former Member
0 Kudos

Dear Abap Experts.

Suppose at a select options field any date can be

choosen or selected up to you. In the next field you can

select a weekday. And now the requirement is

to select "all the people" where have their birthday

on the users selected weekday (e.g. Tuesday) and starting from the

selected date. Only the birthdays where are on tuesdays.

How can this requirement be implemented ?

Regards

sas

1 ACCEPTED SOLUTION

Former Member
0 Kudos

I presented this option when you asked the same question in another thread

This is a demo getting the Day of Week

If you select all the folks with a birthday in your screen range, then use some of the example shown here, you can

DELETE from your internal table if they meet the condition of your Day of Week parm


DATA: str_date    TYPE d,
      end_date    TYPE d,
      dow         TYPE p.
 
SELECT-OPTIONS: mydate FOR sy-datum.
 
 
START-OF-SELECTION.
  str_date = mydate-low.
  IF mydate-high IS INITIAL.
    end_date = mydate-low.
  ELSE.
    end_date = mydate-high.
  ENDIF.
  WHILE end_date GT str_date.
    CALL FUNCTION 'DAY_IN_WEEK'
         EXPORTING
              datum = str_date
         IMPORTING
              wotnr = dow.
    WRITE:/ str_date MM/DD/YYYY,
            dow.
    CASE dow.
      WHEN 1.
        WRITE 'Monday'.
      WHEN 2.
        WRITE 'Tuesday'.
      WHEN 3.
        WRITE 'Wednesday'.
      WHEN 4.
        WRITE 'Thursday'.
      WHEN 5.
        WRITE 'Friday'.
      WHEN 6.
        WRITE 'Saturday'.
      WHEN 7.
        WRITE 'Sunday'.
    ENDCASE.
    str_date = str_date + 1.
  ENDWHILE.

Input was 05/01/2008 to 05/31/2008

The output


05/01/2008               4  Thursday      
05/02/2008               5  Friday        
05/03/2008               6  Saturday      
05/04/2008               7  Sunday        
05/05/2008               1  Monday        
05/06/2008               2  Tuesday       
05/07/2008               3  Wednesday     
05/08/2008               4  Thursday      
05/09/2008               5  Friday        
05/10/2008               6  Saturday      
05/11/2008               7  Sunday        
05/12/2008               1  Monday        
05/13/2008               2  Tuesday       
05/14/2008               3  Wednesday     
05/15/2008               4  Thursday      
05/16/2008               5  Friday        
05/17/2008               6  Saturday      
05/18/2008               7  Sunday        
05/19/2008               1  Monday        
05/20/2008               2  Tuesday       
05/21/2008               3  Wednesday     
05/22/2008               4  Thursday      
05/23/2008               5  Friday        
05/24/2008               6  Saturday      
05/25/2008               7  Sunday        
05/26/2008               1  Monday        
05/27/2008               2  Tuesday       
05/28/2008               3  Wednesday     
05/29/2008               4  Thursday      
05/30/2008               5  Friday        

6 REPLIES 6

former_member673464
Active Contributor
0 Kudos

hi,

you can write logic for fetching the people's details for the given date range from the data base table and then you can delete the details of people who are not in that weekday using the date calculations.

regards,

Veeresh

Former Member
0 Kudos

HI,

u should write ur select as follows,

s_date is ur given date,

s_day is ur given day of birth

select name bdate

from XXXX

into table YYYY

where bdate GE s_date

and bday EQ s_day.

Regards,

kk.

Former Member
0 Kudos

Hello,

thank you for replying.

But the problem is there is no field with weekday (bday).

It must be evaluated separate.

Therefor we can not say:

select ....

and bday EQ s_day.

s_date is ur given date,
s_day is ur given day of birth

select name bdate
from XXXX
into table YYYY
where bdate GE s_date
and bday EQ s_day.

0 Kudos

It is kind of a long process. You can achieve it by the following


data w_date like sy-datum default sy-datum.
s_date is ur given date,
s_day is ur given day of week
 
select name bdate
from XXXX
into table itab1
where bdate GE s_date.

loop at itab1.
  itab1-dob+6(2)=sy-datum+6(2). " get the current year.
* check week day using FM
   DAY_IN_WEEK
     importing
        DATUM itba1-dob
     exporting
         WOTNR  = l_wotnr.

   if l_wotnr = s_day.
     append itab1 to itab2.
   endif.
 endloop.

loop at itab2.
write itab2.
endloop.

hope this helps

reward if helpful.

FY

Former Member
0 Kudos

Hello sas,

One approach would be to

1. Find all those people that have a birthday >= selected date from input screen

2. Sort these people by their birthdays.

3. For each possible birthday use a FM like DAY_IN_WEEK which given a date returns the position of that day in a week. (Mon = 1 Tues =2 .....)

4. Once you know which birthdays fall on the selected day of the week you can select these.

Hope this helps a bit. I know it is a bit short on details

Regards

Greg Kern

Former Member
0 Kudos

I presented this option when you asked the same question in another thread

This is a demo getting the Day of Week

If you select all the folks with a birthday in your screen range, then use some of the example shown here, you can

DELETE from your internal table if they meet the condition of your Day of Week parm


DATA: str_date    TYPE d,
      end_date    TYPE d,
      dow         TYPE p.
 
SELECT-OPTIONS: mydate FOR sy-datum.
 
 
START-OF-SELECTION.
  str_date = mydate-low.
  IF mydate-high IS INITIAL.
    end_date = mydate-low.
  ELSE.
    end_date = mydate-high.
  ENDIF.
  WHILE end_date GT str_date.
    CALL FUNCTION 'DAY_IN_WEEK'
         EXPORTING
              datum = str_date
         IMPORTING
              wotnr = dow.
    WRITE:/ str_date MM/DD/YYYY,
            dow.
    CASE dow.
      WHEN 1.
        WRITE 'Monday'.
      WHEN 2.
        WRITE 'Tuesday'.
      WHEN 3.
        WRITE 'Wednesday'.
      WHEN 4.
        WRITE 'Thursday'.
      WHEN 5.
        WRITE 'Friday'.
      WHEN 6.
        WRITE 'Saturday'.
      WHEN 7.
        WRITE 'Sunday'.
    ENDCASE.
    str_date = str_date + 1.
  ENDWHILE.

Input was 05/01/2008 to 05/31/2008

The output


05/01/2008               4  Thursday      
05/02/2008               5  Friday        
05/03/2008               6  Saturday      
05/04/2008               7  Sunday        
05/05/2008               1  Monday        
05/06/2008               2  Tuesday       
05/07/2008               3  Wednesday     
05/08/2008               4  Thursday      
05/09/2008               5  Friday        
05/10/2008               6  Saturday      
05/11/2008               7  Sunday        
05/12/2008               1  Monday        
05/13/2008               2  Tuesday       
05/14/2008               3  Wednesday     
05/15/2008               4  Thursday      
05/16/2008               5  Friday        
05/17/2008               6  Saturday      
05/18/2008               7  Sunday        
05/19/2008               1  Monday        
05/20/2008               2  Tuesday       
05/21/2008               3  Wednesday     
05/22/2008               4  Thursday      
05/23/2008               5  Friday        
05/24/2008               6  Saturday      
05/25/2008               7  Sunday        
05/26/2008               1  Monday        
05/27/2008               2  Tuesday       
05/28/2008               3  Wednesday     
05/29/2008               4  Thursday      
05/30/2008               5  Friday