How to check whether the Comp variable has Spaces or not .



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

How to check whether the Comp variable has Spaces or not .

Postby gauthamnagpur18 » Wed Nov 02, 2011 5:56 pm

Hi ,

How to check whether the Comp variable has Spaces or not .

i tried like this ,

IF Sample-ctr (SUB) = SPACES

but i got compilation error.

i have defined Sample-ctr as S9(4) comp .

Thanks in advance . :)

Thanks ,
Gautham
gauthamnagpur18
 
Posts: 93
Joined: Sat Oct 23, 2010 1:28 pm
Location: Chennai, India
Has thanked: 3 times
Been thanked: 3 times

Re: How to check whether the Comp variable has Spaces or no

Postby Robert Sample » Wed Nov 02, 2011 6:49 pm

You cannot check a COMP variable for spaces, period. This is because of the definition of a COMP variable -- EVERY POSSIBLE VALUE IS VALID FOR A COMP VARIABLE. If you have a PIC S9(04) COMP variable, and it has X'4040' in it -- the value is 4 times 4096 plus 4 times 16 or 16448. It may LOOK like spaces in a memory dump, but the value is actually 16448, because that's the way COMP variables work.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: How to check whether the Comp variable has Spaces or no

Postby dick scherrer » Thu Nov 03, 2011 10:43 am

Hello,

The code that creates the value should prevent having spaces in the comp field(s) - or any other numeric fields.

It sounds like some bad code was allowed to be implemented and now another bad method is being considered to deal with this. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to check whether the Comp variable has Spaces or no

Postby gauthamnagpur18 » Thu Nov 03, 2011 11:36 am

Thanks dick scherrer & Robert Sample !! :)
gauthamnagpur18
 
Posts: 93
Joined: Sat Oct 23, 2010 1:28 pm
Location: Chennai, India
Has thanked: 3 times
Been thanked: 3 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post