Writing in to a sequential file trhru routine

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

shrinivas
Participant
Posts: 53
Joined: Mon Sep 18, 2006 3:42 am
Location: hyd

Writing in to a sequential file trhru routine

Post by shrinivas »

Hi guys ,
I am writing a file thru a sequence. This is basicly a control routine which accepts list of job names and write output in a sequential file . The problem I am facing is whenever I write the target sequential file , Every time the last character of the sequentail file is appended with a junk character and the ascii value of it I found is 0D. dont know what is the problem. Following is the code

Code: Select all

 Dest := JobName : "," : JobStartTime : ",": JobEndTime : "," : JobStat : "," : RejEntrWarn : ";": RejEntrFatal :"," : SrcRowCount : "," : DstRowCount: '^'  

var1 =  char(10):char(13)
Dest = Trim(Dest,'^',"T")
Status = EREPLACE(Dest,'^',var1) 

          WRITESEQ Status TO FileVar1 ELSE STOP
          
          WEOFSEQ FileVar1

          CloseSeq FileVar

      END ELSE
          Call DSLogFatal('File open error on ':paramset:'. Status = ':Status(),SetParams)
      END 

Above is my code where JobName , JobStartTime ,JobEndTime , JobStat , RejEntrWarn ,RejEntrFatal , SrcRowCount ,DstRowCount are diffrent varaibles containing Jobs status appended with '^'. I am replacing ^ this to New line character to get each job details in new line and then writng it to file
shrinivas
Participant
Posts: 53
Joined: Mon Sep 18, 2006 3:42 am
Location: hyd

Post by shrinivas »

Hi guys ,
I am writing a file thru a sequence
In th eabove message I have written I am writing a file thru a sequence.
Its a typo and the correct sentence is "I am writing a file thru a routine."
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

you have still more typing errors. The word is written "through" and not "thru"!
Wolfgang Hürter
Amsterdam
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You do realize your 'junk character' of 0D is a carriage return - a char(13), yes? Where exactly is this showing up? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
shrinivas
Participant
Posts: 53
Joined: Mon Sep 18, 2006 3:42 am
Location: hyd

Post by shrinivas »

Ya Chulett I just got to know its the ASCII value of "CR" from DS documents ..
I write the Ascii values into a sequential file.There its returning 0D.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

We know it's in the sequential file. I asked where exactly is it? How about an example of your problem?
-craig

"You can never have too many knives" -- Logan Nine Fingers
shrinivas
Participant
Posts: 53
Joined: Mon Sep 18, 2006 3:42 am
Location: hyd

Post by shrinivas »

Its coming in the last row of the file and it is the last character of the row.
For example ........
The file structure looks like ....

JobName , SrcRowCount, DestRowCount
A,10,10
B,10,10
C,20,11
So the Carraiage Return is concatenated with the number 11[Last row Last Character]
When I see the Ascii value its comes as 31310D
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not knowing everything that's going on, first suggestion would be to comment out the WEOFSEQ function in your routine and see if that 'fixes' it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

This is'nt the entire code is it? WHere are you opening the file (OPENSEQ) for writing. Plus, I dont think you need a WEOFSEQ. All you need to do is

Code: Select all

OPENSEQ 'myfilename' to FILE ELSE ABORT
LOOP 
      
        WRITESEQ .....

END LOOP
CLOSESEQ FILE
This is just to give you a general idea. Its not complete code. Does not even have any error handling.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
shrinivas
Participant
Posts: 53
Joined: Mon Sep 18, 2006 3:42 am
Location: hyd

Post by shrinivas »

I removed it but , no change , I am getting the CR at same place
shrinivas
Participant
Posts: 53
Joined: Mon Sep 18, 2006 3:42 am
Location: hyd

Post by shrinivas »

even for the simple transform routine I am getting the same problem

Code: Select all

      #Include DSINCLUDE DSD_STAGE.H
      #Include DSINCLUDE JOBCONTROL.H
      #Include DSINCLUDE DSD.H
      #Include DSINCLUDE DSD_RTSTATUS.H

ErrorCode=0
set=''



destset= Arg1

  Status =  "abcd,122,11"
  
      OPENSEQ destset TO FileVar1 THEN

          WRITESEQ Status TO FileVar1 ELSE STOP
               
          CloseSeq FileVar1

      END ELSE
          Call DSLogFatal('File open error ',SetParams)
      END 
Ans = 0
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There's a whole lot wrong with all the code in this thread. For example, the ELSE clause on OpenSeq can be taken even if the file is opened for writing.

For the moment forget WriteSeq and try the

Code: Select all

echo 
command.

Code: Select all

filename = "myfilename"
Cmd = "echo " : Dest : " >> " : filename
Call DSExecute("UNIX", Cmd, Output, ExitStatus)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
shrinivas
Participant
Posts: 53
Joined: Mon Sep 18, 2006 3:42 am
Location: hyd

Post by shrinivas »

I tried every thing(in my view)..
I can tell you guys my requirments ..
I have a variable having a string and I would like to write in to a file .
The string looks like
a,b,10,11Char(10):Char(13)c,d,12,93Char(10):Char(13)d,e,20,12Char(10):Char(13)

I am appending Char(10):Char(13) to get the values in next line .
Can any body give me the proper syntax to write it in to a file .
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

Shrinivas,

Instead of CHAR(10):CHAR(13) use and try CHAR(13):CHAR(10).


Thanks,
Anupam
shrinivas
Participant
Posts: 53
Joined: Mon Sep 18, 2006 3:42 am
Location: hyd

Post by shrinivas »

I tried ur sugegstion but no improvement ,The problem is what ever I write in to a sequntial file it append the CR in to the last character of the last record .
Can u get me the syntax with an example . from which I can match it my code
Post Reply