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

Display all the number that have a ?2? in the centre


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

New User


Joined: 18 May 2005
Posts: 46
Location: Bangalore, INDIA

PostPosted: Thu Feb 02, 2006 12:39 pm
Reply with quote

I have a field s9(3) comp-3, values are linke 123, 345, 223, 222. I want to display all the number that have a ?2? in the centre. (remember it?s a comp-3 field)
Back to top
View user's profile Send private message
vikasc4

New User


Joined: 11 Dec 2005
Posts: 32

PostPosted: Thu Feb 02, 2006 1:04 pm
Reply with quote

Hi,
First move the comp-3 fields into a numeric field. Then with the help of refrence modification move the centre no. to another field.
Compare it with 2 and if equal then dispaly the no else not.

The code will be:
DATA ....
77 A PIC S9(3) COMP-3.
77 B PIC 9(3).
77 C PIC 9.
PROCEDURE DIVISION.

MOVE A TO B.
MOVE B(2:1) TO C.
IF C = 2
DISPLAY B
ELSE NEXT SENTANCE.


REGARDS
VIKAS
Back to top
View user's profile Send private message
hncs

New User


Joined: 01 Mar 2006
Posts: 11

PostPosted: Mon Mar 06, 2006 2:48 pm
Reply with quote

WORKING-STORAGE SECTION.

01 WS-I PIC 9(02) VALUE ZEROES.
01 A PIC S9(03) COMP-3 VALUE ZEROES.

PROCEDURE DIVISION.

DIVIDE A BY 10 GIVING A.
DIVIDE A BY 10 GIVING A REMAINDER WS-I.

IF WS-I = 2
DISPLAY 'FOUND******'
ELSE
DISPLAY 'NOT FOUND*******'
END-IF
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 Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top