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

Question about '+' and '-' in cobol


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

New User


Joined: 04 Oct 2007
Posts: 49
Location: Mumbai

PostPosted: Thu Sep 08, 2011 10:24 am
Reply with quote

Hi,

Can anyone please suggest a better way to implement the below logic?

01 W03-Table
03 FILLER PIC X(13) 'FULL...+0.180'.

01 W03-Table-R REDEFINES W03-Table.
03 W03-TABLE-ENTRY OCCURS 5 TIMES INDEXED BY W03-INDEX.
05 W03-DED PIC X(6).
05 FILLER PIC X.
05 W03-FCTR PIC S9V999.

I want the value of +0.180 in the variable W03-FCTR. But when i put display statements i am getting an Illegal value in the variable W03-FCTR.
Should this work?
I am aware that if we declare '+' sign explicitly, then it is a special character, so i cannot store +0.180 in S9V999.

Do i need to seperate the declaration OF SIGN as below:
01 W03-Table-R REDEFINES W03-Table.
03 W03-TABLE-ENTRY OCCURS 5 TIMES INDEXED BY W03-INDEX.
05 W03-DED PIC X(6).
05 FILLER PIC X.
05 W03-SIGN PIC X.
05 W03-FCTR PIC 9V999.

Please suggest.

Thanks.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Sep 08, 2011 10:50 am
Reply with quote

if you want the value +0.180 to be in a PIC S9V999 field, use the value clause with the proper usage clause.

pic x and pic PIC 9V999 store data differently.

pic x will store the data as +0.180 / 6 bytes
whereas
pic s9v999 will store the data as x'f0f9f9c9' / 4 bytes
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Sep 08, 2011 11:05 am
Reply with quote

sorry
this
pic s9v999 will store the data as x'f0f9f9c9' / 4 bytes
should have been
pic s9v999 will store the data as x'F0F1F8C0' / 4 bytes
Back to top
View user's profile Send private message
chhabraravneet

New User


Joined: 04 Oct 2007
Posts: 49
Location: Mumbai

PostPosted: Thu Sep 08, 2011 12:36 pm
Reply with quote

Thanks a lot for your promt response.

It worked.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Sep 08, 2011 1:31 pm
Reply with quote

You had a clue from your redefines. The field being redefined was two bytes longer. The S and the V take up no (extra) storage. The V no storage at all, the Compiler just needs it for lining-up for moves/calculations/tests, the S takes up a half-byte which is already being used for a sign, a value (F) to indicate that it is unsigned.

If you want to be able to use the number, search the forum for use of function NUMVAL, or have a look at de-editing in a post by Bill O'Boyle in the forum.
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 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
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top