Appending data in an existing fileusing WRITESEQ

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
loe_ram13
Participant
Posts: 35
Joined: Thu Apr 12, 2007 1:17 am

Appending data in an existing fileusing WRITESEQ

Post by loe_ram13 »

I have a file TestFile.
It has 10 records in it.
Using WRITESEQ I want to append 10 more lines in the file TestFile.
How is this possible??
Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Search the forum for a routine called OpenSequentialFile. It covers all the possibilities.

Basically, you have to position to end-of-file using a Seek statement (or a loop of ReadSeq statements) before attempting a WriteSeq statement. This is managed within the OpenSequentialFile routine.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
loe_ram13
Participant
Posts: 35
Joined: Thu Apr 12, 2007 1:17 am

Post by loe_ram13 »

Thanks !!!
I tried the loop one.
I am getting the desired output with the following code:
$INCLUDE DSINCLUDE JOBCONTROL.H
$INCLUDE DSINCLUDE DSR_UVCONST.H
$INCLUDE DSINCLUDE DSR_COMCONST.H

PRINT 'FIRST LINE OF ROUTINE'
RDT=RECDT
HOUR=HR
PRINT 'SECOND LINE OF ROUTINE'

OPENSEQ'/u04/PRODDSS/data2/srcfiles/test/ramya/server/inrich/abcin':"_":RDT:"_":HOUR TO SrcFile ELSE PRINT 'FILE NOT FOUND'
OPENSEQ'/u04/PRODDSS/data2/srcfiles/test/ramya/server/inrich/fileop':"_":RDT:"_":HOUR TO SeqFile ELSE PRINT 'HIII'
FOR N=1 to 407467 +1
READSEQ A from SrcFile ELSE PRINT'CAN Not Read'

A1=Field(A,',',1); *MDN
A2=Field(A,',',2); *MIN
A3=Field(A,',',3); *BUCKET ID with TILDE
A4=Field(A,',',4); *BUCKET VAL with TILDE
A5=Field(A,',',5); *COSID with TILDE
B=DCount(A3,'~'); *Count i.e. no of times the for loop will execute
For Outer = 1 To B Step +1 ;* outer B no of repetitions
C1=Field(A3,'~',Outer);
D1=Field(A4,'~',Outer);
E1=Field(A5,'~',Outer);
Final=A1:'|':A2:'|':C1:'|':D1:'|':E1;
WRITESEQF Final TO SeqFile ELSE STOP
Next Outer
Next N
CLOSESEQ SeqFile
CLOSESEQ SrcFile
Ans=1


But when Iam executing it in a job,job is getting finished with see log.
The warning message is:
DataStage Job 130 Phantom 9784
FIRST LINE OF ROUTINE
SECOND LINE OF ROUTINE
DataStage Phantom Finished

Kindly help.
Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That is purely because of the PRINT statements in your code. DataStage logs a warning if anything "unexpected" appears in the output. Comment out the PRINT statements, or change them to DSLogInfo() calls, and the warning will vanish.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply