Tuesday, May 6, 2008

SAP ABAP Function Module for getting day of the week

SAP ABAP Function Module for getting day of the week

The function module to get the day of the week is given below.

DAY_IN_WEEK

This function module computes the day of the week from the date. Examine the program given below.


REPORT ZEX_DAYINAWEEK .

Parameters: P_date like sy-datum.

data: d_wotnr type p.


CALL FUNCTION 'DAY_IN_WEEK'
     EXPORTING
          DATUM = P_date
     IMPORTING
          WOTNR = d_wotnr.


Case d_wotnr.

  when '1'.
    Write:/ 'Day = ', 'Monday'.

  when '2'.
    Write:/ 'Day = ', 'Tuesday'.

  when '3'.
    Write:/ 'Day = ', 'Wednesday'.

  when '4'.
    Write:/ 'Day = ', 'Thursday'.

  when '5'.
    Write:/ 'Day = ', 'Friday'.

  when '6'.
    Write:/ 'Day = ', 'Saturday'.

  when '7'.
    Write:/ 'Day = ', 'Sunday'.

Endcase.

The output of the above program is as follows.

Input 05/05/2008

OutPut

Get day in a week         
                          
Day =  Monday   

Input 03/05/2008

OutPut

Get day in a week  
                   
Day =  Wednesday   

Input

05/05/2008

OutPut

Get day in a week    
                     
Day =  Thursday 

    



         

No comments:

Post a Comment