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
 

 

Help with packed-decimal issue.

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

New User


Joined: 24 Sep 2008
Posts: 10
Location: Chennai

PostPosted: Thu Dec 11, 2008 7:59 pm    Post subject: Help with packed-decimal issue.
Reply with quote

I have a file with one of its field is alphanumeric X(11). It needs to be inserted into a DB2 Table colum [ corresponding DCL gen variable PIC S9(7)V9(2) USAGE COMP-3. ]

the value of this field can be like

1) -1234567.89
2) 1234
3) -123.23
4) 1234567.89
5) 1234567.89

Note: the value at the 1st byte can be negative sign or spaces but not a value. But negative sign can appear anywhere between 2nd to 9th byte.

Regards
Rajiv Rengasamy
Back to top
View user's profile Send private message

rajiv rengasamy

New User


Joined: 24 Sep 2008
Posts: 10
Location: Chennai

PostPosted: Thu Dec 11, 2008 8:11 pm    Post subject: Reply to: Help with packed-decimal issue.
Reply with quote

Hi Folks
Let me know if anyone needs further information.

Regards
Rajiv
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Dec 11, 2008 8:45 pm    Post subject:
Reply with quote

COMPUTE HOST-VAR = NUMVAL(alphanumeric-x-11) end-compute

host-var PIC S9(7)V9(2) USAGE COMP-3
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Thu Dec 11, 2008 8:46 pm    Post subject:
Reply with quote

See intrinsic function NUMVAL in the Language Reference Manual. It will convert alphanumeric to numeric then you can populate your DB2 decimal column.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Thu Dec 11, 2008 9:15 pm    Post subject: Reply to: Help with packed-decimal issue.
Reply with quote

I checked something before answering, and until I finished my tests you've got your answer.
What I wanted to check is what happens if the alpha field contains an invalid value.
This is what I got (there are 2 good tests before the bad one). The abend is U4038:
Code:
FROM = {   +987.65       }
NUMVAL -> TO = {000000000098765}

FROM = {-123.45          }
NUMVAL -> TO = {00000000001234N}

FROM = {12xxx34          }
IGZ0152S Invalid character x was found in column 4 in argument-1 for function NU
         displacement X'30A4'.
         From compile unit TR#MRS01 at entry point TR#MRS01 at compile unit offs
          at address 3EC033CC.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Thu Dec 11, 2008 9:37 pm    Post subject:
Reply with quote

You have to do your own edit-checking before using NUMVAL or NUMVAL-C. See the manual.
Back to top
View user's profile Send private message
rajiv rengasamy

New User


Joined: 24 Sep 2008
Posts: 10
Location: Chennai

PostPosted: Thu Dec 11, 2008 9:54 pm    Post subject: Thanks a lot Folks...
Reply with quote

I checked it works...Thanks a lot for the help.
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 Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Execessive parameter issue Sumeendar JCL & VSAM 5 Mon Dec 19, 2016 4:35 pm


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