-
-
Save pcf0/d184e57c1f4d0aa64f9217446bd880c5 to your computer and use it in GitHub Desktop.
test program for New Check: Activate fixed point arithmetic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object Type | Message Type | Error Messages | WarningMessages | Information Messages | Check Description | Message Text | Line Number | Column Number for Message | |
---|---|---|---|---|---|---|---|---|---|
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = 12345 | 32 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_Q = 67891 | 33 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: LV_R = 23456 | 34 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = GV_Q | 46 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = '500.12' | 51 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = `500.12` | 56 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = | `500.12` | | 61 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = 4 | 76 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: LV_R = 20 | 77 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = GV_P * LV_R | 86 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = GV_P / LV_R | 91 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = 20 | 101 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = GV_P * LV_I | 111 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = GV_P / LV_I | 116 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: GV_P = 4000 | 126 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: LV_I = LV_I * GV_P | 136 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: LV_I = LV_I / GV_P | 141 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: PIV_RESULT = 4000 | 174 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: PIV_RESULT = 4000 | 178 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: PIV_RESULT = 4000 | 182 | 2 | |
PROG | 3_N | 0 | 0 | 1 | Activate fixed point arithmetic | Statement blocks activation of fixed point arithmetic: PIV_RESULT = 4000 | 186 | 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REPORT. | |
DATA: | |
gv_fixpt TYPE trdir-fixpt, | |
gv_p TYPE p LENGTH 10 DECIMALS 3, | |
gv_q TYPE p LENGTH 10 DECIMALS 4. | |
"get fixed point arithmetic for assertion | |
SELECT SINGLE fixpt FROM trdir INTO gv_fixpt | |
WHERE name = sy-cprog. | |
PERFORM assignment. | |
PERFORM calculation. | |
PERFORM calculation2. | |
PERFORM calculation3. | |
PERFORM parameter_magic. | |
FORM assert USING piv_result TYPE simple | |
piv_str_fixpt TYPE string | |
piv_str_no_fixpt TYPE string. | |
IF gv_fixpt = abap_true. | |
ASSERT piv_result = piv_str_fixpt. | |
ELSE. | |
ASSERT piv_result = piv_str_no_fixpt. | |
ENDIF. | |
ENDFORM. | |
FORM assignment. | |
DATA: | |
lv_r TYPE p LENGTH 10 DECIMALS 3. | |
gv_p = 12345. "not okay | |
gv_q = 67891. "not okay | |
lv_r = 23456. "not okay | |
PERFORM assert USING gv_p | |
`12345.000 ` | |
`12.345 `. | |
PERFORM assert USING gv_q | |
`67891.0000 ` | |
`6.7891 `. | |
PERFORM assert USING lv_r | |
`23456.000 ` | |
`23.456 `. | |
gv_p = gv_q. "not okay | |
PERFORM assert USING gv_p | |
`67891.000 ` | |
`67.891 `. | |
gv_p = '500.12'. "not okay | |
PERFORM assert USING gv_p | |
`500.120 ` | |
`50.012 `. | |
gv_p = `500.12`. "not okay | |
PERFORM assert USING gv_p | |
`500.120 ` | |
`50.012 `. | |
gv_p = |500.12|. "not okay - string template is only detected by hack | |
PERFORM assert USING gv_p | |
`500.120 ` | |
`50.012 `. | |
gv_p = lv_r. "this is okay, because same type | |
PERFORM assert USING gv_p | |
`23456.000 ` | |
`23.456 `. | |
ENDFORM. | |
FORM calculation. | |
DATA: | |
lv_r TYPE p LENGTH 10 DECIMALS 3. | |
gv_p = 4. "not okay | |
lv_r = 20. "not okay | |
PERFORM assert USING gv_p | |
`4.000 ` | |
`0.004 `. | |
PERFORM assert USING lv_r | |
`20.000 ` | |
`0.020 `. | |
gv_p = gv_p * lv_r. "not okay | |
PERFORM assert USING gv_p | |
`80.000 ` | |
`0.080 `. | |
gv_p = gv_p / lv_r. "not okay | |
PERFORM assert USING gv_p | |
`4.000 ` | |
`0.004 `. | |
ENDFORM. | |
FORM calculation2. | |
DATA: | |
lv_i TYPE i. | |
gv_p = 20. "not okay | |
lv_i = 4000. "this is okay, because not type p | |
PERFORM assert USING gv_p | |
`20.000 ` | |
`0.020 `. | |
PERFORM assert USING lv_i | |
`4000 ` | |
`4000 `. | |
gv_p = gv_p * lv_i. "not okay | |
PERFORM assert USING gv_p | |
`80000.000 ` | |
`80.000 `. | |
gv_p = gv_p / lv_i. "not okay | |
PERFORM assert USING gv_p | |
`20.000 ` | |
`0.020 `. | |
ENDFORM. | |
FORM calculation3. | |
DATA: | |
lv_i TYPE i. | |
gv_p = 4000. "not okay | |
lv_i = 20. "this is okay, because not type p | |
PERFORM assert USING gv_p | |
`4000.000 ` | |
`4.000 `. | |
PERFORM assert USING lv_i | |
`20 ` | |
`20 `. | |
lv_i = lv_i * gv_p. "this is okay, because not type p | |
PERFORM assert USING lv_i | |
`80000 ` | |
`80000 `. | |
lv_i = lv_i / gv_p. "this is okay, because not type p | |
PERFORM assert USING lv_i | |
`20 ` | |
`20 `. | |
ENDFORM. | |
FORM parameter_magic. | |
CLEAR gv_p. | |
PERFORM parameter_magic_simple USING gv_p. "not okay | |
PERFORM assert USING gv_p | |
`4000.000 ` | |
`4.000 `. | |
CLEAR gv_p. | |
PERFORM parameter_magic_any USING gv_p. "not okay | |
PERFORM assert USING gv_p | |
`4000.000 ` | |
`4.000 `. | |
CLEAR gv_p. | |
PERFORM parameter_magic_p USING gv_p. "not okay | |
PERFORM assert USING gv_p | |
`4000.000 ` | |
`4.000 `. | |
CLEAR gv_p. | |
PERFORM parameter_magic_none USING gv_p. "not okay | |
PERFORM assert USING gv_p | |
`4000.000 ` | |
`4.000 `. | |
ENDFORM. | |
FORM parameter_magic_simple USING piv_result TYPE simple. | |
piv_result = 4000. | |
ENDFORM. | |
FORM parameter_magic_any USING piv_result TYPE any. | |
piv_result = 4000. | |
ENDFORM. | |
FORM parameter_magic_p USING piv_result TYPE p. | |
piv_result = 4000. | |
ENDFORM. | |
FORM parameter_magic_none USING piv_result. | |
piv_result = 4000. | |
ENDFORM. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment