View previous topic :: View next topic
|
Author |
Message |
yramakrishnan
New User
Joined: 07 Jun 2023 Posts: 2 Location: Chennai, IN
|
|
|
|
Greetings !
I am trying to move a COMP3 field S9(11)v9(7) COMP-3 to a CHAR field via a Edited PIC field -(11)9.9(7).
COMP-FIELD PIC S9(11)v9(7) COMP-3.
ED-PIC-FIELD PIC -(11)9.9(7).
COMP-FIELD value is +00000000007.3000000
MOVE COMP-FIELD TO ED-PIC-FIELD.
My Expectation is that the ED-PIC-FIELD gets the same value, however it's receiving as 0.000007.
The remaining values are truncated. I shamelessly copied this code from another program where this happens as expected, but in my new program it gives different result, which i can't understand why.
Any help appreciated. Thanks in advance. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2127 Location: USA
|
|
|
|
In your ED-PIC-FIELD definition you must specify the position where the fractional portion begins. Character V is used to do this, exactly as in your COMP-FIELD. By default this position is after the last character 9.
The dot in the middle of your ED-PIC-FIELD definition is printed as is, whatever numeric value is assigned.
Code: |
COMP-FIELD value is
+00000000007.3000000
ED-PIC-FIELD value is +00000000000.0000007 |
MUST BE MOVED TO THE BEGINNER'S SECTION.
For the people who cannot read basic manuals. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2127 Location: USA
|
|
|
|
Code: |
COMP-FIELD value is
+00000000007.3000000
ED-PIC-FIELD PIC +9(11).9(7) value is +00000000000.0000007
ED-PIC-FIELD PIC +9(11)V9(7) value is +000000000073000000
ED-PIC-FIELD PIC +9(11)V.9(7) value is +00000000007.3000000
|
You MUST try various PIC definitions to become familiar with your job duties. Otherwise people from internet forums are condemned to do your further tasks! |
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
looks suspicious
Code: |
ED-PIC-FIELD PIC -(11)9.9(7). |
try
Code: |
ED-PIC-FIELD PIC -9(11).9(7). |
|
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2127 Location: USA
|
|
|
|
dneufarth wrote: |
looks suspicious
Code: |
ED-PIC-FIELD PIC -(11)9.9(7). |
try
Code: |
ED-PIC-FIELD PIC -9(11).9(7). |
|
Both versions will eliminate the fractional part of the original value.
Code: |
PIC '-----------9.9999999'
ED-PIC-FIELD PIC -(11)9.9(7) ==> ' 0.0000007'
ED-PIC-FIELD PIC -9(11).9(7) ==> ' 00000000000.0000007'
PIC '-99999999999.9999999'
|
|
|
Back to top |
|
|
yramakrishnan
New User
Joined: 07 Jun 2023 Posts: 2 Location: Chennai, IN
|
|
|
|
sergeyken wrote: |
Code: |
COMP-FIELD value is
+00000000007.3000000
ED-PIC-FIELD PIC +9(11).9(7) value is +00000000000.0000007
ED-PIC-FIELD PIC +9(11)V9(7) value is +000000000073000000
ED-PIC-FIELD PIC +9(11)V.9(7) value is +00000000007.3000000
|
You MUST try various PIC definitions to become familiar with your job duties. Otherwise people from internet forums are condemned to do your further tasks! |
You are the man. Thank you. +9(11)V9(7) worked for my need.
Reg trying out various PIC definitions, i agree. I did try a few, but didn't realize the Edit pic needs a 'V' as well. Thanks for the help. |
|
Back to top |
|
|
|