IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Moving Packed Data to Display Variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sripallu

New User


Joined: 11 May 2005
Posts: 12
Location: India

PostPosted: Tue Sep 02, 2014 4:11 pm
Reply with quote

Hi,
I need some help from Guru's here !
I am receiving a file which is unloaded from a db2 table and there are particular columns which are DECIMAL(31,2) and has been modified as
characters with the help of COALESCE function

Here are how theydefined

1. In the table

X1 DECIMAL (31,2) WITH DEFAULT NULL

2. Unload job which unloads by

COALESCE(CHAR(X1),CHAR(' ')) AS X1

3. In the flat file i have received as (this is what i have declared in copybook)

X1-FILE PIC X(33) , and i could see the field value as below

' 000000000000000000000000000123.33'

3. I want this field to be moved to a report variable

HEADER-X1 PIC Z.ZZZ.ZZZ.ZZZ.ZZZ.ZZ9,99

I have tried using the NUMVAL function and getting U4038 error, also tried to use NUMVAL-C but no luck

Can someone please guide me in this regard?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 02, 2014 5:26 pm
Reply with quote

Code:
01  a-field-with-a-good-name.
    05  some-random-blank PIC X.
    05  nice-name-integer-part PIC 9(29).
    05  nice-name-decimal-point PIC X.
        88  decimal-point-is-ok VALUE ".".
    05  nice-name-decimal-part PIC 99.


01  another-field-with-good-name PIC 9(29)V99.
01  FILLER REDEFINES another-field-with-good-name.
     05  afwgn-integer-part PIC 9(29).
     05  afwgn-decimal-part PIC 99,


On the first group, check the obvious things for being NUMERIC and use the 88. If all OK, MOVE the obvious to the obvious receivers, and use another-field-with-good-name.

At the moment I don't care why you can't get NUMVAL to work - I don't use it, through choice :-).
Back to top
View user's profile Send private message
sripallu

New User


Joined: 11 May 2005
Posts: 12
Location: India

PostPosted: Tue Sep 02, 2014 5:35 pm
Reply with quote

Bill Woodger wrote:
Code:


01  another-field-with-good-name PIC 9(29)V99.
01  FILLER REDEFINES another-field-with-good-name.
     05  afwgn-integer-part PIC 9(29).
     05  afwgn-decimal-part PIC 99,


.

thank Bill,

I am compiling thru Endevor and i dont have control to use Arith for using varibales more than 18digits ,

will my program compiles if i declare PIC 9(29)V99 ??

any how i will give a try, but just curios upfront
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 02, 2014 5:43 pm
Reply with quote

Nope. Not a chance. Probably also why NUMVAL/NUMVAL-C were not working.

Why is the field 31 digits in the db if you can't process it?

Just split the 29-byte fields into two, 15 and 14 (or any combination that you like as long as less than or equal to 18). Increase the number of MOVEs appropriately. Even the editing will work.
Back to top
View user's profile Send private message
sripallu

New User


Joined: 11 May 2005
Posts: 12
Location: India

PostPosted: Tue Sep 02, 2014 5:59 pm
Reply with quote

We have an unload job which extracts the data from the db2 table and provide us in a file , i am using that file to generate a quick report

below is the snapshot of select stmt mentioned in that

select
COALESCE(CHAR(X1),CHAR(' ')) AS X1
from <table>
where <condition>
;

This unload job (DSNTIAUL) runs and generates the file

BTW : the above declarations couldn't pass thru compilation ! Since the db2 stores the DECIMAL as packed decimal we have used the above CHAR to have them in file readable format,

I will try to split the variable as
PIC X(15)
PIC X(14) and check each of them separately
Back to top
View user's profile Send private message
sripallu

New User


Joined: 11 May 2005
Posts: 12
Location: India

PostPosted: Tue Sep 02, 2014 7:28 pm
Reply with quote

I understood sometimes we need to think simple rather than using functions/or any other fancy stuff

Splitting the variables did the trick !
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Sep 02, 2014 8:01 pm
Reply with quote

Btw what is the purpose of DECIMAL (31,2) big amount?
Back to top
View user's profile Send private message
sripallu

New User


Joined: 11 May 2005
Posts: 12
Location: India

PostPosted: Wed Sep 03, 2014 10:45 am
Reply with quote

Not sure
icon_rolleyes.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Sep 04, 2014 1:42 am
Reply with quote

Quote:
Not sure


May be thats where you can start asking this question to Business or responsible parties, as tomorrow what is plan B if you get more than 18 bytes?
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Thu Sep 04, 2014 5:39 am
Reply with quote

IMO, you should always question a requirement that makes no sense. It is your duty as a professional programmer. What if it was a typo in the specification document? It happens.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top