View previous topic :: View next topic
|
Author |
Message |
ravi.veda
New User
Joined: 30 Mar 2007 Posts: 7 Location: banglore
|
|
|
|
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 |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 631 Location: Wisconsin
|
|
|
|
You need to switch to display format
01 Amount PIC -9(12).99. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ravi.veda
New User
Joined: 30 Mar 2007 Posts: 7 Location: banglore
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ravi.veda
New User
Joined: 30 Mar 2007 Posts: 7 Location: banglore
|
|
|
|
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.
Really Thank You all |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome, good luck |
|
Back to top |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
Have you tried
input s9(12)v99 sign is leading
output s9(12)v99 sign is trailing
move input to output |
|
Back to top |
|
|
annujp
New User
Joined: 31 Aug 2005 Posts: 39 Location: St Paul,MN
|
|
|
|
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 |
|
|
jmreddymca Warnings : 1 New User
Joined: 14 Oct 2007 Posts: 29 Location: Bangalore
|
|
|
|
yes Anitha you are right , we can do the way you suggested |
|
Back to top |
|
|
HARLEEN SINGH MANN Warnings : 2 New User
Joined: 03 Aug 2007 Posts: 17 Location: Pune
|
|
|
|
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 |
|
|
|