Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Changing sign from left to right

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Changing sign from left to right
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: 632
Location: Wisconsin

PostPosted: Sat Oct 06, 2007 8:11 pm    Post subject:
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

Site Director


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

PostPosted: Sat Oct 06, 2007 10:04 pm    Post subject:
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    Post subject:
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: 1224
Location: Israel

PostPosted: Mon Oct 08, 2007 9:13 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Oct 09, 2007 2:29 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Oct 10, 2007 1:17 am    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: yes
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    Post subject: Re: Changing sign from left to right
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    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 Coverting PD to FS and also left just... Atul Banke DFSORT/ICETOOL 6 Wed Aug 24, 2016 4:31 pm
No new posts changing z/os unicode conversion service meykh2014 All Other Mainframe Topics 0 Tue Jul 12, 2016 10:49 am
No new posts Problems in File-Aid / DB2 Spufi whil... amitc23 CLIST & REXX 6 Fri Feb 12, 2016 1:59 pm
No new posts Zero suppress and shift left Bryant Shearin DFSORT/ICETOOL 10 Sat Oct 31, 2015 9:28 pm
No new posts Changing UID dynamically in ACF2 newroad CA Products 2 Sat Oct 31, 2015 1:17 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us