Hello I'm new to Cobol and I'm having trouble with REDEFINE a TABLE.
So I'm reading an input file of about 4000 lines, and the length of each record is 59 bytes long but not all 59 are used. For example: "A G T J S K H E T Y "
01 WS-CLASS-IN.
03 WS-CLASS-FILL1 PIC X(7).
03 WS-CLASS-CODE PIC X(52).
01 WS-CLASS-TABLE.
03 WS-CLASS-ITEM OCCURS 4000 TIMES.
05 WS-CLASS-CODE-T PIC X(52) VALUE SPACES.
03 CLASS-INDEX PIC 9(4) VALUE ZEROS.
Here is my method
010-PROCESS-LOAD-CLASS-TBL.
PERFORM 600-READ-DFI-CLASS-IN THRU 600-EXIT
IF WCLASS-EOF = 'Y'
GO TO 010-EXIT
END-IF
ADD 1 TO CLASS-INDEX
MOVE WS-CLASS-CODE TO WS-CLASS-CODE-T(CLASS-INDEX)
DISPLAY WS-CLASS-CODE.
010-EXIT.
EXIT.
My above code works and I'm able to display the string of characters. My next step is to remove the spaces which I'm having an epic headache, I've tried it in many ways but I was unsuccessful. I read that I have to use REDEFINE
01 WS-CLASS-TABLE.
03 WS-CLASS-ITEM OCCURS 4000 TIMES.
05 WS-CLASS-CODE-T PIC X(52) VALUE SPACES.
05 WS-CLASS-CODE-R REDEFINES WS-CLASS-CODE-T
OCCURS 26 TIMES.
10 WS-CLASS-R PIC X(1) VALUE SPACES.
10 FILLER PIC X(1) VALUE SPACES.
03 CLASS-INDEX PIC 9(4) VALUE ZEROS.
03 I PIC 9(4) COMP VALUE ZEROS.
03 J PIC 9(4) COMP VALUE ZEROS.
03 K PIC 9(4) COMP VALUE ZEROS.
03 WCLASS-TEMP PIC X(52) VALUE SPACES.
I'm trying to make a new table where I can put the String of Characters and just pull from there WS-CLASS-R.
WCLASS is my output
ICLASS is my input file
MOVE SPACES TO WCLASS
MOVE WS-CLASS-CODE-T(ICLASS) TO WCLASS-TEMP
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 26
ADD 1 TO J
MOVE WS-CLASS-R(I) TO WCLASS(J)
END-PERFORM.
What am I doing wrong? Please help
_Karin_