Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
You would need to first build a translate "from" table, initialize a translate "to" table to SPACES, then move the characters to want to keep from the "from" table to the "to" table. It is perfectly fine to use the TALLY Special Register or you can subsitute it with another fullword. Remember, binary variables are your friends .
When you're done with the from-table "build", it will contain X'00' (in position 001) through X'FF' (in position 256).
PERFORM UNTIL TALLY > LENGTH OF WS-XLATE-FROM-TBL
COMPUTE WS-SUB = (TALLY - 1)
MOVE WS-SUB-X (4:) TO WS-XLATE-FROM-TBL (TALLY:1)
ADD 1 TO TALLY
MOVE SPACES TO WS-XLATE-TO-TBL.
MOVE WS-XLATE-FROM-TBL (241:) TO WS-XLATE-TO-TBL (241:10).
In this example and after the "from" table build, move the data beginning at position 241 of the "from" table to position 241 of the "to" table (for a length of 10), which are the numeric values 0-9. The remaining moves are up to you.
You must have a copy of the EBCDIC collating sequence available in order to review what data to keep.
However, keep in mind that the position in the table is always one greater than the value of the byte as it appears in the collating sequence. For example, a capital "A" (decimal 193/X'C1' in the collating sequence), can be found at position 194 of the table.
After completing the "to" table build, issue an INSPECT to remove (as an example) all bogus characters (which you've defined) from WS-WORK-AREA and keep only the data you need.
INSPECT WS-WORK-AREA CONVERTING WS-XLATE-FROM-TBL