SAP DURATION_DETERMINE Function Module for Calendar: Determine duration between two times
DURATION_DETERMINE is a standard duration determine SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Calendar: Determine duration between two times processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for duration determine FM, simply by entering the name DURATION_DETERMINE into the relevant SAP transaction such as SE37 or SE38.
Function Group: SCA4
Program Name: SAPLSCA4
Main Program: SAPLSCA4
Appliation area: S
Release date: 02-Jul-1997
Mode(Normal, Remote etc): Normal Function Module
Update:
Function DURATION_DETERMINE pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'DURATION_DETERMINE'"Calendar: Determine duration between two times.
EXPORTING
* UNIT = "Time unit
* FACTORY_CALENDAR = "Factory calendar
IMPORTING
DURATION = "Duration
CHANGING
* START_DATE = SY-DATUM "Start date
* START_TIME = SY-UZEIT "Start Time
* END_DATE = SY-DATUM "End Date
* END_TIME = SY-UZEIT "End Time
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1 DATE_OUT_OF_CALENDAR_RANGE = 2 DATE_NOT_VALID = 3 UNIT_CONVERSION_ERROR = 4 SI_UNIT_MISSING = 5 PARAMETERS_NOT_VALID = 6
IMPORTING Parameters details for DURATION_DETERMINE
UNIT - Time unit
Data type: T006-MSEHIOptional: Yes
Call by Reference: No ( called with pass by value option)
FACTORY_CALENDAR - Factory calendar
Data type: SCAL-FCALIDOptional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for DURATION_DETERMINE
DURATION - Duration
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
CHANGING Parameters details for DURATION_DETERMINE
START_DATE - Start date
Data type: SY-DATUMDefault: SY-DATUM
Optional: Yes
Call by Reference: No ( called with pass by value option)
START_TIME - Start Time
Data type: SY-UZEITDefault: SY-UZEIT
Optional: Yes
Call by Reference: No ( called with pass by value option)
END_DATE - End Date
Data type: SY-DATUMDefault: SY-DATUM
Optional: Yes
Call by Reference: No ( called with pass by value option)
END_TIME - End Time
Data type: SY-UZEITDefault: SY-UZEIT
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
FACTORY_CALENDAR_NOT_FOUND - Factory calendar not found
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DATE_OUT_OF_CALENDAR_RANGE - Date outside factory calendar validity
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DATE_NOT_VALID - Date is invalid
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
UNIT_CONVERSION_ERROR - Time unit conversion error
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
SI_UNIT_MISSING - Time unit missing
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
PARAMETERS_NOT_VALID - Input parameters invalid
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for DURATION_DETERMINE Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.DATA: | ||||
lv_unit | TYPE T006-MSEHI, " | |||
lv_duration | TYPE T006, " | |||
lv_start_date | TYPE SY-DATUM, " SY-DATUM | |||
lv_factory_calendar_not_found | TYPE SY, " | |||
lv_start_time | TYPE SY-UZEIT, " SY-UZEIT | |||
lv_factory_calendar | TYPE SCAL-FCALID, " | |||
lv_date_out_of_calendar_range | TYPE SCAL, " | |||
lv_end_date | TYPE SY-DATUM, " SY-DATUM | |||
lv_date_not_valid | TYPE SY, " | |||
lv_end_time | TYPE SY-UZEIT, " SY-UZEIT | |||
lv_unit_conversion_error | TYPE SY, " | |||
lv_si_unit_missing | TYPE SY, " | |||
lv_parameters_not_valid | TYPE SY. " |
  CALL FUNCTION 'DURATION_DETERMINE' "Calendar: Determine duration between two times |
EXPORTING | ||
UNIT | = lv_unit | |
FACTORY_CALENDAR | = lv_factory_calendar | |
IMPORTING | ||
DURATION | = lv_duration | |
CHANGING | ||
START_DATE | = lv_start_date | |
START_TIME | = lv_start_time | |
END_DATE | = lv_end_date | |
END_TIME | = lv_end_time | |
EXCEPTIONS | ||
FACTORY_CALENDAR_NOT_FOUND = 1 | ||
DATE_OUT_OF_CALENDAR_RANGE = 2 | ||
DATE_NOT_VALID = 3 | ||
UNIT_CONVERSION_ERROR = 4 | ||
SI_UNIT_MISSING = 5 | ||
PARAMETERS_NOT_VALID = 6 | ||
. " DURATION_DETERMINE |
ABAP code using 7.40 inline data declarations to call FM DURATION_DETERMINE
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8."SELECT single MSEHI FROM T006 INTO @DATA(ld_unit). | ||||
"SELECT single DATUM FROM SY INTO @DATA(ld_start_date). | ||||
DATA(ld_start_date) | = SY-DATUM. | |||
"SELECT single UZEIT FROM SY INTO @DATA(ld_start_time). | ||||
DATA(ld_start_time) | = SY-UZEIT. | |||
"SELECT single FCALID FROM SCAL INTO @DATA(ld_factory_calendar). | ||||
"SELECT single DATUM FROM SY INTO @DATA(ld_end_date). | ||||
DATA(ld_end_date) | = SY-DATUM. | |||
"SELECT single UZEIT FROM SY INTO @DATA(ld_end_time). | ||||
DATA(ld_end_time) | = SY-UZEIT. | |||
Search for further information about these or an SAP related objects