View previous topic :: View next topic
|
Author |
Message |
chhabraravneet
New User
Joined: 04 Oct 2007 Posts: 49 Location: Mumbai
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
chhabraravneet
New User
Joined: 04 Oct 2007 Posts: 49 Location: Mumbai
|
|
|
|
Thanks a lot for your promt response.
It worked. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|