Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Need to convert PD length from Decimal(4,0) to Decimal(6,2)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
gotlamitla

New User


Joined: 31 Oct 2006
Posts: 11

PostPosted: Thu Feb 21, 2008 4:05 pm    Post subject: Need to convert PD length from Decimal(4,0) to Decimal(6,2)
Reply with quote

I have a DB2 column defined as Decimal(4,0) and is getting changed to Decimal(6,2). I have a file with old column length in a flatfile in PD format. I have to create a load file by converting this field to the new length(decimal 6,2) which is also in PD format.

Do we have any sample to convert a PD format field length as required to include decimal positions ?
Back to top
View user's profile Send private message

shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Feb 21, 2008 4:36 pm    Post subject:
Reply with quote

gotlamitla,

Let us assume the DB2 column defined as Decimal(4,0) is in position 1 and length 3 of load file.

Please check with the following code for your requirement.
Code:
// EXEC PGM=SORT                             
//SORTIN DD DSN=OLDLOAD.FILE,DISP=SHR       
//SORTOUT DD DSN=NEWLOAD.FILE,DISP=...       
//SYSOUT DD SYSOUT=*                         
//SYSIN DD *                                 
 OPTION COPY                                 
 INREC BUILD=(1,3,PD,MUL,+100,TO=PD,LENGTH=4)
/*                                           
// 

Thanks,
Shankar
Back to top
View user's profile Send private message
gotlamitla

New User


Joined: 31 Oct 2006
Posts: 11

PostPosted: Thu Feb 21, 2008 6:48 pm    Post subject: Need to convert PD length from Decimal(4,0) to Decimal(11,2)
Reply with quote

Thanks for the quick response.
But I understand that this sample you have given will not harm the integer part even it is getting multiplied with +100 as Decimal(4,0) and Decimal(6,2) will have integer part as S9(4) (execluding decimal part) ..
Ex: 1234 in decimal(4,0)
after the jcl ... it will be 123400 which will get mapped as 1234.00 for decimal(6,0)

I guess this approach creates problem if the destination field is having length decimal(11,2).

Let me know how can we acheive this.
Correct me if my understanding is wrong.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Feb 21, 2008 7:51 pm    Post subject:
Reply with quote

Hi gotlamitla,
Quote:
I guess this approach creates problem if the destination field is having length decimal(11,2).

Modify the before posted code as per the column datatype and length.
Let us assume the DB2 column defined as Decimal(4,0) changed to Decimal(11,2), then we have to modify the before posted code as below to get the new load file.
Code:
 OPTION COPY                                 
 INREC BUILD=(1,3,PD,MUL,+100000000,TO=PD,LENGTH=6)

Thanks,
Shankar
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Feb 21, 2008 10:46 pm    Post subject:
Reply with quote

I don't use DB2 so I don't know the notation being used here.

Does Decimal(4,0) mean 4 digits with 0 digits after the decimal point (e.g. 1234)?

Does Decimal(6,2) mean 6 digits with 2 digits after the decimal point (e.g. 1234.56)?

Does Decimal(11,2) mean 11 digits with 2 digits after the decimal point (e.g. 123456789.01)?

If so, then to convert from Decimal(4,0) to Decimal(11,2), you could use:

Code:

  OPTION COPY                                 
  INREC BUILD=(1,3,PD,MUL,+100,TO=PD,LENGTH=6)


That would convert 1234 = X'01234C' = PL3'1234' to 123400 = X'00000123400C' = PL6'123400'.

Unless I'm misinterpreting what the Decimal notation means, I don't know why Shankar is multiplying by +100000000.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Thu Feb 21, 2008 11:04 pm    Post subject:
Reply with quote

He shouldn't be, he should just be multiplying by +100 to add 2 zeros to the end.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Feb 22, 2008 10:43 am    Post subject:
Reply with quote

Hi Craq Giegerich/Frank Yaeger

Quote:
He shouldn't be, he should just be multiplying by +100 to add 2 zeros to the end.

Yes, you are correct and I am wrong. Sorry for posting the wrong code.

Thanks,
Shankar
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
This topic is locked: you cannot edit posts or make replies. Selecting two copybooks of different ... Vignesh Sid COBOL Programming 8 Tue Sep 05, 2017 7:28 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us