Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Question about '+' and '-' in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Question about '+' and '-' in cobol
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: 6968
Location: porcelain throne

PostPosted: Thu Sep 08, 2011 10:50 am    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Thu Sep 08, 2011 11:05 am    Post subject:
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    Post subject: Reply to: Question about '+' and '-' in cobol
Reply with quote

Thanks a lot for your promt response.

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Sep 08, 2011 1:31 pm    Post subject: Reply to: Question about '+' and '-' in cobol
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    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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts question about dfsms management clas... Hervey Martinez IBM Tools 0 Tue Oct 10, 2017 6:19 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us