View previous topic :: View next topic
|
Author |
Message |
shr_amar Warnings : 2 Active User
.jpg)
Joined: 02 May 2005 Posts: 128 Location: UK
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
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:
Output:
Code: |
WS-ALPHANUMERIC-IN ==> ! #$%^&88
WS-ALPHANUMERIC-OUT ==> 000000088 |
|
|
Back to top |
|
 |
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
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:
|
|
Back to top |
|
 |
Aaru
Senior Member

Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 |
|
 |
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
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 |
|
 |
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
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 |
|
 |
Aaru
Senior Member

Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 |
|
 |
KMV
New User

Joined: 15 May 2007 Posts: 22 Location: Coimbatore
|
|
|
|
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 |
|
 |
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
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:
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
dominickim
New User
Joined: 28 Feb 2007 Posts: 65 Location: NS, CA
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
jmreddymca Warnings : 1 New User
Joined: 14 Oct 2007 Posts: 29 Location: Bangalore
|
|
|
|
Hello dominickim
the command which you mention is not possible you know.
i don't know how you show the result????? |
|
Back to top |
|
 |
krisprems
Active Member

Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
Back to top |
|
 |
dominickim
New User
Joined: 28 Feb 2007 Posts: 65 Location: NS, CA
|
|
|
|
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 |
|
 |
|
|