converting the data type in unix shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting converting the data type in unix shell script
# 1  
Old 10-16-2008
converting the data type in unix shell script

I am writing a unix shell script that will extract records from table and write into a file.
Code:
======================================
#! /bin/ksh
############################
#   AFI Monitor Script
############################
. /db2/uszlad48/sqllib/db2profile
export mondir=/home/bmwdev1/script/krishna/arc
export monlog=$mondir/r1.log
# connect to DB
db2 connect to r2pdev user bmwdevup using summer08
# extract the records from the table ZB_RCBL_ERROR_MSG_MIG
db2 -x "SELECT A.LINE_OF_BUSINESS, A.USER_UPDATED, A.ERROR_STATUS_CD, A.STATE_CD, A.AGENT_DIST, A.AGENT_ID, A.COMPANY_CD, A.REGION_CD, A.PLCY_CONTRACT_NUM, A.EFF_DT, A.BILLING_ACCT_NUM, A.PREMIUM_AMT, B.MSG_NUM, B.MSG_ID, B.MSG_TYP, B.MSG_TEXT FROM BMWDEV1.ZB_RCBL_ERROR A, BMWDEV1.ZB_RCBL_ERROR_MSG B WHERE A.TRACKING_NUM = B.TRACKING_NUM AND A.TRACKING_NUM_SUFFIX = B.TRACKING_NUM_SUFFIX AND A.TIMESTAMP_UPDATED >= '2008-10-01-00.00.00.000000' AND A.TIMESTAMP_UPDATED < '2008-10-05-00.00.00.000000' WITH UR" >> $monlog
# disconnect from DB2
db2 terminate
exit 0
======================================

Following is the output I have got by executing this script
Code:
F                R2P          E               22       02         102      B21        08        929460723         10/07/2008 M866516384            -1669.46 002                          I       One or more uncleared errored receivables for the policy                                            
A                R2P          E               22       02         102      B01        08        175056956         09/22/2008 M277377095              237.60 003                          I       Policy / Contract Account Number are pending in the ZB_MASTER_DATA_LOG                              
F                R2P          E               22       02         330      B21        08        929460103         09/29/2008 M275350821             1772.29 038     >4                   I       Enter an amount                                                                                     
F                R2P          E               22       02         330      B21        08        929460103         09/29/2008 M275350821             1150.00 002                          I       One or more uncleared errored receivables for the policy                                            
F                R2P          E               36       35         330      B21        02        929460739         10/08/2008 P897680301             1824.93 003                          I       Policy / Contract Account Number are pending in the ZB_MASTER_DATA_LOG

The problem what i am facing is the field Premium_amt is available in the file in character format. I going to FTP this text file to mainframe. There they will format the data. While formatting they have to add the premium amount. If it is available character format we will not be able to sum all the premium amount. If it is avilable in packed decimal we will convert into decimal and will sum it up.
Can anyone help me to fix this problem.
Krishnakanth
# 2  
Old 10-16-2008
Code:
F2='myjcl.jcl'
echo "
verbose
open mvsnode
user myuser mypass
-- getting mainframe jcl
get 'PROD.AAAA.JCLLIB(@XXXXXXX)' $F2
quote site submit
put $F2
quit
" > $F1

use quote site submit your jcl 'PROD.AAAA.JCLLIB(@XXXXXXX)' to do a data conversion on the file you just placed over there.
# 3  
Old 10-16-2008

Which field is that?

What does it contain?

What do you want it to contain?

Please give samples of input and desired output.
# 4  
Old 10-17-2008
I want the field PREMIUM_AMT to be in packed decimal format.

Code:
-1669.46
237.60
1772.29
1150.00
1824.93


Currently this field is in character format.

I am trying to write a shell script to convet into packed decimal (comp -3) format.

Please advice.

Krishnakanth
# 5  
Old 10-17-2008
Quote:
Originally Posted by kmanivan82
I am trying to write a shell script to convet into packed decimal (comp -3) format.

