SAP Zinsrechnung Listing

Das Listing zum Workshop Thema Zinsrechnung im SAP System.

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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
REPORT zs_zinsen.
* Achtung: Festpunktarithmetik ist aus
TYPES: BEGIN OF tab1,
dat TYPE dats,
bet TYPE p DECIMALS 2,
zvo TYPE dats,
zta TYPE i,
zin TYPE azinssatz,
zsu TYPE p DECIMALS 2,
gsu TYPE p DECIMALS 2,
END OF tab1.
 
DATA: it_tab1 TYPE TABLE OF tab1,
wa_tab1 LIKE LINE OF it_tab1,
wa_tab TYPE t056p,
r_itab TYPE REF TO data,
l_alv TYPE REF TO cl_salv_table,
l_cols TYPE REF TO cl_salv_columns_table,
l_col TYPE REF TO cl_salv_column_table,
d1 TYPE dats,
d2 TYPE dats,
t1 TYPE i,
z TYPE trff_value.
 
FIELD-SYMBOLS: <wa_tab1> TYPE tab1,
<wa_tab> TYPE t056p,
<tab> TYPE table.
 
PARAMETERS: stdat TYPE t056p-datab,
zins TYPE azinssatz,
betr TYPE p DECIMALS 2.
 
CREATE DATA r_itab TYPE TABLE OF t056p.
ASSIGN wa_tab1 TO <wa_tab1>.
ASSIGN r_itab->* TO <tab>.
 
* Spezialitaet Invertiertes Datum
* Konvertierungsroutine in der Domaene
 
SELECT * FROM t056p INTO TABLE <tab> ORDER BY datab DESCENDING.
CONVERT INVERTED-DATE stdat INTO DATE d1.
CONVERT DATE sy-datum INTO INVERTED-DATE wa_tab-datab.
APPEND wa_tab TO <tab> .
<wa_tab1>-gsu = betr.
LOOP AT <tab> ASSIGNING <wa_tab>.
WRITE: / sy-tabix ,<wa_tab>-datab, <wa_tab>-zsoll.
<wa_tab1>-dat = d1.
CONVERT INVERTED-DATE <wa_tab>-datab INTO DATE d2.
 
IF d2 < d1.
<wa_tab1>-zvo = d2.
<wa_tab1>-zin = <wa_tab>-zsoll + zins.
 
CONTINUE.
ELSEIF d1 = d2.
* Spezialitaet Invertiertes Datum
* Konvertierungsroutine in der Domaene
<wa_tab1>-zin = <wa_tab>-zsoll + zins.
 
READ TABLE <tab> INDEX sy-tabix + 1 INTO <wa_tab>.
CONVERT INVERTED-DATE <wa_tab>-datab INTO DATE d2.
<wa_tab1>-zvo = d1.
 
ENDIF.
 
* CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
* EXPORTING
* i_date_from = d1
* i_date_to = d2
* IMPORTING
* e_days = t1.
 
CALL FUNCTION 'FIMA_DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_von = d1
i_datum_bis = d2
* I_STGMETH = '0'
********************
* Die Zinsberechnungsmothode SZBMETH
* beeinflusst ob Banktage oder Kalendartage
********************
* I_SZBMETH = '1'
IMPORTING
e_tage = t1
.
<wa_tab1>-bet = betr.
<wa_tab1>-zta = t1.
CALL FUNCTION 'Y_ZAHL'
EXPORTING
i_pzahl = <wa_tab1>-zin
* I_FZAHL =
IMPORTING
e_fzahl = z
* E_PZAHL =
.
* z = <wa_tab1>-zin.
* z = z / 10000000.
* FB rechnet mit floatingpoint Zahl. Problem mit Festpunktarithmetik
CALL FUNCTION 'FIMA_INTEREST_COMPUTE'
EXPORTING
i_bbasis = betr
i_pzins = z
i_atage = <wa_tab1>-zta
i_abastage = '360'
IMPORTING
e_bzinsen = <wa_tab1>-zsu.
IF sy-subrc NE 0.
MESSAGE 'Fehler' TYPE 'E'.
ENDIF.
* man achte auf die Typen und deren Konvertierung
* Festpunktarithmetik ist aus!
betr = betr + <wa_tab1>-zsu.
IF t1 > 0.
<wa_tab1>-gsu = betr.
APPEND <wa_tab1> TO it_tab1.
MOVE d2 TO d1.
<wa_tab1>-zin = <wa_tab>-zsoll + zins.
 
<wa_tab1>-zvo = d2.
ENDIF.
ENDLOOP.
<wa_tab1>-dat = sy-datum.
<wa_tab1>-zin = 0.
<wa_tab1>-zta = 0.
<wa_tab1>-zsu = 0.
<wa_tab1>-gsu = betr.
<wa_tab1>-bet = <wa_tab1>-gsu.
APPEND <wa_tab1> TO it_tab1.
CLEAR r_itab.
 
cl_salv_table=>factory(
EXPORTING
list_display = if_salv_c_bool_sap=>true
IMPORTING
r_salv_table = l_alv
CHANGING
t_table = it_tab1
).
 
l_cols = l_alv->get_columns( ).
l_col ?= l_cols->get_column( 'DAT' ).
l_col->set_medium_text( 'Datum ab' ).
l_col ?= l_cols->get_column( 'BET' ).
l_col->set_medium_text( 'Betrag' ).
l_col ?= l_cols->get_column( 'ZVO' ).
l_col->set_medium_text( 'Zins von' ).
l_col ?= l_cols->get_column( 'ZTA' ).
l_col->set_medium_text( 'Tage' ).
l_col ?= l_cols->get_column( 'ZIN' ).
l_col->set_medium_text( 'Zins' ).
* Wichtig für die Darstellung negativer Werte
l_col->set_sign( 'X' ).
l_col ?= l_cols->get_column( 'ZSU' ).
l_col->set_medium_text( 'Zinsen' ).
l_col ?= l_cols->get_column( 'GSU' ).
l_col->set_medium_text( 'Summe' ).
l_alv->display( ).
[gs-fb-comments]