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

Changing sign from left to right


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

New User


Joined: 30 Mar 2007
Posts: 7
Location: banglore

PostPosted: Sat Oct 06, 2007 6:30 pm
Reply with quote

01 AMOUNT S9(12)V99

AMOUNT is the variable, if it is positive fine. If it is negative, the sign will be store in the last i.e rightmost side.

ex: i/p '-12345.67'
the o/p should be '12345.67-'
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 631
Location: Wisconsin

PostPosted: Sat Oct 06, 2007 8:11 pm
Reply with quote

You need to switch to display format

01 Amount PIC -9(12).99.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Sat Oct 06, 2007 10:04 pm
Reply with quote

Hello,

I'd most likely use
01 OUTPUT-VALUE PIC Z(12).99- to suppress the leading zeros and place the minus at the right end.

This "01 AMOUNT S9(12)V99 " will not contain "i/p '-12345.67' ". The "AMOUNT" field can only contain numerics, not a "-". The value might be negative, but value will not contain a "-".
Back to top
View user's profile Send private message
ravi.veda

New User


Joined: 30 Mar 2007
Posts: 7
Location: banglore

PostPosted: Mon Oct 08, 2007 8:52 pm
Reply with quote

hi scherrer,
thank you,iam getting the output by using
01 OUTPUT-VALUE PIC Z(12).99-

Can you plz guide me wat's the wrong in given below.
i have variable1 with s9(12)v99 and variable2

if var1<0
move var1(1:1) to var2(16:1)
move var1(2:13) to var2(1:12)
move var1(15:2) to var2(14:2)

ex:var1=-666661234566.33
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Oct 08, 2007 9:13 pm
Reply with quote

PIC S9(12)V99 does not mean there is a sign in the leftmost character,
it means the number is signed. The sign is kept in the rightmost character.
So var1 contains: '6666612345663L' and you're just making a big mess with the number icon_wink.gif
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Oct 08, 2007 9:43 pm
Reply with quote

ravi.veda,

The size of a s9(12)v99 is 14 bytes not 16, the sign does not occupy a byte and the V implies a decimal point that does not exist. Have you considered looking in the COBOL manuals?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Oct 09, 2007 2:29 am
Reply with quote

Hello,

Quote:
if var1<0
move var1(1:1) to var2(16:1)
move var1(2:13) to var2(1:12)
move var1(15:2) to var2(14:2)

ex:var1=-666661234566.33
If you are going to use variables as signed numbers in some calculation, you will most likely not use reference modification to re-arrange the data.

If you more completely explain what you have and what you want to do with it, we can probably give better replies. I suspect there is more than what you have posted so far. What else needs to happen with the s(12)v99 field content?

Quote:
thank you,iam getting the output by using
01 OUTPUT-VALUE PIC Z(12).99-
Back to top
View user's profile Send private message
ravi.veda

New User


Joined: 30 Mar 2007
Posts: 7
Location: banglore

PostPosted: Tue Oct 09, 2007 9:59 pm
Reply with quote

Hischerrer,
y am asked is,before ur answer i think like that.so,i expressed my question and get clear clarification.
actually it is a part of my CR.


icon_sad.gif Really Thank You all icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Oct 10, 2007 1:17 am
Reply with quote

You're welcome, good luck icon_smile.gif
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Fri Oct 12, 2007 9:49 pm
Reply with quote

Have you tried

input s9(12)v99 sign is leading
output s9(12)v99 sign is trailing

move input to output
Back to top
View user's profile Send private message
annujp

New User


Joined: 31 Aug 2005
Posts: 39
Location: St Paul,MN

PostPosted: Tue Oct 16, 2007 3:50 am
Reply with quote

Just thought i wud try this out.
I declared these variables.

Code:
01  WS-A                        PIC S9(4)V99 VALUE ZEROS 
                                SIGN LEADING SEPARATE.   
01  WS-B                        PIC S9(4)V99 VALUE ZEROS 
                                SIGN TRAILING SEPARATE.   
01  WS-C                        PIC -9(4).99 VALUE ZEROS.
01  WS-D                        PIC 9(4).99- VALUE ZEROS.



I moved the variables to switch signs.

Code:
MOVE -1234.99              TO WS-A 
                              WS-C.
MOVE WS-A                  TO WS-B.
MOVE WS-C                  TO WS-D.


This was my result
Code:
WS-A -123499 
WS-B 123499- 
WS-C -1234.99
WS-D 1234.99-


Sign leading and sign trailing separate will occupy another byte for the sign. So S9(4)V99 SIGN LEADING SEPARATE will occupy 7 bytes, with the sign in the first byte.

Correct me if I am wrong.
Back to top
View user's profile Send private message
jmreddymca
Warnings : 1

New User


Joined: 14 Oct 2007
Posts: 29
Location: Bangalore

PostPosted: Wed Oct 17, 2007 5:38 pm
Reply with quote

yes Anitha you are right , we can do the way you suggested
Back to top
View user's profile Send private message
HARLEEN SINGH MANN
Warnings : 2

New User


Joined: 03 Aug 2007
Posts: 17
Location: Pune

PostPosted: Fri Oct 19, 2007 11:14 pm
Reply with quote

ravi.veda wrote:
01 AMOUNT S9(12)V99

AMOUNT is the variable, if it is positive fine. If it is negative, the sign will be store in the last i.e rightmost side.

ex: i/p '-12345.67'
the o/p should be '12345.67-'


There is one mistake the writere has made here, the -ve sign is not stored after 7 but in the same byte where 7 is. so the display wont be 12345.67- but 123456* (some char in place of *). This is due to the defined type of AMOUNT.
To achieve the op you require define it or move it into a
S9(12)V99 SIGN TRAILING SEPERATE.

Hope things are clearer now.

Regards.
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 Shift left VB record without x00 endi... DFSORT/ICETOOL 11
No new posts changing defaults in db2 admin - Unlo... DB2 0
No new posts Tilde Characters Changing to COLONs i... CLIST & REXX 22
No new posts Changing Data Type SYNCSORT 4
This topic is locked: you cannot edit posts or make replies. Missing Negative sign in COBOL COBOL Programming 6
Search our Forums:

Back to Top