I am writing a unix shell script that will extract records from table and write into a file.
======================================
#! /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
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