Get work date in SAP with ABAP important task for SAP developers and I will show example getting factory day in SAP system. If we want to get next work day for sending email, or previous work day for checking activities or work date for planning.
Work date in ABAP
For example, I choose first standard calendar ID from SAP table TFACD. In real work often using custom tables for storage calendars.
1 2 3 |
SELECT SINGLE ident INTO @DATA(lv_calendar_id) FROM tfacd. |
Create string with using inline declaration ABAP in new ABAP syntax and variable for calendar also.
1 |
DATA(lv_str) = '20241015'. |
After preparing data we execute function module DATE_CONVERT_TO_FACTORYDATE for getting first work day since date lv_str. It can be the same date if in lv_str work day or next work day if not.
1 2 3 4 5 6 |
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE' EXPORTING date = CONV datum( lv_str ) factory_calendar_id = lv_calendar_id IMPORTING date = lv_new_date. |
Function module DATE_CONVERT_TO_FACTORYDATE have more parameters then I use in my example. All parameters for this FM:

With parameter CORRECT_OPTION where default value ‘+’ we can choose what we want to get: next work day or previous work day (for this you need to use ‘-‘ ).
Example using DATE_CONVERT_TO_FACTORYDATE
Full ABAP code with example. How to get work day or factory day in SAP:
1 2 3 4 5 6 7 8 9 10 11 12 |
SELECT SINGLE ident INTO @DATA(lv_calendar_id) FROM tfacd. DATA(lv_str) = '20241015'. CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE' EXPORTING date = CONV datum( lv_str ) factory_calendar_id = lv_calendar_id IMPORTING date = lv_new_date. |