Skip to Content

Factory Time function module

Jul 05, 2017 at 05:46 PM


avatar image

Is there a Func module like DATE_CONVERT_TO_FACTORYDATE but for factory times instead of dates?

Input : Factcal_id, date.

Output should be next working Date, working start time , working end time (or factory begin and end timestamps for a working day for a factcal_id).


Output: work start time and

duration of working seconds on a particular factory date.

10 |10000 characters needed characters left characters exceeded

or another way , given 2 timestamps, can the number of factory hours be derived between those 2 timestamps?

Basically the need is

1. for a given UTC start date-time of a task ,

is that UTC start time within factory working time of plant? If no, replace with next nearest factory working time.

2. For a given UTC end date-time of a task,

taking derived factory working start time from point 1 above, what is the time in factory hours passed (duration) between working start time and working end time.

So we have to derive working start and end date-time and then derive factory hours passed between them.

* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Sandra Rossi Jul 06, 2017 at 02:26 AM

Assuming you have retrieved the start and end times somewhere from your system, your function would resemble this:

function working_seconds_between_timestamps( date1, time1, date2, time2, 
                           plant_factory_calendar, plant_start_time, plant_end_time)
if date1 = date2 then working_seconds = time2 - time1
else if date1 < date2 then
  number_of_working_days calculated from DATE_CONVERT_TO_FACTORYDATE (date1, date2, plant_factory_calendar)
  seconds_first_day = plant_end_time - time1
  seconds_full_days = plant_end_time - plant_start_time
  seconds_last_day = time2 - plant_start_time
  working_seconds = seconds_first_day + ( number_of_working_days - 1 ) * seconds_full_days + seconds_last_day

Of course, you need to adjust many parts of the raw algorithm based on the context and on your exact requirement.

10 |10000 characters needed characters left characters exceeded
Sandra Rossi Jul 06, 2017 at 01:37 AM

The Factory Calendar is only for dates. If you're looking for hours, then this "function module" exists only if there is such a feature in your system, so it's a functional question to ask to an ECC (or SRM, APO, ...?) forum rather than ABAP. When you know the name of this feature, then you can ask how to get it from ABAP.

10 |10000 characters needed characters left characters exceeded