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
 

 

Conversion from decimal to smallint and packeddecimal

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

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Wed Sep 17, 2008 10:47 pm    Post subject: Conversion from decimal to smallint and packeddecimal
Reply with quote

Dear all,
I am trying a send a text file from java application to Mainframe to upload into DB2.here the problem is when i use load utilities i am not able to convert the decimal(java short datatype) to DB2 format which is S9(4) comp-4 or binary.similarly float datatype to packed decimal(S9(9)V99 COMP -1)

i also understand there should be cobol/easytrive to load the file that is generated from Java.our manager doesnt want a cobol program to be written. so i am just looking for DFSORT.. is there any way that i can convert the decimal and float data into cobol computational data such as s9(9) comp-4 in JCL?

i also tried to write a java program that converts the equivalent of s9(9) comp-4 data.. since the representation is different i culd not go for that option too?

any help would greatly appreciated!!!
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Sep 18, 2008 1:24 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

vijayalayancse,

Quote:
similarly float datatype to packed decimal(S9(9)V99 COMP -1)


You say packed decimal and COMP-1. Did you mean COMP-3? With DFSORT you can easily convert the numbers into COMP/COMP-4 and COMP-3

Just convert the java data types to regular readable numbers with signs(+10 or -10.99) and you can run a sort step step to convert them back to the DB2 format.

for ex:

Code:

//STEP0100 EXEC PGM=ICEMAN           
//SYSOUT   DD SYSOUT=*               
//SORTIN   DD *                       
+100      +2200.34                   
-10       -234000.00                 
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                       
  SORT FIELDS=COPY                   
  INREC BUILD=(1,10,SFF,TO=FI,LENGTH=4, 
               11,10,SFF,TO=PD,LENGTH=4)
