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.
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.
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 ****************************
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.