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
 

 

Convert a Numeric-Edited value to Numeric value

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

New User


Joined: 03 Oct 2008
Posts: 43
Location: Chennai,India.

PostPosted: Wed Apr 29, 2009 7:09 pm    Post subject: Convert a Numeric-Edited value to Numeric value
Reply with quote

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
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Apr 29, 2009 7:12 pm    Post subject:
Reply with quote

look at NUMVAL - it is a COBOL instruction.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Wed Apr 29, 2009 7:32 pm    Post subject:
Reply with quote

Depending on your version of COBOL you could just use a MOVE.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Wed Apr 29, 2009 7:40 pm    Post subject:
Reply with quote

Which version of COBOL? What have you tried and what results have you gotten?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Wed Apr 29, 2009 8:11 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Thu Apr 30, 2009 10:57 pm    Post subject:
Reply with quote

So Enterprise COBOL can now do automatic "de-editing"? Amazing!
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: Fri May 01, 2009 12:42 am    Post subject:
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri May 01, 2009 2:36 am    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri May 01, 2009 3:20 am    Post subject:
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri May 01, 2009 5:59 am    Post subject:
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun May 03, 2009 8:21 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 05, 2009 2:35 am    Post subject:
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue May 05, 2009 3:00 am    Post subject: Reply to: Convert a Numeric-Edited value to Numeric value
Reply with quote

Terry,

I had also pointed out this concept back in late July 2008, but I couldn't recall whether it was introduced with VS/COBOL II, Version 3 or COBOL/370.

http://ibmmainframes.com/viewtopic.php?p=145037&highlight=#145037

Regards.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 05, 2009 4:46 am    Post subject:
Reply with quote

How embarrasing. I even responded during that thread. icon_redface.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue May 05, 2009 5:45 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 05, 2009 10:36 pm    Post subject:
Reply with quote

Sorry, the manual I have is a hard copy acquired in the late 80s.
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 May 05, 2009 11:31 pm    Post subject:
Reply with quote

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
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 How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am
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