/*


This will create a 4 byte Binary field(comp or comp-4 ) and a 4 byte Packed decimal field (comp3)

Hope this helps...

Cheers
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Thu Sep 18, 2008 3:52 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

Skolusu,
Thanks a lot for your help.

Can you explain me what is there in the SORT IN dd ?
(like -100, +10 and the equivalent numbers ). your explanation would be helpful for my SORT utility JCL..
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Thu Sep 18, 2008 4:00 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

Sorry,

i understand those are just example.. i thought there were some formatting stuffs.


i will get back to you if any clarification needed once again thank you
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Fri Sep 19, 2008 9:51 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

I need another clarification . i have loaded the data in the DB2. but the output differs from the input.

Input :
40.0
2.0
1.0
1.0
1.0

my sysin card:

//SYSIN DD *
SORT FIELDS=COPY
OUTREC BUILD=(1,368,369,11,SFF,TO=PD,LENGTH=10,
380,3,SFF,TO=ZD,LENGTH=2,383,1)
/*


output:

0.0400
0.0020
0.0010
0.0010
0.0010


Can you please explain me why it happens?

Your help is very much appreciated!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Sep 19, 2008 9:48 pm    Post subject:
Reply with quote

vijayalayancse,

You are converting one filed to Packed decimal and another to zoned decimal format. What are the corresponding DB2 table definitions? ZD format is nothing but a character representation of numeric data.

Show me the DB2 table table definitions for these 2 columns and also show me the contents from 369 thru 382 in your input file and I will show you the control cards necessary for converting them
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Fri Sep 19, 2008 10:15 pm    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

Thanks for the reply.

My table definition is

ITEM_WT - decimal (11,4)
PG_NBR - SMALLINT 2

the corresponding load definition i gave is here

ITEM_WT POSITION( 369: 380 )
DECIMAL PACKED
,
PG_NBR POSITION( 381: 382 )
SMALLINT
,


content of the file
I am displaying only the columns from 360 to 382..
The attached screenshot shows the data



Thanks again for your help!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Sep 19, 2008 10:27 pm    Post subject:
Reply with quote

vijayalayancse,

ITEM_WT - decimal (11,4) is a 6 byte packed decimal field You converted that to a 10 byte field which is wrong.

Try the following control cards

Code:

//SYSIN DD *
  SORT FIELDS=COPY
  OUTREC BUILD=(001,368,
                369,11,SFF,TO=PD,LENGTH=6,
                380,03,SFF,TO=BI,LENGTH=2,383,1)
/*


Hope this helps...
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Sat Sep 20, 2008 12:26 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

Kolusu,
Thanks for ur reply. i am still getting the same issue.

My sysin card

//SYSIN DD *
SORT FIELDS=COPY
OUTREC BUILD=(001,368,369,11,SFF,TO=PD,LENGTH=6,
380,3,SFF,TO=BI,LENGTH=2,383,1)
/*
**************************** Bottom of Data *********

My Output file after executing the JCL before loading into DB2 is given in the attachment..



My Load utility

ITEM_WT POSITION( 369: 374 )
DECIMAL PACKED
,
PG_NBR POSITION( 375: 376 )
SMALLINT

My output shows in DB2,

0.0200
0.0013
0.0020
0.0080
0.0020
0.0080
0.0040
0.0018
0.0013
0.0075


My Input is


*********
NYY20.0
NYY0.13
NYY2.0
NYY8.0
NYY2.0
NYY8.0
NYY4.0
NYY1.8
NYY1.3
NYY0.75




Any idea ???
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Sep 20, 2008 1:06 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

vijayalayancse,

I see the problem now since your input doesn't have the leading zeros the values are stroed as if they are just decimals. Use the following control cards

Code:

//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  OUTREC IFTHEN=(WHEN=INIT,PARSE=(%00=(ABSPOS=369,         
  ENDAT=C'.',FIXLEN=7),%01=(FIXLEN=4)),                   
  OVERLAY=(384:%00,UFF,EDIT=(STTTTTTT),SIGNS=('+','-',,), 
           %01,UFF,EDIT=(TTTT))),                         
  IFTHEN=(WHEN=INIT,BUILD=(1,368,384,12,SFF,PD,LENGTH=6,   
                           380,3,SFF,TO=BI,LENGTH=2,383,1))
/*                                                         


Hope this helps...

Cheers
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Sat Sep 20, 2008 3:10 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

Kolusu,

Thanks again for your help. i still have one issue. as you said the fields are updated correctly.but,the decimal points are not accurate

Code:

//SYSIN DD *                                               
  SORT FIELDS=COPY                                         
  OUTREC IFTHEN=(WHEN=INIT,PARSE=(%00=(ABSPOS=369,         
  ENDAT=C'.',FIXLEN=7),%01=(FIXLEN=4)),                     
  OVERLAY=(384:%00,UFF,EDIT=(STTTTTTT),SIGNS=('+','-',,),   
           %01,UFF,EDIT=(TTTT))),                           
  IFTHEN=(WHEN=INIT,BUILD=(1,368,384,12,SFF,PD,LENGTH=6,   
          380,3,SFF,TO=BI,LENGTH=2,383,1))                 
/*     


Input:
Code:

20.0
0.13
2.0
8.0
2.0
8.0
4.0
1.8
1.3
0.75


Output:

Code:

20.0000 
 0.0013 
 2.0000 
 8.0000 
 2.0000 
 8.0000 
 4.0000 
 1.0008 
 1.0003 
 0.0075 


I am also okay to make changes in my java program if anything to make easier like make all the fields with the same length ..

i also tried to add leading zeros but the issue was the same..

leading zeros output with the old sysin card

Code:

0.0200
0.0013
0.0020
0.0080
0.0020
0.0080
0.0040
0.0018
0.0013
0.0075


Please help.. i am thankful to you .....
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Sep 20, 2008 3:52 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

vijayalayancse,

Code:

20.0
0.13
2.0
8.0
2.0
8.0
4.0
1.8
1.3
0.75


What are you expecting the output to be for the above data? Show me the output you want and I will show you a way to do it
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Sat Sep 20, 2008 4:16 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

Kolusu,

Thanks for ur reply.
The output should be same as the input. as i am sending the files from java i just need to upload them into DB2 without any modification.

Input:
20.0
0.13
2.0
8.0
2.0
8.0
4.0
1.8
1.3
0.75

Output in Db2:
20.0
0.13
2.0
8.0
2.0
8.0
4.0
1.8
1.3
0.75
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Sat Sep 20, 2008 5:52 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

Kolusu,

I forgot to mention one thing. the current output has some issues. not all the records.

current output for below sysin card

Code:

//SYSIN DD *                                               
  SORT FIELDS=COPY                                         
  OUTREC IFTHEN=(WHEN=INIT,PARSE=(%00=(ABSPOS=369,         
  ENDAT=C'.',FIXLEN=7),%01=(FIXLEN=4)),                     
  OVERLAY=(384:%00,UFF,EDIT=(STTTTTTT),SIGNS=('+','-',,),   
           %01,UFF,EDIT=(TTTT))),                           
  IFTHEN=(WHEN=INIT,BUILD=(1,368,384,12,SFF,PD,LENGTH=6,   
          380,3,SFF,TO=BI,LENGTH=2,383,1)) 


o/p :

Code:

20.0000
 0.0013 ===> should have been 0.13
 2.0000
 8.0000
 2.0000
 8.0000
 4.0000
 1.0008 === > should have been 1.8
 1.0003  === >  should have been 1.3
 0.0075 == should have been 0.75


if you could help me out in this.. i would appreciate it
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Sep 20, 2008 9:13 pm    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

vijayalayancse,


Use the following control cards which will take care of the decimals

Code:

//SYSIN DD *                                               
  SORT FIELDS=COPY                                         
  OUTREC IFTHEN=(WHEN=INIT,PARSE=(%00=(ABSPOS=369,         
  ENDAT=C'.',FIXLEN=7),%01=(FIXLEN=4)),                     
  OVERLAY=(384:%00,UFF,EDIT=(STTTTTTT),SIGNS=('+','-',,),   
           %01,TRAN=ALTSEQ)),                           
  IFTHEN=(WHEN=INIT,BUILD=(1,368,384,12,SFF,PD,LENGTH=6,   
          380,3,SFF,TO=BI,LENGTH=2,383,1))

  ALTSEQ CODE=(40F0)
/*
Back to top
View user's profile Send private message
vijayalayancse

New User


Joined: 29 Aug 2005
Posts: 25
Location: Chennai

PostPosted: Tue Sep 23, 2008 8:52 am    Post subject: Reply to: Conversion from decimal to smallint and packeddeci
Reply with quote

Excellent!.. you are the best. thanks a lot
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 File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts EBCDIC to ASCII conversion using OCOPY mistah kurtz All Other Mainframe Topics 5 Tue Sep 06, 2016 2:26 pm
No new posts Comparex utility to Syncsort conversion mistah kurtz SYNCSORT 11 Fri Jul 22, 2016 1:53 pm


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