DATE_COMPUTE_DAY - ABAP Function

How to display the day of week for a given date?

This function module DATE_COMPUTE_DAY determines the day of the week for a date. 
The date must be passed with a valid value.

Call (transaction SE37)  function module DATE_COMPUTE_DAY.

Import parameters
- DATE

Export
- DAY

Exceptions

Function Group
- SCAL

Results:

If it returns

  • 1 monday
  • 2 tue
  • 3 wed
  • 4 thu
  • 5 fri
  • 6 sat
  • 7 sunday
An example:

CALL FUNCTION 'DATE_COMPUTE_DAY'
       EXPORTING
            DATE = workdate
       IMPORTING
            DAY  = day_of_week_num
       EXCEPTIONS
            OTHERS  = 8.

CASE day_of_week_num.

    WHEN 1.
      hold_day_of_week = 'Monday'.
    WHEN 2.
      hold_day_of_week = 'Tuesday'.
    WHEN 3.
      hold_day_of_week = 'Wednesday'.
    WHEN 4.
      hold_day_of_week = 'Thursday'.
    WHEN 5.
      hold_day_of_week = 'Friday'.
    WHEN 6.
      hold_day_of_week = 'Saturday'.
    WHEN 7.
      hold_day_of_week = 'Sunday'.
    WHEN OTHERS.
      hold_day_of_week = 'invalid'.

ENDCASE.

ABAP

See Also:
Help on Conversion From Numbers to Text Amount

More Function Module
Functions / SAP Script / ALV

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.