View previous topic :: View next topic
|
Author |
Message |
Raghuraman_New
New User
Joined: 03 Oct 2008 Posts: 43 Location: Chennai,India.
|
|
|
|
Hi
Need to convert a Numeric_edited value to numeric value
EX.
A pic --,---,---,---,---,--9.99.
B pic S9(16)V9(2).
Need to move A to B.
Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
look at NUMVAL - it is a COBOL instruction. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Depending on your version of COBOL you could just use a MOVE. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Which version of COBOL? What have you tried and what results have you gotten? |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Robert Sample wrote: |
Which version of COBOL? What have you tried and what results have you gotten? |
Code: |
PP 5655-G53 IBM Enterprise COBOL for z/OS 3.4.1
77 WS-NUMERIC PIC S9(16)V9(2) VALUE ZERO.
77 WS-NUMERIC2 PIC S9(16)V9(2) VALUE ZERO.
77 WS-NUMERIC-EDITTED PIC --,---,---,---,---,--9.99.
MOVE 123456789.12 TO WS-NUMERIC.
MOVE WS-NUMERIC TO WS-NUMERIC-EDITTED.
MOVE WS-NUMERIC-EDITTED TO WS-NUMERIC2.
DISPLAY 'WS-NUMERIC ' WS-NUMERIC.
DISPLAY 'WS-NUMERIC-EDITTED ' WS-NUMERIC-EDITTED.
DISPLAY 'WS-NUMERIC2 ' WS-NUMERIC2.
MOVE -9876543.22 TO WS-NUMERIC.
MOVE WS-NUMERIC TO WS-NUMERIC-EDITTED.
MOVE WS-NUMERIC-EDITTED TO WS-NUMERIC2.
DISPLAY 'WS-NUMERIC ' WS-NUMERIC.
DISPLAY 'WS-NUMERIC-EDITTED ' WS-NUMERIC-EDITTED.
DISPLAY 'WS-NUMERIC2 ' WS-NUMERIC2. |
The results
Code: |
WS-NUMERIC 00000001234567891B
WS-NUMERIC-EDITTED 123,456,789.12
WS-NUMERIC2 00000001234567891B
WS-NUMERIC 00000000098765432K
WS-NUMERIC-EDITTED -9,876,543.22
WS-NUMERIC2 00000000098765432K |
|
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
So Enterprise COBOL can now do automatic "de-editing"? Amazing! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I'd suggest only using this when the same program created the "edited" value in the field (rather than if this edited value came from some external input). . .
NUMVAL and NUMVAL-C work quite nicely with variably formatted, edited data from some trusted external source. If the input is from some direct user screen input or some kind of "heads-down" data entry, the data needs to be validated before any movement is attempted. . .
fwiw. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Terry Heinze wrote: |
So Enterprise COBOL can now do automatic "de-editing"? Amazing! |
Yes, just used this some days back and it worked nicely. I believe, if you're using COBOLII or later, just move ws-a to ws-b. Mine is Enterprise COBOL. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
No, COBOL II requires the NUMVAL.
My personal opinion:
I believe that Enterprise COBOL, in addition to the multi-thread capability that it now offers - or Object Oriented as the phrase goes,
COBOL 3 was written for coders that do not have the bits&bytes - near assembler background - that many of us 'legacy programmers' (read: dinosauers) have. Like Java or C, if you manage to define the data properly, you can have 'generic' commands (MOVE in this case) that will tailor the extended code based on the attributes of the defined data.
Confusing the newbees with extra (or special) instructions, such as NUMVAL, was something to be avoided.
End personal opinion: |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
dbzTHEdinosauer wrote: |
Confusing the newbees with extra (or special) instructions, such as NUMVAL, was something to be avoided. |
No! I disagree, tools have a purpose, and properly used, are of value.
The move of an edited numeric is well documented but crap coming from the "user" does need editing...and NUMVAL and the NUMVALC are very handy....
Heck, when the macro de-edit got downsized, I wrote my own. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Quote: |
If it works for MOVE, I wonder if it will work for ADD or COMPUTE.... |
Numeric edited fields can only be used as receiving fields in arith stmts (e.g COMPUTE NUM-ED = A * B).
You'll have to move the N/E field 1st to a numeric field, before executing the arith stmt.
Update - It looks like the orig poster deleted the quoted remarks, but the point is still valid. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Out of curiosity, I checked an old (VS COBOL II) manual and apparently this de-editing MOVE has been valid since at least Rel. 3.2. That is, moving a numeric-edited field to a numeric field. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
How embarrasing. I even responded during that thread. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Terry Heinze wrote: |
I checked an old (VS COBOL II) manual and apparently this de-editing MOVE has been valid since at least Rel. 3.2. That is, moving a numeric-edited field to a numeric field. |
ah... I was having sleepless nights in search of "that" Manual . . . can you please point me to the URL?
Regards,
Anuj |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Sorry, the manual I have is a hard copy acquired in the late 80s. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
VS COBOL II is available via the "IBM Manuals" link at the top of the page.
And from that manual:
Quote: |
° De-editing allows moving a numeric-edited data item into a numeric or
numeric-edited receiver. The compiler accomplishes this by first
establishing the unedited value of the numeric-edited item (this value
can be signed), then moving the unedited numeric value to the
receiving numeric or numeric-edited data item.
|
|
|
Back to top |
|
|
|