Hello,
Out of curiosity, for instance we have:
Variable A: 011190
Expected result: 01.11.90
In COBOL, what is the shortest method to achieve the above result (in terms of instructions), is it possible to achieve it in one MOVE statement?
The simplest approaches I could think of were; but all had at least 2-3 MOVE:
a. Move Var-A to another Var with definition 99B99B99; and then INSPECT replacing the spaces with '.'
b. Move Var-A to another Var which is redefined- broken into chunks of 2 bytes each; have another variable with redefs, and '.'; then perform a MOVE CORR from the original redef to the redef with '.'.
c. UNSTRING the data
Thank you.
05 WS-SOURCE PIC 9(6) VALUE 011190.
05 WS-TARGET1 PIC 99B99B99.
PROCEDURE DIVISION.
0000-MAIN.
MOVE WS-SOURCE TO WS-TARGET1.
INSPECT WS-TARGET1 REPLACING ALL SPACE BY '.'.
MOVE WS-SOURCE TO WS-TARGET1.
MOVE '.' TO WS-TARGET1 (3 : 1)
WS-TARGET1 (6 : 1).