i am trying to check a string for value '&' and replace it using '&'. Please find the code below.
I am not able to identify where i m missing it. pls share your ideas guys.
Thanks.
01 WS-SUB1 PIC S9(04) COMP.
01 WS-SUB2 PIC S9(04) COMP.
01 WS-TEMP PIC S9(04) COMP.
01 WS-VAR.
05 WS-DESC PIC X(30) VALUE 'AAA & BBB'.
05 WS-DESC1 REDEFINES WS-DESC OCCURS 30 TIMES
DEPENDING ON WS-SUB1.
10 WS-CHAR PIC X(01).
01 WS-VAR1.
05 WS-DESC2 REDEFINES WS-DESC OCCURS 100 TIMES
DEPENDING ON WS-SUB2.
10 WS-CHAR1 PIC X(01).
PROCEDURE DIVISION.
0000-MAINLINE.
MOVE 1 TO WS-SUB1
WS-SUB2
PERFORM UNTIL WS-TEMP > 30
IF WS-DESC1(WS-SUB1) = '&'
MOVE WS-DESC1(WS-SUB1) TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB1
WS-SUB2
MOVE '&' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
MOVE 'a' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
MOVE 'm' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
MOVE 'p' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
MOVE ';' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
ELSE
MOVE WS-DESC1(WS-SUB1) TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB1
WS-SUB2
END-IF
END-PERFORM
01 WS-SUB2 PIC S9(04) COMP.
01 WS-TEMP PIC S9(04) COMP.
01 WS-VAR.
05 WS-DESC PIC X(30) VALUE 'AAA & BBB'.
05 WS-DESC1 REDEFINES WS-DESC OCCURS 30 TIMES
DEPENDING ON WS-SUB1.
10 WS-CHAR PIC X(01).
01 WS-VAR1.
05 WS-DESC2 REDEFINES WS-DESC OCCURS 100 TIMES
DEPENDING ON WS-SUB2.
10 WS-CHAR1 PIC X(01).
PROCEDURE DIVISION.
0000-MAINLINE.
MOVE 1 TO WS-SUB1
WS-SUB2
PERFORM UNTIL WS-TEMP > 30
IF WS-DESC1(WS-SUB1) = '&'
MOVE WS-DESC1(WS-SUB1) TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB1
WS-SUB2
MOVE '&' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
MOVE 'a' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
MOVE 'm' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
MOVE 'p' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
MOVE ';' TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB2
ELSE
MOVE WS-DESC1(WS-SUB1) TO WS-DESC2(WS-SUB2)
ADD 1 TO WS-SUB1
WS-SUB2
END-IF
END-PERFORM