on 2024 Oct 09 11:11 AM
Dear experts,
Kindly suggest me on the below requirement.
Current system config:
We have 4 Attendances codes, as follows: 1019, 1020, 1021 & 1027. And following Wage Types gets generated and added to ZL table for each of the A/A codes respectively, WT2008, WT2009, WT2010, WT2011. Also, there's a condition that users are allowed to register hours on above A/A codes only once for every week.
For example: Person M recorded 1 hour using A/A 1019 on Monday, so he is no more allowed to register hours on the same A/A code or any other A/A codes until next Tuesday.
Kindly help me write a PCR on below requirement or provide any article relating to the same.
Condition: In any given month, the first 3 week's WT's should only gets generated.
For example: In October, the user registered hours for the first three weeks and WT got generated. However, even if the user registers hours in the fourth and fifth week, the WT should not get generated.
Kindly help on above.
Many thanks in advance.
Sai
Request clarification before answering.
To implement the requirement that users can register hours for the specified attendance codes only three times in a given month, follow these steps in your PCR:
Track Instances:
Create a counter to track the number of instances a user has registered hours for the specified attendance codes within the month.
Check Instance Count:
Before generating wage types, check if the instance count is less than or equal to 3.
Generate Wage Types: If the user has registered hours and the instance count is within the limit, generate the wage types; otherwise, do not generate them.
Example for PCR logic outline:
* Initialize variables
INSTANCE_COUNT = GET_INSTANCE_COUNT(USER_ID) * Function to get the count of instances for the user
* Check if the instance count is less than 3
IF INSTANCE_COUNT < 3 THEN
* Check if any attendance codes were used this month
IF ATTENDANCE_CODE_USED(1019) OR ATTENDANCE_CODE_USED(1020) OR ATTENDANCE_CODE_USED(1021) OR ATTENDANCE_CODE_USED(1027) THEN
* Increment the instance count for this registration
INCREMENT_INSTANCE_COUNT(USER_ID)
* Generate wage types
GENERATE_WAGE_TYPE(WT2008)
GENERATE_WAGE_TYPE(WT2009)
GENERATE_WAGE_TYPE(WT2010)
GENERATE_WAGE_TYPE(WT2011)
ENDIF
ENDIF
* Function to get the count of instances for the user
FUNCTION GET_INSTANCE_COUNT(USER_ID)
* Logic to retrieve and return the count of instances registered by the user in the current month
RETURN INSTANCE_COUNT
ENDFUNCTION
* Function to increment the instance count
FUNCTION INCREMENT_INSTANCE_COUNT(USER_ID)
* Logic to increment the instance count for the user in the current month
ENDFUNCTION
* Function to generate wage types
FUNCTION GENERATE_WAGE_TYPE(WAGE_TYPE)
* Logic to add the wage type to the ZL table
ENDFUNCTION
* Function to check if attendance code has been used this month
FUNCTION ATTENDANCE_CODE_USED(ATT_CODE)
* Logic to check if the given attendance code was used in the current month
RETURN USED_FLAG
ENDFUNCTION
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
To implement your requirement using a Personnel Calculation Rule (PCR), you can follow these steps
Define the Week and Month Conditions: You need to determine the current week of the month and check if it's within the allowed range (first three weeks).
Check Attendance Code Registration: Ensure that hours for the specified attendance codes are registered only once per week.
Control Wage Type Generation: Based on the week and whether the attendance codes have been used, control the generation of the wage types.
Please try the below sample code
* Initialize variables
INCLUDE <SAP standard includes for date functions>
* Determine the current week and month
CURRENT_WEEK = GET_CURRENT_WEEK()
CURRENT_MONTH = GET_CURRENT_MONTH()
* Check if the week is within the allowed range
IF CURRENT_WEEK <= 3 THEN
* Check if any of the attendance codes have been used in this week
IF ATTENDANCE_CODE_USED(1019) OR ATTENDANCE_CODE_USED(1020) OR ATTENDANCE_CODE_USED(1021) OR ATTENDANCE_CODE_USED(1027) THEN
* Generate wage types if conditions are met
GENERATE_WAGE_TYPE(WT2008)
GENERATE_WAGE_TYPE(WT2009)
GENERATE_WAGE_TYPE(WT20010)
GENERATE_WAGE_TYPE(WT20011)
ENDIF
ENDIF
* Function to check if an attendance code has been used this week
FUNCTION ATTENDANCE_CODE_USED(ATT_CODE)
* Logic to check if the given attendance code was used in the current week
RETURN USED_FLAG
ENDFUNCTION
* Function to generate wage types
FUNCTION GENERATE_WAGE_TYPE(WAGE_TYPE)
* Logic to add the wage type to the ZL table
ENDFUNCTION
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
4 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.