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

COBOL - Move S9(11)v9(7) COMP-3 to -(11)9.9(7)


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

New User


Joined: 07 Jun 2023
Posts: 2
Location: Chennai, IN

PostPosted: Wed Jun 07, 2023 8:46 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Wed Jun 07, 2023 5:35 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Wed Jun 07, 2023 6:11 pm
Reply with quote

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
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 419
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Wed Jun 07, 2023 6:19 pm
Reply with quote

looks suspicious
Code:
ED-PIC-FIELD PIC -(11)9.9(7).


try
Code:
ED-PIC-FIELD PIC -9(11).9(7).
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Wed Jun 07, 2023 6:30 pm
Reply with quote

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
View user's profile Send private message
yramakrishnan

New User


Joined: 07 Jun 2023
Posts: 2
Location: Chennai, IN

PostPosted: Wed Jun 07, 2023 7:41 pm
Reply with quote

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
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 2
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