I don't know how fractions are handled, but I think this will convert integers:

Code:
case $n in
  -*) sign=D ;;
  *) sign=C ;;
esac
while [ -n "$n" ]
do
  printf "%x" "'$n"
  n=${n#?}
done
echo "$sign"

If you know the formula, please post it, and I'll write a script to do the conversion.
# 6  
Old 10-18-2008
try to use typeset in script...
I think it will help you...
man typeset
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting LONG Data Type from DB via UNIX Script

Hi, I want to extract a XML file which is stored in the database having a data Type as "LONG" via UNIX Scripting. But when i am triggering the SQL via UNIX it is fetching only the first Line and not the complete XML. Can you please suggest if the parameters that i have used needs any... (2 Replies)
Discussion started by: Barbara1234
2 Replies

2. Programming

Visual Basic converting a decimal data type to a label with currency format

Here is the code that I am working with. I have tried several other things. any suggestions? Lbl_Cost_Output.Text = (dDistance * dCostPerMile).ToString("C") The label is formatted correctly in terms of value 0.00 but no dollar sign appears. Please let me know if you have any questions. (1 Reply)
Discussion started by: briandanielz
1 Replies

3. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

4. Shell Programming and Scripting

Data export UNIX shell script

Hi, I want to write a shell script which connect to my database with the following credentials : User name : user PWD : rap_user_1 Hostname : app.Unix.Gsm1900.Org Port : 7862 SID : PTNC1 Once connected to DB i want to fetch data with the help of a SQL statement and expoet... (4 Replies)
Discussion started by: neeraj617
4 Replies

5. Shell Programming and Scripting

How to fetch data from oracle in unix shell script

Hi, How to fetch data from oracle database in unix shell scripting. list=`sqlplus -s ds_user/dsuser@EMI <<EOF set feedback off set serveroutput on set heading off set pagesize 0 set tab off select IP_ID from table / exit EOF` The output is not what i expected.I need output in... (4 Replies)
Discussion started by: Anusha_Reddy
4 Replies

6. Shell Programming and Scripting

Extracting LONG Data Type from DB via UNIX Script

Hi, I want to extract a XML file which is stored in the database having a data Type as "LONG" via UNIX Scripting. But when i am triggering the SQL via UNIX it is fetching only the first Line and not the complete XML. Can you please suggest if the parameters that i have used needs any... (0 Replies)
Discussion started by: dear_abhi2007
0 Replies

7. Shell Programming and Scripting

Unix shell script converting temperatures.

:confused:Please I really need help with an assignment question. I need to write a script that will take the input from a file and convert the number from Centigrade(Celcius) to Fahrenheit or vice versa. Thank you so much. I really need it to be detailed. Please remember the input comes from a file. (1 Reply)
Discussion started by: starter101
1 Replies

8. UNIX for Dummies Questions & Answers

Verify the data type in a file with UNIX function

I am seeking help on this UNIX function, please help. Thanks in advance. I have a large file, named as 'MyFile'. It was tab-delmited, I am told that each record in column 1 is unique. How would I verify this with UNIX function or command? (1 Reply)
Discussion started by: duke0001
1 Replies

9. Shell Programming and Scripting

How to type the Omega symbol Ω in unix shell script

Hi, I have a data file delimited by Ω symbol, I would like to use this in grep and cut command. but How to type this Omega symbol. Thanks Murugesan (1 Reply)
Discussion started by: NagaMurugesan
1 Replies

10. Shell Programming and Scripting

How to extract data using UNIX shell script?

Hello All, I am starting with UNIX. Any help is highly appreciated. How to extract data using UNIX shell script? And how do you export data using UNIX shell scripts into Microsoft Excel format? Thank you. (3 Replies)
Discussion started by: desiondarun
3 Replies
Login or Register to Ask a Question