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

Doubt on EBCDIC format of data....


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

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Thu Oct 27, 2011 7:51 am
Reply with quote

In cobol, if I define a variable as below:

Code:
01  PIC  S9(13)V9(2) COMP-3.


and I move data to it in subsequent step:
Code:

move 12345 to A.

the value of A displays as below:

Code:

----+---
----+---
----+---
 -------
......&.
00001350
0000240C


and then, when I
Code:

move 123.45 to A

the value of A displays as below:
Code:

----+---
----+---
----+---
 -------
.......*
00000135
0000024C
 -------
********


My question is, how do I know the value stored in the output D/S is 12345 or 123.45, provided I do not know the definition in cobol program?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Oct 27, 2011 8:30 am
Reply with quote

If the receiving field were display, you'd see -

X'F1F2F3F4F5' (CL5'12345')

If it were a binary-fullword (4-bytes), you'd see -

X'00003039' (also expressed in decimal as F'12345')

And finally (as you've posted) signed packed decimal -

X'12345C' (only 3-bytes shown). Also expressed as PL3'12345'.

Only masked-fields, such as PIC ZZZ,ZZZ.99 have an explicit decimal point. All others have an implicit decimal point.

So, without a field definition, you would not know if a field has an implicit decimal point.

Mr. Bill
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Oct 27, 2011 8:31 am
Reply with quote

Quote:
how do I know the value stored in the output D/S is 12345 or 123.45, provided I do not know the definition in cobol program?


You will never know! amen
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Oct 27, 2011 9:57 am
Reply with quote

Quote:
My question is, how do I know the value stored in the output D/S is 12345 or 123.45, provided I do not know the definition in cobol program?
The V in the PICTURE clause is an IMPLIED decimal point -- meaning it does not really exist, but that COBOL uses that spot for decimal alignment. If you cannot see the COBOL definition, you cannot know where the implied decimal point is (if there is one at all).
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Thu Oct 27, 2011 10:08 am
Reply with quote

I fullly understood this, thank you, experts!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Oct 27, 2011 10:10 am
Reply with quote

follow on ...
Quote:
Doubt on EBCDIC format of data....


the title of the question is also wrong ...
the data stored <in> the computer is not <in se> EBCDIC, ASCII, KLINGON, ...
is just a sequence of bits which is interpreted according to some convention
anyway PACKED data is NOT an EBCDIC <thing>
see the POP here
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DZ9ZR003/CCONTENTS?SHELF=DZ9ZBK03&DN=SA22-7832-03&DT=20040504121320

the same concept (virtual/implied decimal point) applies also to BINARY data
You will never know until You see the program dealing with it (COBOL,ASSEMBLER,PL/I,KLINGONESE)
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 Store the data for fixed length COBOL Programming 1
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top