Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to remove junk chacters

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to remove junk chacters
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    Post subject:
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: 2504
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 04, 2008 5:24 pm    Post subject: How to remove junk chacters
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts replacing junk with hyphen Nitin32 DFSORT/ICETOOL 10 Fri Jun 02, 2017 7:47 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm
No new posts Sort Card to Remove Duplicate records... raj4neo SYNCSORT 2 Wed Jan 25, 2017 4:44 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us