It’ll be big issue if using standard operation ADDMB in middle of month. As SAP mentioned carefully on HR310+-+Time+Evaluation+With+Clock+Times page 194:
Only using ADDMB if the current date in Time Evaluation – TE is end of month (normally it’s 30 or 31 and 28 or 29 in Feb). Why is it big problem if we are put ADDMB in middle of month? As the wrong value will be generated in case re-run TE. So in the document I will share why is wrong and how to change your PCR / Schema to adjust with complicated requirements.
Anyway, NOTE: only using ADDMB on EOM. If using in middle of month, you MUST change and correct your solution. Recommendation: instead of using ADDMB, standard function CUMBT and configuration in V_T555A are the best option for accumulating in TE.
Simply calculate how many days from 26th last month to 5th current month.
III.1 Solution with ADDMB
Step 1: everyday assign 1 into time type ZV01 with configuration as below. Because all configuration in V_T555A is 1 so SAP will automatically accumulate in function CUMBT.
in PCR ZV00
Step 2: if the date is 26th, using ADDMB to clear accumulate value. Meaning all accumulating before 26th will be blank.
Step 3: if the date is 05th, get value for accumulate table with time type ZV02 and assign to time type ZV02.
Step 4: assign into schema. Just put before CUMBT, so current value HRS=MZV01 (accumulate value before current date). It’s reason why on 5th we have to plus both HRS=MZV01 & HRS+DZV01 (MZV01 accumulate before 5th and DZV01 current value for 5th).
III.2 Solution with ADDMB testing
It’s perfect if there is no re-run in TE. The value is 11 (from 26th Oct to 5th Nov). I captured on SALDO on 5th. Clearing by ADDMB on 26th last month is working fine.
It’s WRONG when re-run TE. (note the start date of the employee is 1st Oct so it’s the reason why until 5th Nov total is 36 days). As whenever re-run TE, accumulated by ADDMB in middle of month will be ignored.
III.3 New Solution
Creating new Time Type ZV03 shares same characteristics with Time Type ZV01. The purpose of ZV03 is holding total accumulate until 25th. When 5th comes, retrieving current accumulated in ZV01 minus accumulated until 25th. That’s all. Plz check carefully in pcr ZVT0 as below. Only changing pcr, no need adjust schema.
Why have to minus MZV03?
Without minus MZV03: (only HRS=MZV01 ADDDBZV03Z), the logic as below:
On 26th Oct, value in MZV01 is 25 => the value 25 will be updated into ZV03.
On 26th Nov, value in MZV01 will be 31 ( in Oct) + 25 (in Nov) = 56 days.
The value will be added into MZV03. As previous value in Oct is 25, add more 56 days in Nov => total value in ZV03 = 25 + 56 = 81 days. Wrong. The purpose of ZV03 is holding total accumulate until 25th => have to minus.
III.4 New Solution Testing
The value of Time Type ZV02 is always 11 even re-run TE many times . ZV03 contains total day before 26th => ZV03 value is 25. ZV01 still holds all total day from 1st Oct to 5th Nov => ZV01 value is 36.
Solution: if you want to accumulate from date X to date Y (example from Mon to Sun every week), 3 steps below must be done:
1. creating 2 Time types (ZV01 & ZV03) with all configurations are 1 in V_T555A
2. when the date in TE is X (eg Mon) => add MZV01 into ZV03 (note: must be minus current value in ZV03).
3. when the date in TE is Y (eg Sun) => simply assign ZV02 = DZV01 + MZV01 – MZV03 => output is accumulate from X to Y (from Mon to Sun).
If ZV01 contains daily working hour, ZV02 will be total working time on this week. Normally it’s 40hrs. If it’s bigger than 40hrs, you can generate Over Time.
If ZV01 is working day, X is 16th and Y is 15th, so you can calculate total working day from 16th last month to 15th current month, etc.