IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

validating 3rd and 4th position character of 10 digits numbe


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rcreddy

New User


Joined: 23 Nov 2007
Posts: 4
Location: hyderabad

PostPosted: Fri Nov 23, 2007 7:14 pm
Reply with quote

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
View user's profile Send private message
sameer

New User


Joined: 10 Mar 2005
Posts: 41
Location: United States Of America

PostPosted: Fri Nov 23, 2007 7:35 pm
Reply with quote

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
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Nov 23, 2007 7:38 pm
Reply with quote

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
View user's profile Send private message
rcreddy

New User


Joined: 23 Nov 2007
Posts: 4
Location: hyderabad

PostPosted: Fri Nov 23, 2007 7:42 pm
Reply with quote

thanks for ur reply..let me try and will come back to u.
Back to top
View user's profile Send private message
rcreddy

New User


Joined: 23 Nov 2007
Posts: 4
Location: hyderabad

PostPosted: Fri Nov 30, 2007 5:30 pm
Reply with quote

I have tested it ..it is working..
Thanks for ur suggestion.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts Want to mask Middle 8 Digits of Debit... COBOL Programming 3
Search our Forums:

Back to Top