SAP HR_CL_TERM_YEARS_SERVICE Function Module for Years of Service
HR_CL_TERM_YEARS_SERVICE is a standard hr cl term years service SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Years of Service 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 hr cl term years service FM, simply by entering the name HR_CL_TERM_YEARS_SERVICE into the relevant SAP transaction such as SE37 or SE38.
Function Group: HRCL_PAYROLL_TERMINATION
Program Name: SAPLHRCL_PAYROLL_TERMINATION
Main Program: SAPLHRCL_PAYROLL_TERMINATION
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function HR_CL_TERM_YEARS_SERVICE 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 'HR_CL_TERM_YEARS_SERVICE'"Years of Service.
EXPORTING
P_PERNR = "Personnel Number
P_LSTWD = "Last worked day
* P_LIMIT = 'X' "Top Limit Application
IMPORTING
P_ENTRYDATE = "Start Date
P_YEARS_SERVICE = "Length of Employment Period (Number of Years)
EXCEPTIONS
ENTRY_DATE_NOT_FOUND = 1 PERNR_NOT_ASSIGNED = 2
IMPORTING Parameters details for HR_CL_TERM_YEARS_SERVICE
P_PERNR - Personnel Number
Data type: PERNR-PERNROptional: No
Call by Reference: Yes
P_LSTWD - Last worked day
Data type: P_99S_LSTWDOptional: No
Call by Reference: Yes
P_LIMIT - Top Limit Application
Data type: XFELDDefault: 'X'
Optional: Yes
Call by Reference: Yes
EXPORTING Parameters details for HR_CL_TERM_YEARS_SERVICE
P_ENTRYDATE - Start Date
Data type: P0000-BEGDAOptional: No
Call by Reference: Yes
P_YEARS_SERVICE - Length of Employment Period (Number of Years)
Data type: P0000_AF-NOYRSOptional: No
Call by Reference: Yes
EXCEPTIONS details
ENTRY_DATE_NOT_FOUND - No entry date found
Data type:Optional: No
Call by Reference: Yes
PERNR_NOT_ASSIGNED - Personnel number not assigned yet
Data type:Optional: No
Call by Reference: Yes
Copy and paste ABAP code example for HR_CL_TERM_YEARS_SERVICE 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_p_pernr | TYPE PERNR-PERNR, " | |||
| lv_p_entrydate | TYPE P0000-BEGDA, " | |||
| lv_entry_date_not_found | TYPE P0000, " | |||
| lv_p_lstwd | TYPE P_99S_LSTWD, " | |||
| lv_p_years_service | TYPE P0000_AF-NOYRS, " | |||
| lv_pernr_not_assigned | TYPE P0000_AF, " | |||
| lv_p_limit | TYPE XFELD. " 'X' |
|   CALL FUNCTION 'HR_CL_TERM_YEARS_SERVICE' "Years of Service |
| EXPORTING | ||
| P_PERNR | = lv_p_pernr | |
| P_LSTWD | = lv_p_lstwd | |
| P_LIMIT | = lv_p_limit | |
| IMPORTING | ||
| P_ENTRYDATE | = lv_p_entrydate | |
| P_YEARS_SERVICE | = lv_p_years_service | |
| EXCEPTIONS | ||
| ENTRY_DATE_NOT_FOUND = 1 | ||
| PERNR_NOT_ASSIGNED = 2 | ||
| . " HR_CL_TERM_YEARS_SERVICE | ||
ABAP code using 7.40 inline data declarations to call FM HR_CL_TERM_YEARS_SERVICE
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 PERNR FROM PERNR INTO @DATA(ld_p_pernr). | ||||
| "SELECT single BEGDA FROM P0000 INTO @DATA(ld_p_entrydate). | ||||
| "SELECT single NOYRS FROM P0000_AF INTO @DATA(ld_p_years_service). | ||||
| DATA(ld_p_limit) | = 'X'. | |||
Search for further information about these or an SAP related objects