Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
How to check for spaces in a Cobol program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
iknow

Senior Member


Joined: 22 Aug 2005
Posts: 582
Location: Colarado, US

PostPosted: Thu Oct 13, 2005 8:14 am    Post subject: How to check for spaces in a Cobol program
Reply with quote

Hi All
I want the program to follow a certain path if the value of a
variable is spaces. How do I code this logic.
Back to top
View user's profile Send private message
References
Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 107
Location: Concord, New Hampshire, USA.

PostPosted: Thu Oct 13, 2005 9:01 am    Post subject:
Reply with quote

Hi,
Try this...
Code:
WORKING STORAGE SECTION.
77 A PIC X(5).
77 B PIC X(5) VALUE SPACES.
PROCEDURE DIVISION.
IF A = B THEN DISPLAY "A IS NOT POPULATED" ELSE DISPLAY "A IS POPULATED".
There might be a more efficient way.
Regards,
Sridevi.
Back to top
View user's profile Send private message
umeshkmrsh

Active User


Joined: 21 Sep 2005
Posts: 81
Location: India

PostPosted: Thu Oct 13, 2005 12:21 pm    Post subject:
Reply with quote

Yes there is a better way too.

Code:
WORKING STORAGE SECTION.
77 A PIC X(5).
PROCEDURE DIVISION.
IF A = SPACES THEN
DISPLAY "A IS NOT POPULATED"
ELSE
DISPLAY "A IS POPULATED"
END-IF.
Back to top
View user's profile Send private message
mathiprakash

New User


Joined: 29 Apr 2005
Posts: 15
Location: Pune, India.

PostPosted: Thu Oct 13, 2005 12:31 pm    Post subject:
Reply with quote

Hi Iknow,

You are going to check whether the variable is having spaces or not, right?
Then why cann't you use this,

IF <variable> IS SPACES

This is a better option to check.

Regards,
Matty
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1