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
 

 

Converting an edited picture clause value to signed numeric

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
annujp

New User


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

PostPosted: Wed Nov 07, 2007 3:06 am    Post subject: Converting an edited picture clause value to signed numeric
Reply with quote

I have a field that is defined as

Code:
10 WS-A          PIC ZZ,ZZZ,ZZZ.99-


I want to extract the numerical value of this variable and put it in a field

Code:
10 WS-B          PIC S9(8)V99


Could you please tell me how i can move the numeric value of the edited picture clause value to this signed variable?
Thanks in advance
Anitha

P.S. I searched the forum for something similar but i could not find anything.
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 Nov 07, 2007 3:30 am    Post subject:
Reply with quote

Hello,

How did the value get into ws-a? You might move the value to some other field (or even ws-b) at the same time it is moved to ws-a.

If the edited value comes from some input file, i've often set up a work field that has something like:
Code:
01  ws-wkfld.
    05 ws-dlrs  pic 9(8).
    05 filler   pic x.
    05 ws-cnts  pic 99.
I then redefine ws-a as a pic x(11) field and move the redefinition to the work field. In the work field, i eliminate the leading spaces then compute the value of ws-b. Keep in mind that you need to "scale" the dollars one way or another.

It is ugly, but has always worked icon_smile.gif
Back to top
View user's profile Send private message
skkp2006

New User


Joined: 14 Jul 2006
Posts: 93
Location: Chennai,India

PostPosted: Wed Nov 07, 2007 10:29 am    Post subject: Reply to: Converting an edited picture clause value to signe
Reply with quote

Have u tried NUMVAL function. I am not sure whether it works or not. Give it a try.

http://publib.boulder.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=/com.ibm.entcobol3.doc/tpstr19.htm
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 07, 2007 9:01 pm    Post subject:
Reply with quote

Hi Anitha,

If you're using COBOLII (I think) or later, just move ws-a to ws-b.
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 Nov 07, 2007 9:43 pm    Post subject: Reply to: Converting an edited picture clause value to signe
Reply with quote

Hello,

Yup, just tried this with Enterprise COBOL and it works just fine.

Thanx, Jack icon_smile.gif

d
Back to top
View user's profile Send private message
annujp

New User


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

PostPosted: Thu Nov 08, 2007 1:02 am    Post subject:
Reply with quote

Thanks Dick.
I did just what you said. I moved the variable into a gp variable to separate out the ',' and the '.'. Then used the parts of the dollar and cent amount to calculate the correct value. Based on the sign in the input, i multiplied the computed value by '-1' to generate a negative sign.

Thanks for your help.
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: Thu Nov 08, 2007 2:23 am    Post subject: Reply to: Converting an edited picture clause value to signe
Reply with quote

You're welcome icon_smile.gif

While i've used the method i posted for a long, long time (way before the "simple move" way was implemented), i really like the wha t Jack posted better.

I need to do some testing on what happens if the data is not numeric (due to some problem) and if a "not numeric" compare would catch all errors.

Good to hear your requirement has been met icon_cool.gif

d
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Nov 12, 2007 12:20 am    Post subject:
Reply with quote

Sorry Dick, you're wlecome. I just now saw your "Thanx". Another Sr. moment. I'm losing count. icon_smile.gif

BTW, your caution is well noted. I only use it when I'm sure the field was created by a COBOL pgm.
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: Mon Nov 12, 2007 3:44 am    Post subject: Reply to: Converting an edited picture clause value to signe
Reply with quote

Quote:
Another Sr. moment. I'm losing count
Yup, i resemble that icon_smile.gif

d
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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