IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to remove junk chacters


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Anand78

New User


Joined: 06 Mar 2006
Posts: 50
Location: PUNE

PostPosted: Tue Mar 04, 2008 3:08 pm
Reply with quote

Hi ,


Pls tell me how to remove chacters like x'07' , X'2d'. Etc.. etc..

Chacters like that we find with comand F P'.'.

For me the above task to be done using cobol

Thanks
Anand
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Tue Mar 04, 2008 4:06 pm
Reply with quote

SEARCH FOR INSPECT REPLACING/CONVERTING.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 04, 2008 5:24 pm
Reply with quote

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 icon_wink.gif .

When you're done with the from-table "build", it will contain X'00' (in position 001) through X'FF' (in position 256).

Code:

03  WS-SUB PIC  9(08) BINARY.
03  WS-SUB-X REDEFINES WS-SUB PIC  X(04).
03  WS-XLATE-FROM-TBL PIC  X(256).
03  WS-XLATE-TO-TBL PIC  X(256).
03  WS-WORK-AREA PIC  X(500).

MOVE 1 TO TALLY.

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
END-PERFORM.

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.

Code:

INSPECT WS-WORK-AREA CONVERTING WS-XLATE-FROM-TBL
                     TO WS-XLATE-TO-TBL.

HTH....

Regards,

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Remove leading zeroes SYNCSORT 4
No new posts How to remove block of duplicates DFSORT/ICETOOL 8
No new posts To Remove spaces (which is in hex for... JCL & VSAM 10
Search our Forums:

Back to Top