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
 

 

Moving Packed Data to Display Variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Moving Packed Data to Display Variable
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Tue Sep 02, 2014 5:26 pm    Post subject: Reply to: Moving Packed Data to Display Variable
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    Post subject: Re: Reply to: Moving Packed Data to Display Variable
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Tue Sep 02, 2014 5:43 pm    Post subject: Reply to: Moving Packed Data to Display Variable
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    Post subject:
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    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue Sep 02, 2014 8:01 pm    Post subject:
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    Post subject: Reply to: Moving Packed Data to Display Variable
Reply with quote

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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Sep 04, 2014 1:42 am    Post subject:
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: 641
Location: Whitby, ON, Canada

PostPosted: Thu Sep 04, 2014 5:39 am    Post subject:
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    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 Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm


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