Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replacing unwanted characters with zeros

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 126
Location: UK

PostPosted: Thu Oct 18, 2007 12:32 pm    Post subject: Reply to: INSPECT verb to check whether it contains '*' or '
Reply with quote

Hello ,


I just want to all other value to Zeroes (except numeric Value) .

For Example ws-var = ! #$%^&88
i want to replace it like 000000088

that means all other characters replaced with zeroes.


can we do it using INSPECT

Regards
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 18, 2007 12:40 pm    Post subject:
Reply with quote

Hello,

When you have a question, it is usually better to start a new topic for yojr question rather than reply to an almost 2-year-old topic.

What should happen if the value is
Code:
 ws-var = ! #23$%^&88
?

If you merely convert all non-numerals to zeros, you may cause later problems (if the field requires numeric data).
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Oct 18, 2007 1:20 pm    Post subject:
Reply with quote

shr_amar,

Please check with the following code for your requirement.
Code:
       IDENTIFICATION DIVISION.                                   
       PROGRAM-ID. C.                                             
       ENVIRONMENT DIVISION.                                     
       CONFIGURATION SECTION.                                     
       SPECIAL-NAMES.                                             
           CLASS NOTJUNK IS '1' THRU '9' ZERO.                   
       DATA DIVISION.                                             
       WORKING-STORAGE SECTION.                                   
       77 WS-ALPHANUMERIC-IN PIC X(9) VALUE SPACES.               
       77 WS-ALPHANUMERIC-OUT PIC X(9) VALUE SPACES.             
       77 WS-I PIC 99.                                           
       77 WF-JUNK PIC X VALUE 'N'.                               
        88 JUNK-FOUND VALUE 'Y'.                                 
        88 JUNK-NOT-FOUND VALUE 'N'.                             
       PROCEDURE DIVISION.                                       
           ACCEPT WS-ALPHANUMERIC-IN                             
           DISPLAY 'WS-ALPHANUMERIC-IN  ==> ' WS-ALPHANUMERIC-IN 
           PERFORM VARYING WS-I FROM 1 BY 1 UNTIL WS-I > LENGTH OF
                           WS-ALPHANUMERIC-IN                     
            IF WS-ALPHANUMERIC-IN(WS-I:1) IS NOT NOTJUNK         
             SET JUNK-FOUND TO TRUE                               
            END-IF                                               
            IF JUNK-FOUND                                         
             MOVE ZERO TO WS-ALPHANUMERIC-OUT(WS-I:1)             
             SET JUNK-NOT-FOUND TO TRUE                           
            ELSE                                                 
             MOVE WS-ALPHANUMERIC-IN(WS-I:1) TO                   
                 WS-ALPHANUMERIC-OUT(WS-I:1)                     
            END-IF                                               
           END-PERFORM                                           
           DISPLAY 'WS-ALPHANUMERIC-OUT ==> ' WS-ALPHANUMERIC-OUT
           GOBACK.

Input:
Code:
! #$%^&88

Output:
Code:
WS-ALPHANUMERIC-IN  ==> ! #$%^&88
WS-ALPHANUMERIC-OUT ==> 000000088
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Oct 18, 2007 1:34 pm    Post subject:
Reply with quote

shr_amar,

