I have source file which contains 13 columns. In that last 11 columns contains rates for year 1 to 11. I want to create 11 records from one line. For that I have written following routine. But while testing itself it hangs the routine. I think it hangs while opening or reading the file. Can any body help me out.
Or is there any other way to the same thing in datastage other than use of basics.
FncSplitYearRate (SourceFile,TargetFile)
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
mycovcd=""
myyears=0
fr_term=0
to_term=0
mynrate=0
myprate=0
myrate=0
errcode=0
paramerr=0
print "hello "
openseq SourceFile to rfilevar then errcode = 0 else errcode = -1
print "source errcode " : errcode
openseq TargetFile to wfilevar then errcode = 0 else errcode = -1
print "target errcode " : errcode
if errcode = 0
then
Loop
readseq rfileline from rfilevar then *errcode = 0 else errcode = -1
print "Line read is " : rfileline
AgreementSeqNbr = field(rfileline, ",",1)
Fr_Term = field(rfileline, ",",2)
myrate1 = field(rfileline,",",3)
myrate2 = field(rfileline,",",4)
myrate3 = field(rfileline,",",5)
myrate4 = field(rfileline,",",6)
myrate5 = field(rfileline,",",7)
myrate6 = field(rfileline,",",8)
myrate7 = field(rfileline,",",9)
myrate8 = field(rfileline,",",10)
myrate9 = field(rfileline,",",11)
myrate10 = field(rfileline,",",12)
myrate11 = field(rfileline,",",13)
fr_term=0
to_term=0
if myrate1 > 0
then
nRate= myrate1
nYear=1
gosub Myroutine
end
if myrate2 > 0
then
nRate= myrate2
nYear=2
gosub Myroutine
end
if myrate3 > 0
then
nRate= myrate3
nYear=3
gosub Myroutine
end
if myrate4 > 0
then
nRate= myrate4
nYear=4
gosub Myroutine
end
if myrate5 > 0
then
nRate= myrate5
nYear=5
gosub Myroutine
end
if myrate6 > 0
then
nRate= myrate6
nYear=6
gosub Myroutine
end
if myrate7 > 0
then
nRate= myrate7
nYear=7
gosub Myroutine
end
if myrate8 > 0
then
nRate= myrate8
nYear=8
gosub Myroutine
end
if myrate9 > 0
then
nRate= myrate9
nYear=9
gosub Myroutine
end
if myrate10 > 0
then
nRate= myrate10
nYear=10
gosub Myroutine
end
if myrate11 > 0
then
nRate= myrate11
nYear=11
gosub Myroutine
end
Repeat
end
Print "Closing Files"
closeseq rfilevar
closeseq wfilevar
Print "Files Closed"
Myroutine:
print "In routine ";
* if mynrate <> myprate then
* fr_term = fr_term + 1
* to_term = to_term + 1
* myprate = mynrate
* wfileline = mycovcd : "," : myyears : "," : fr_term : "," : to_term : "," : mynrate
* print "fr term " : fr_term
* print "to term " : to_term
* print "mynrate " : mynrate
wfileline = AgreementSeqNbr : "," : Fr_Term : ",": nYear : "," : nRate
print wfileline
writeseq wfileline to wfilevar then errcode = 0 else errcode = -1
* end
Return (0);
errorCode = 0
Ans=0
Girish Oak[/code]