Tip the return value of a method must be checked
This rule is the result of the previous rule, A method must have a return value. If a return value exists, not checking the result might make you ignore an error.
The following is an example of a wrong block of code.
# Let's add a line at the end of a Collection LINES for 'MYORDER' Instance
#
Local Integer LINE_NO
LINE_NO = Fmet MYORDER.ADDLINE("LINES",[V]CST_ALASTPOS)
MYORDER.LINES(LINE_NO).PRODUCT="A"
MYORDER.LINES(LINE_NO).QUANTITY=1
...
This method is incorrect because the "ADDLINE" method can return a '[V]CST_ANOTDEFINED' error code if the insertion is denied. As '[V]CST_ANOTDEFINED' is a negative value, an error will appear for the following assignments.
The correct code is as follows:
# Let's add a line at the end of a Collection LINES for 'MYORDER' Instance
#
Local Integer LINE_NO
LINE_NO = Fmet MYORDER.ADDLINE("LINES",[V]CST_ALASTPOS)
If LINE_NO <> [V]CST_ANOTDEFINED
MYORDER.LINES(LINE_NO).PRODUCT="A"
MYORDER.LINES(LINE_NO).QUANTITY=1
...
Else
# Handle the error
...
Endif