Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Diff bw SPACE and SPACES (figurative constants)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Tue Dec 19, 2006 5:11 pm    Post subject: Diff bw SPACE and SPACES (figurative constants)
Reply with quote

Hi,
Could anyone explain the difference between SPACE and SPACES (figurative constants) COBOL reserved words?

Regards,
Mohan
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Tue Dec 19, 2006 5:18 pm    Post subject:
Reply with quote

Hi Mohan

I think SPACE is for one space & SPACES is for more spaces .
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Dec 19, 2006 5:23 pm    Post subject:
Reply with quote

There is no difference, they both produce the same result. Grammatically speaking, the singular sounds better when used as one while the plural sounds better when used as many.
Back to top
View user's profile Send private message
jcbhimani

New User


Joined: 30 Nov 2006
Posts: 12
Location: Ahmedabad

PostPosted: Tue Dec 19, 2006 11:28 pm    Post subject:
Reply with quote

SPACE represents one blank while SPACES represents more then one blank. Same as ZERO represents one zero while ZEROS or ZEROES represents more then one zero.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Dec 19, 2006 11:58 pm    Post subject:
Reply with quote

num pic 9999
move zero to num
what is in num?

char pic xxxx
move zero to char
what is in char?
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Dec 20, 2006 12:01 am    Post subject: Re: Diff bet space & spaces in COBOL
Reply with quote

As William said, There is no difference in function. SPACE, SPACES and ZERO, ZEROS. The only difference is readability.

Code:

WORKING-STORAGE SECTION.                                       
                                                               
01  CHARSTR1 PIC X(20).                                         
01  CHARSTR2 PIC X(20).                                         
01  DECIMAL1 PIC 9(10).                                         
01  DECIMAL2 PIC 9(10).                                         
                                                               
PROCEDURE DIVISION.                                             
PROGRAM-START.                                                 
                                                               
    DISPLAY 'CHARSTR1 >' CHARSTR1 '< CHARSTR2 >' CHARSTR2 '<'   
    DISPLAY 'DECIMAL1 >' DECIMAL1 '< DECIMAL2 >' DECIMAL2 '<'   
                                                               
    MOVE SPACE TO CHARSTR1.                                     
    MOVE SPACES TO CHARSTR2.                                   
    MOVE ZERO TO DECIMAL1.                                     
    MOVE ZEROS TO DECIMAL2.                                     
                                                               
    DISPLAY 'CHARSTR1 >' CHARSTR1 '< CHARSTR2 >' CHARSTR2 '<'   
    DISPLAY 'DECIMAL1 >' DECIMAL1 '< DECIMAL2 >' DECIMAL2 '<'   


result

Code:

.SARPAGE 4                                                                   
.                                                                           
.CHARSTR1 >....................< CHARSTR2 >....................<             
.DECIMAL1 >..........< DECIMAL2 >..........<                                 
.CHARSTR1 >                    < CHARSTR2 >                    <             
.DECIMAL1 >0000000000< DECIMAL2 >0000000000<                                 
******************************** BOTTOM OF DATA *****************************


As you can see, SPACE and SPACES, ZERO and ZEROS produce the same data.

Dave
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Wed Dec 20, 2006 8:28 am    Post subject:
Reply with quote

Thanks all for the quick response.

In one of the program Im working upon (for small enhancement), I have group variable as follows -

01 group-var. (pic of all other level is x)
05 sub-var1 pic x(9).
05 sub-var2 pic x(3).
.
.
.
05 sub-var12 pic x(242).


And also I have statement MOVE SPACE TO GROUP-VAR in procedure division. But found spaces was not moved (i.e., found earlier data in the variable).

So, just got a doubt regarding SPACE and SPACES functioning.

Regards,
Mohan
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Dec 20, 2006 9:52 am    Post subject:
Reply with quote

Hi Mohan,


May be after moving spaces u r passing some value in the variable Thats why it is showing some value other than spaces
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Dec 20, 2006 10:53 pm    Post subject:
Reply with quote

Hello,

From one of the COBOL manuals. . .

Quote:

SPACE, SPACES
Represents one or more blanks or spaces. SPACE is treated as an alphanumeric literal when used in a context that requires an alphanumeric character, as a DBCS literal when used in a context that requires a DBCS character, and as a national literal when used in a context that requires a national character. The EBCDIC DBCS space character has the value X?4040?, and the national space character has the value NX?0020?.


From that, one might read that SPACE will only do one.

Put the following into a pgm:

and the following was the result:
Code:

*                                             
 01  SPACEMOVETEST.                           
     05 SMT1   PIC XXX VALUE 'ABC'.           
     05 SMT2   PIC XXX VALUE '123'.           

     DISPLAY 'ORIGINAL   ' SPACEMOVETEST.     
     MOVE SPACE TO SPACEMOVETEST.             
     DISPLAY 'AFTER MOVE ' SPACEMOVETEST.     
     DISPLAY ' '.                             



Code:

ORIGINAL      ABC123
AFTER MOVE       


When i did a preview, the PIC X(3) showed as TTT - is this an undocumented feature of the "reply editor"? Seems like tripleX is converted to TTT. XX and XXXX don't get converted. Must be the auto-censor at work. . . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts VSAM Space Allocation mrgnndhmk JCL & VSAM 7 Sat Apr 22, 2017 12:42 am
This topic is locked: you cannot edit posts or make replies. Need help in estimating space of unlo... ashek15 IMS DB/DC 12 Fri Apr 07, 2017 5:11 am
No new posts Need inputs on Space requirement and... ashek15 IMS DB/DC 0 Sat Apr 01, 2017 8:26 am
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us