Hi All,
I'm new in Cobol and I'm facing a problem while trying to resolve a search over an internal table.I hope you can help me.
I've created an internal table
01 WT-ROLEPLAYERS.
05 WT-ROLEPLAYER OCCURS 10 TIMES
ASCENDING KEY IS WT-CDFILIAC
INDEXED BY WT-INDEX.
10 WT-CODE PIC X(10) VALUE SPACES.
10 WT-FIN-SER-ROL PIC X(23) VALUE SPACES.
10 WT-PHY-OBJ-REL PIC X(11) VALUE SPACES.
where some codes are stored in WT-CODEs.Of these codes I need to know which are the distinct ones and,only for the distinct ones, I need to retrieve other datas from database and inform corresponding WT-FIN-SER-ROL and WT-PHY-OBJ-REL of the table.
I tried to use a binary search but it looks like that it only allows to perform a statement over equal condition.
MOVE WT-CDCODE(WC-1) TO WS-CODE-AUX.
SEARCH ALL WT-ROLEPLAYER
AT END
CONTINUE
WHEN WT-CDCODE (WT-INDEX) IS <> WS-CODE-AUX
COMPUTE WS-INDEX2 = (WT-INDEX) - 1
IF WT-CDCODE(WS-INDEX2) NOT EQUAL SPACES
PERFORM 4314-RETRIEVE-DATA
THRU 4314-RETRIEVE-DATA-EXIT
END-IF
MOVE WT-CDCODE(WT-INDEX) TO
WS-CODE-AUX
END-SEARCH.
Do you know why this code is not correct?There is a way to find out the distincts WT-CODEs?
I'm new in Cobol and I'm facing a problem while trying to resolve a search over an internal table.I hope you can help me.
I've created an internal table
01 WT-ROLEPLAYERS.
05 WT-ROLEPLAYER OCCURS 10 TIMES
ASCENDING KEY IS WT-CDFILIAC
INDEXED BY WT-INDEX.
10 WT-CODE PIC X(10) VALUE SPACES.
10 WT-FIN-SER-ROL PIC X(23) VALUE SPACES.
10 WT-PHY-OBJ-REL PIC X(11) VALUE SPACES.
where some codes are stored in WT-CODEs.Of these codes I need to know which are the distinct ones and,only for the distinct ones, I need to retrieve other datas from database and inform corresponding WT-FIN-SER-ROL and WT-PHY-OBJ-REL of the table.
I tried to use a binary search but it looks like that it only allows to perform a statement over equal condition.
MOVE WT-CDCODE(WC-1) TO WS-CODE-AUX.
SEARCH ALL WT-ROLEPLAYER
AT END
CONTINUE
WHEN WT-CDCODE (WT-INDEX) IS <> WS-CODE-AUX
COMPUTE WS-INDEX2 = (WT-INDEX) - 1
IF WT-CDCODE(WS-INDEX2) NOT EQUAL SPACES
PERFORM 4314-RETRIEVE-DATA
THRU 4314-RETRIEVE-DATA-EXIT
END-IF
MOVE WT-CDCODE(WT-INDEX) TO
WS-CODE-AUX
END-SEARCH.
Do you know why this code is not correct?There is a way to find out the distincts WT-CODEs?