Please check with the following sort jcl for your requirement.
Code:
// EXEC PGM=SORT                                               
//SORTIN DD *                                                   
! #$%^&88                                                       
/*                                                             
//SORTOUT DD SYSOUT=*                                           
//SYSOUT DD SYSOUT=*                                           
//SYSIN DD *                                                   
 OPTION COPY                                                   
 INREC IFTHEN=(WHEN=(1,1,SS,NE,C'0123456789'),OVERLAY=(1:C'0'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(2,1,SS,NE,C'0123456789'),OVERLAY=(2:C'0'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(3,1,SS,NE,C'0123456789'),OVERLAY=(3:C'0'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(4,1,SS,NE,C'0123456789'),OVERLAY=(4:C'0'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(5,1,SS,NE,C'0123456789'),OVERLAY=(5:C'0'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(6,1,SS,NE,C'0123456789'),OVERLAY=(6:C'0'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(7,1,SS,NE,C'0123456789'),OVERLAY=(7:C'0'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(8,1,SS,NE,C'0123456789'),OVERLAY=(8:C'0'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(9,1,SS,NE,C'0123456789'),OVERLAY=(9:C'0'))
/*                                                             
//                                                             

Output:
Code:
000000088
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Oct 18, 2007 1:59 pm    Post subject: Reply to: Replacing unwanted characters with zeros
Reply with quote

Shankar,

You can make use of NUM instead of checking for the digits from 0 - 9

Code:
INREC IFTHEN=(WHEN=(1,1,FS,NE,NUM),OVERLAY=(1:C'0'),
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Oct 18, 2007 2:11 pm    Post subject:
Reply with quote

Aaru,
Quote:
Shankar,

You can make use of NUM instead of checking for the digits from 0 - 9

Code:
INREC IFTHEN=(WHEN=(1,1,FS,NE,NUM),OVERLAY=(1:C'0'),

My site has SYNCSORT FOR Z/OS 1.2.3 and FS and NUM are not available in that version.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Oct 18, 2007 2:18 pm    Post subject:
Reply with quote

Aaru,

Format FS is available but FS,EQ,NUM and FS,NE,NUM are not available in SYNCSORT FOR Z/OS 1.2.3
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Oct 18, 2007 2:26 pm    Post subject: Reply to: Replacing unwanted characters with zeros
Reply with quote

Quote:
My site has SYNCSORT FOR Z/OS 1.2.3 and FS and NUM are not available in that version.


Even my site uses the same version of SYNCSORT and not DFSORT. I posted so that shr_amar can try that option too if DFSORT is installed in his site.
Back to top
View user's profile Send private message
KMV

New User


Joined: 15 May 2007
Posts: 22
Location: Coimbatore

PostPosted: Thu Oct 18, 2007 3:30 pm    Post subject: INSPECT verb to replace characters.
Reply with quote

Hi,
Try this one :
Code:

INSPECT WS-DEC-LIC-NO1 REPLACING
CHARACTERS BY ZEROES.           


This will replace all the characters (a-z and special characters)
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Oct 18, 2007 4:09 pm    Post subject:
Reply with quote

KMV,

The requirement is to replace all characters to zero except the numeric(0,1,2,3,4,5,6,7,8,9).

when i tried with your code, it is replacing all alphabets, numeric and special characters to zeros.

Please check with the below cobol code, input and output using INSPECT statement as suggested by you.
Code:
       IDENTIFICATION DIVISION.                           
       PROGRAM-ID. A.                                     
       DATA DIVISION.                                     
       WORKING-STORAGE SECTION.                           
       77 WS-IN PIC X(9) VALUE SPACES.                   
       77 WS-OUT PIC X(9) VALUE SPACES.                   
       PROCEDURE DIVISION.                               
           ACCEPT WS-IN                                   
           DISPLAY 'WS-IN  ==> ' WS-IN                   
           MOVE WS-IN TO WS-OUT                           
           DISPLAY 'WS-OUT ==> ' WS-OUT '  BEFORE INSPECT'
           INSPECT WS-OUT REPLACING CHARACTERS BY ZERO   
           DISPLAY 'WS-OUT ==> ' WS-OUT '  AFTER  INSPECT'
           GOBACK.

Input:
Code:
! #$%^&88

Output:
Code:
WS-IN  ==> ! #$%^&88               
WS-OUT ==> ! #$%^&88  BEFORE INSPECT
WS-OUT ==> 000000000  AFTER  INSPECT

Note that numeric 88 in ! #$%^&88 are also changed to zeros
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 18, 2007 7:40 pm    Post subject:
Reply with quote

Hello,

To repeat:
Quote:
What should happen if the value is
Code:
 ws-var = ! #23$%^&88

?

If you merely convert all non-numerals to zeros, you may cause later problems (if the field requires numeric data).


Rather than show TS how they might cause problems, i believe it would be good to understand the business requirement that "identified" this "rule".

After the value has been "fixed" how will it be used? If it is a quantity, an amount, or a key to some random read/insert, merely changing all of the not numerals to numerals will likely cause more problems than it solves.
Back to top
View user's profile Send private message
dominickim

New User


Joined: 28 Feb 2007
Posts: 65
Location: NS, CA

PostPosted: Sat Oct 20, 2007 12:17 am    Post subject: How about TSO command
Reply with quote

Code:
Command ===> c all p'-' '0' 1 9                                 Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 ! #$%ï&88                                                               
****** **************************** Bottom of Data ****************************

Code:
Command ===>                                                    Scroll ===> CSR
****** ***************************** Top of Data ******************************
==CHG> 000000088                                                               
****** **************************** Bottom of Data ****************************
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Oct 20, 2007 12:23 am    Post subject:
Reply with quote

Hello dominickim and welcome to the fourms,

Quote:
How about TSO command
Probably not as the request was to do this in COBOL. . . This would be especially true if this was going to be part of a regular, scheduled job.
Back to top
View user's profile Send private message
jmreddymca
Warnings : 1

New User


Joined: 14 Oct 2007
Posts: 29
Location: Bangalore

PostPosted: Mon Oct 22, 2007 5:52 pm    Post subject: Hello dominickim
Reply with quote

Hello dominickim

the command which you mention is not possible you know.
i don't know how you show the result?????
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Oct 22, 2007 7:28 pm    Post subject:
Reply with quote

Hello,
what about using numval-Chttp://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/igy3pg30/1.6.6.3?ACTION=MATCHES&REQUEST=NUMVAL-C&TYPE=FUZZY&SHELF=&DT=20050628164603&CASE=&searchTopic=TOPIC&searchText=TEXT&searchIndex=INDEX&rank=RANK&ScrollTOP=FIRSTHIT#FIRSTHIT
Back to top
View user's profile Send private message
dominickim

New User


Joined: 28 Feb 2007
Posts: 65
Location: NS, CA

PostPosted: Tue Oct 23, 2007 8:50 pm    Post subject: Re: Not possible?
Reply with quote

Quote:

Hello jmreddymca,
What do you mean NOT POSSIBLE? I know it is not a COBOL program he/she wanted to know and I mentioned TSO command first. These are before and after images.
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 Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am
No new posts Join key - Populate Zeros when Unpair... rexx77 DFSORT/ICETOOL 6 Thu May 12, 2016 12:22 am
No new posts Replacing Start Transid with LINK pkmurali CICS 12 Tue Apr 19, 2016 8:22 pm
No new posts Trasnmitting a file with french chara... spoorni IBM Tools 1 Wed Feb 24, 2016 8:13 pm
No new posts How to massage out unwanted lines prino DFSORT/ICETOOL 24 Tue Jan 05, 2016 6:59 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us