View previous topic :: View next topic
|
Author |
Message |
rcreddy
New User
Joined: 23 Nov 2007 Posts: 4 Location: hyderabad
|
|
|
|
Hi,
This is regarding validation of 3rd and 4th position character.
Details:
I need to validate the 10 digits number.
3 and 4th positions should have "ALPHABETIC"
Example:
Number: 07AB123456
so i need to validate 3 and 4 position character.
plz suggest me how can do this. |
|
Back to top |
|
|
sameer
New User
Joined: 10 Mar 2005 Posts: 41 Location: United States Of America
|
|
|
|
rcreddy,
This will work.
WORKING-STORAGE SECTION.
01 WS-DATA VALUE '07AB123456'.
05 FILLER PIC X(2).
05 FIELD2 PIC X(2).
05 FILLER PIC X(6).
PROCEDURE DIVISION.
MAIN-PARA.
IF FIELD2 IS ALPHABETIC
DISPLAY '3RD & 4TH BYTES ARE ALPHABETIC'
ELSE
DISPLAY 'NOT ALPHABETIC'
END-IF.
STOP RUN.
Thanks,
Sameer
TCS |
|
Back to top |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
rcreddy,
I think your requirement is to validate the PIC X(10) variable in which 3rd and 4th positions should be "ALPHABETIC" and remaining positions should be "NUMERIC". If yes, please check with the following code for your requirement.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. A.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 WS PIC X(10) VALUE '07AB123456'.
PROCEDURE DIVISION.
IF WS(1:2) IS NUMERIC AND
WS(5:6) IS NUMERIC AND
WS(3:2) IS ALPHABETIC
DISPLAY 'OK'
ELSE
DISPLAY 'NOT OK'
END-IF
GOBACK. |
|
|
Back to top |
|
|
rcreddy
New User
Joined: 23 Nov 2007 Posts: 4 Location: hyderabad
|
|
|
|
thanks for ur reply..let me try and will come back to u. |
|
Back to top |
|
|
rcreddy
New User
Joined: 23 Nov 2007 Posts: 4 Location: hyderabad
|
|
|
|
I have tested it ..it is working..
Thanks for ur suggestion. |
|
Back to top |
|
|
|