Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Missing Negative sign in COBOL

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 85
Location: brisbane

PostPosted: Sat Sep 26, 2020 11:32 am    Post subject: Missing Negative sign in COBOL
Reply with quote

i've got the following code fragment:

Code:

01 WS-NUMFMT    PIC Z(12)9.99- BLANK WHEN ZERO.
01 MNTH_ONG_LIAB_AMT    PIC X(11) JUSTIFIED.
...
 
MOVE 12345.67 TO WS-NUMFMT
MOVE WS-NUMFMT TO MNTH_ONG_LIAB_AMT


this produces the correct result : "12345.67-"

however, with the definition :

01 WS-NUMFMT PIC -Z(12)9.99 BLANK WHEN ZERO.

... I lose the sign, and get only "12345.67"

any help appreciated !
Back to top
View user's profile Send private message

Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1012
Location: Richmond, Virginia

PostPosted: Tue Sep 29, 2020 7:07 pm    Post subject:
Reply with quote

How can moving a positive value to WS-NUMFMT produce a "correct" (as you say) negative result?

I would expect the "-" in the edit mask to be replaced with a blank since your value is positive.

You need to show results as produced, not just say what they are.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8567
Location: Dubuque, Iowa, USA

PostPosted: Tue Sep 29, 2020 7:24 pm    Post subject: Reply to: Missing Negative sign in COBOL
Reply with quote

I think at a minimum you have a typo; at the maximum you are lying. Code:
Code:
000800  WORKING-STORAGE SECTION.                                       
000900  01  WS-VARS.                                                   
001000      05  WS-NUMVAR1              PIC Z(12)9.99- BLANK WHEN ZERO.
001100      05  WS-NUMVAR2              PIC -Z(12)9.99 BLANK WHEN ZERO.
001200  PROCEDURE DIVISION.                                             
001300      MOVE 12345.67               TO  WS-NUMVAR1                 
001400                                      WS-NUMVAR2.                 
001500      DISPLAY 'NUMVAR1 >' WS-NUMVAR1 '<'.                         
001600      DISPLAY 'NUMVAR2 >' WS-NUMVAR2 '<'.                         
001700      DISPLAY ' ' .                                               
001800      MOVE -12345.67              TO  WS-NUMVAR1                 
001900                                      WS-NUMVAR2.                 
002000      DISPLAY 'NUMVAR1 >' WS-NUMVAR1 '<'.                         
002100      DISPLAY 'NUMVAR2 >' WS-NUMVAR2 '<'.                         
produces results of
Code:
NUMVAR1 >        12345.67 < 
NUMVAR2 >         12345.67< 
                             
NUMVAR1 >        12345.67-< 
NUMVAR2 >-        12345.67< 
These results are precisely as expected -- and completely contradict what you posted. Hence my earlier statement that you have typo(s) or are lying.
Back to top
View user's profile Send private message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 85
Location: brisbane

PostPosted: Thu Oct 01, 2020 4:39 pm    Post subject:
Reply with quote

there was an obvious typo in the original post; but equally true you didn't read the post.

error on my part was not using a floating sign. The definition should have been:

01 WS-NUMFMT PIC -(12)9.99 BLANK WHEN ZERO.


The 'lying' suggestion both unprofessional and unbecoming of a 'moderator'
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 865
Location: Maryland

PostPosted: Thu Oct 01, 2020 7:12 pm    Post subject:
Reply with quote

jzhardy wrote:
there was an obvious typo in the original post; but equally true you didn't read the post.

error on my part was not using a floating sign. The definition should have been:

01 WS-NUMFMT PIC -(12)9.99 BLANK WHEN ZERO.


The 'lying' suggestion both unprofessional and unbecoming of a 'moderator'

I recommend you either to RTFM, or move your questions to the Beginners Forum.
No way to discuss in your manner here.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1012
Location: Richmond, Virginia

PostPosted: Thu Oct 01, 2020 7:23 pm    Post subject:
Reply with quote

I stand by my reply.

You still moved an unsigned number to WS-NUMFMT, and you have not replied to that.

Your post: MOVE 12345.67 TO WS-NUMFMT
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8567
Location: Dubuque, Iowa, USA

PostPosted: Thu Oct 01, 2020 8:28 pm    Post subject:
Reply with quote

You CANNOT, under any circumstances, get the value 12345.67- when you move 12345.67 to your WS-NUMFMT variable. I showed this in my code post. So when you tell us you got certain results, and it has been proved beyond any doubt that you CANNOT get those results with what you posted, what conclusion should we draw? Furthermore, I did NOT accuse you of lying -- what I said was that you either have a typo or you were lying.

Start posting on Beginners and Students Forum as it is much more suited for your skill set. It doesn't matter how many "years" of experience you claim, you are a beginner.

Topic locked to prevent further waste of time.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    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 XML Parsing in COBOL creating "h... elixir1986 COBOL Programming 0 Sat Oct 31, 2020 7:19 am
No new posts Calling Rexx program from Cobol Srinivas B CLIST & REXX 12 Thu Oct 29, 2020 6:00 pm
No new posts COBOL reading from SYSIN jzhardy COBOL Programming 1 Mon Sep 21, 2020 2:37 pm
No new posts how to read accounting information in... jzhardy COBOL Programming 1 Mon Sep 21, 2020 9:57 am
No new posts CA7 Negative dependency JOB=/ Dave Hinds CA Products 0 Thu Sep 10, 2020 7:36 pm

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