DATE_CONVERT_TO_FACTORYDATE — Convert Calendar Date to Factory Workday Sequence
DATE_CONVERT_TO_FACTORYDATE turns an ordinary calendar date into a factory date, a workday-sequence number valid only within one specific factory calendar. It underlies scheduling logic in PP, PM, MM and QM that needs to add or subtract workdays without looping over weekends and holidays. It is a low-level calendar utility, not a formally released customer API, so calendar ID must come from real master data and every exception must be checked, never swallowed.
This page covers what DATE_CONVERT_TO_FACTORYDATE actually returns, why the output cannot be treated as a normal date, and the exception handling that separates a safe caller from a silent scheduling error. It also covers ownership of the underlying factory calendar master data, since most production incidents trace back there rather than to the function module itself.
Published 16 Sept 2026· 1,426 words
What it does
DATE_CONVERT_TO_FACTORYDATE converts an ordinary calendar date into a factory date: a sequential workday index expressed against a specific factory calendar, the calendar object used across PP, PM, MM and QM to describe which days a plant, work center or planning object actually works on. The output is not a calendar date in the everyday sense; it is a running count of working days that lets other logic add or subtract whole numbers of workdays without stepping through weekends and holidays by hand. It sits in the general calendar function group underneath scheduling logic rather than being exposed as a supported application API. It is not formally released for customer use in the sense of a guaranteed stable interface; most usages found in customer code are the result of a developer tracing standard scheduling logic and reusing the same low-level call rather than a deliberate design choice.
Parameters
The interface is short: one date in, one factory date out, plus the calendar key and a flag that decides how a non-working input date is handled. Only the input date field is safe to assume by name; the calendar key and correction indicator naming should be confirmed against the actual released interface before being hardcoded into new code.
- DATE (importing, type D) - the calendar date to convert, in ordinary Gregorian format.
- Factory calendar identifier (importing) - the short key of the factory calendar to use, commonly the calendar ID maintained in factory calendar customizing; the exact parameter name is not certain and should be verified before coding against it.
- Correction indicator (importing) - controls what happens when DATE itself is not a working day in the chosen calendar: whether the call should fail, or silently roll the date forward or backward to the nearest working day before converting.
- FACTORYDATE (exporting) - the resulting workday-sequence value. It has the shape of a date field but its numeric value is meaningful only relative to the calendar that produced it; it is not interchangeable with a factorydate produced against a different calendar.
Exceptions
Each exception here is a signal that either the calendar master data or the input is wrong, not that the function module is unreliable. Discarding any of them turns a hard, visible failure into a soft, invisible scheduling error that surfaces much later, usually as a wrong production, maintenance or delivery date.
- Factory calendar not found - the calendar ID passed does not exist, or exists but has not been generated for the plant or company involved. If caught and ignored, FACTORYDATE is left at its initial value and any later arithmetic built on it silently produces a nonsense schedule date rather than a clear error.
- Date outside the calendar's generated range - factory calendars are only built out for a limited window of years and have to be extended periodically by whoever owns calendar maintenance; a date past the last generated year, or before the first, raises this exception. Swallowing it produces the same silent nonsense-date problem, typically surfacing months later as orders scheduled into the wrong year.
- Date not valid - the input itself is not a real calendar date, almost always the result of bad string-to-date conversion or concatenation upstream, not a defect in this function module.
- Correction indicator not allowed - a value outside the small set the function module accepts was passed; this is a coding defect in the caller and should never occur once a program is stable.
- Swallowing any of these without checking sy-subrc is the single most common way this function module causes damage: it fails safely by raising an exception, and only becomes dangerous when the caller ignores that exception.
How to call it safely
Call it with every relevant exception listed explicitly rather than a blanket OTHERS, and check sy-subrc immediately afterward; do not use FACTORYDATE if sy-subrc is non-zero. Resolve the factory calendar ID from the actual master data of the object being scheduled, the plant, the work center or the assigned planning calendar, and never hardcode a calendar key, because a hardcoded key that happens to match the development system's default calendar will silently point at the wrong calendar, or none at all, once the program runs in a different client or company code. On failure, log the calendar ID and the input date together so calendar maintenance can be checked; the fix is almost always in the calendar's generated range or its assignment, not in the calling code.
ECC vs S/4HANA
The factory calendar mechanism itself has not been re-architected for S/4HANA, so this function module continues to work unchanged where existing code still calls it; there is no simplification-list retirement and no newer released successor. It is not a clean-core-friendly building block, being a basis utility rather than a public API, so new S/4HANA extensions should avoid calling it directly and instead rely on the scheduling logic already exposed by the relevant application, which resolves the correct calendar and performs the conversion internally. Where a direct call cannot be avoided, wrapping it in a local function isolates the risk if the low-level interface ever changes.
Common pitfalls
Most real incidents are master-data or misuse problems dressed up as function module bugs.
- Hardcoding the factory calendar ID instead of reading it from the plant, work center or planning calendar master data; it matches the calendar in the development client and looks fine in testing, then silently resolves to the wrong calendar, or none, once the program runs in another company code or client.
- Ignoring the date-out-of-range exception in mass batch jobs run early in a new fiscal year, because the factory calendar was generated only through the previous year and calendar maintenance had not yet extended it; the job either dumps for every date in the new year or, worse, produces schedule dates rolled back into the old year if the exception is caught and discarded.
- Treating FACTORYDATE as an ordinary date field and writing it straight into a display field or a normal date column; the value is only meaningful as a workday count relative to the calendar that produced it, and moving it into a context expecting a real calendar date produces a date that looks valid but is wrong.
- Mixing factorydates computed against two different factory calendars in the same arithmetic, for example combining a factorydate offset calculated for one plant with a factorydate produced for another plant; the two sequences do not line up and the result is meaningless without raising any runtime error.
- Always requesting the fail-hard correction behavior in unattended background processing, so a batch run aborts entirely the first time it hits a public holiday instead of being told to roll to the nearest working day.
Whose problem this is
Correct behavior depends on two separate owners. Whoever maintains factory calendar customizing, the calendar definitions, holiday assignment and the generated year range, owns the master data; most exception tickets trace back to a calendar that was never extended into the current year or never assigned to the plant or work center in question. The ABAP developer who wrote the calling code owns correct exception handling and correct resolution of which calendar ID to pass. When this function module misbehaves in production, check calendar maintenance before assuming a code defect.
Related SAP objects
Reviewed pages this object connects to in the ERPClimb knowledge graph.
Source: ERPClimb — https://erpclimb.com/sap-function-modules/date-convert-to-factorydateERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.