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

Variable movement in COBOL


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

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Tue Jun 17, 2008 8:48 pm
Reply with quote

Hi All,
In a cobol program i declared 3 variables as follows,

05 WS-A PIC X(02) VALUE '12'.
05 WS-B PIC X(06) VALUE SPACES.
05 WS-C PIC 9(06) VALUE ZEROES.

AFTER THE BELOW OPERATION WHAT SHOULD BE THE VALUE IN EACH VARIABLES?

MOVE WS-A TO WS-B.
MOVE WS-B TO WS-C.

I got values as,
WS-A : 12
WS-B: '12 '(12 and 4 spaces)
WS-C:'12 0'(12,3 SPACES and one zero)

Any one explain to me Why i got this value in WS-C??
Regards,
Bipin Peter
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Jun 17, 2008 9:55 pm
Reply with quote

Hello,

Quote:
Why i got this value in WS-C??
Not to sound trite, but because that is the way it works. . . And it is not intuitive.

When you moved the x(6) to the 9(6), the "12" and the spaces were moved. When the value was "received" the system forced an "F" sign over the low order digit of the 9(6), creating an x'F0" (instead of the x'40' of the low-order space).
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top