Rouitne to create the file in appending mode

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
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Rouitne to create the file in appending mode

Post by Aquilis »

Hello,
I have created a transform routine as shown below. It actually restructures the incoming data and creates the file & writes the data in append mode. Routines is behaving as I am exepcting but the issue with this I have to touch the files first (I have to get the zero byte first file created).

What I'm a expecting is , Routine it self should create the file & write the data in appending mode to it.

Since I am getting the 'N' number of files with different set metadata defined in the them, I am following this approach.


Code: Select all


 FileDir= '/Wrkdir/data'
      FileName="xxx_unspecified.dat"
      ColCnt=count(ColName,",")+1
      IF Rownum>0 Then
*** Write To File
         PathName = FileDir:'/':FileName
         OpenSeq PathName To FileVar Then
            SEEK FileVar,4,2 
            ELSE
               Call DSLogWarn("Error in SEEK", RoutineName)
            END
            For i=1 to ColCnt
               Column_Name=Field(ColName,',',i)
               Column_Value=Field(ColValue,',',i)
               FileFormat=File:'|':i:'|':Column_Name:'|':Column_Value:'|':Rownum
               WRITESEQ FileFormat TO FileVar Then
               END
            NEXT i
         END
         Ans=FileFormat
         weofseq FileVar
         CloseSeq FileVar
      End
 
Could anybody of you help me on this.
Thank you,
Aquilis
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Check the OpenSeq syntax in the BASIC manual, you need to add the 'else' path to create it when the open fails. A search here would turn up examples as well.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... and, within the ELSE path of the OPENSEQ statement, you can use a CREATE statement to force the file to exist.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

Thanks Ray,
It's working.
Aquilis
Post Reply