-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnext-working-day-starting-next-monday.abap
64 lines (58 loc) · 1.9 KB
/
next-working-day-starting-next-monday.abap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
METHOD calc_payment_date.
DATA: lv_wotnr TYPE p,
lv_holiday_found TYPE scal-indicator,
lt_thol TYPE TABLE OF thol.
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
datum = ip_approve_date
IMPORTING
wotnr = lv_wotnr.
DATA(lv_payment_date) = CONV d( ip_approve_date + ( 8 - lv_wotnr ) ).
DO.
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
datum = lv_payment_date
IMPORTING
wotnr = lv_wotnr.
IF lv_wotnr = 6 OR lv_wotnr = 7.
ADD 1 TO lv_payment_date.
ELSE.
CLEAR: lv_holiday_found, lt_thol.
CALL FUNCTION 'HOLIDAY_CHECK_AND_GET_INFO'
EXPORTING
date = lv_payment_date
holiday_calendar_id = 'TR'
with_holiday_attributes = 'X'
IMPORTING
holiday_found = lv_holiday_found
TABLES
holiday_attributes = lt_thol
EXCEPTIONS
calendar_buffer_not_loadable = 1
date_after_range = 2
date_before_range = 3
date_invalid = 4
holiday_calendar_id_missing = 5
holiday_calendar_not_found = 6
OTHERS = 7.
CASE lv_holiday_found.
WHEN 'X'.
READ TABLE lt_thol ASSIGNING FIELD-SYMBOL(<ls_thol>) INDEX 1.
CASE sy-subrc.
WHEN 0.
CASE <ls_thol>-klass.
WHEN '2'. "yarım gün
EXIT.
WHEN OTHERS.
ADD 1 TO lv_payment_date.
ENDCASE.
WHEN OTHERS.
ADD 1 TO lv_payment_date.
ENDCASE.
WHEN OTHERS.
EXIT.
ENDCASE.
ENDIF.
ENDDO.
rv_payment_date = lv_payment_date.
ENDMETHOD.