INITIALIZE versus MOVE.
Posted: Mon Jan 21, 2019 12:35 pm
Hi,
I have this code written:
To which one of my Team lead has said,
It's better to use MOVE instead of INITIALIZE, however for this code, it should be fine. Is there a rule to use MOVE and not INITIALIZE? What is the difference between the two?
Also he said that
and are redundant as WS-AVG-COST is being calculated in the next statement, so I should remove it. I'm just thinking what difference will it make if keep it there/
I have this code written:
Code: Select all
05 WS-AVG-COST PIC S9(13)V99 COMP-3.
INITIALIZE WS-AVG-COST.
MOVE INB-AVG-COST TO WS-AVG-COST
COMPUTE WS-AVG-COST ROUNDED = INB-AVG-COST * 1
MOVE WS-AVG-COST TO SYU12-INPUT-FIELD
MOVE INB-AVG-COST TO SYU12-INPUT-FIELD
MOVE INI-AVG-COST TO WS-AVG-COST
COMPUTE WS-AVG-COST ROUNDED = INI-AVG-COST * 1
MOVE WS-AVG-COST TO SYU12-INPUT-FIELD
MOVE INI-AVG-COST TO SYU12-INPUT-FIELD
MOVE INI-AVG-COST TO WS-AVG-COST
COMPUTE WS-AVG-COST ROUNDED = INI-AVG-COST * 1 It's better to use MOVE instead of INITIALIZE, however for this code, it should be fine. Is there a rule to use MOVE and not INITIALIZE? What is the difference between the two?
Also he said that
Code: Select all
MOVE INB-AVG-COST TO WS-AVG-COSTCode: Select all
MOVE INI-AVG-COST TO WS-AVG-COST