Sequential file error handling

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
gmorgen1
Premium Member
Premium Member
Posts: 12
Joined: Sat Nov 11, 2006 2:13 pm

Sequential file error handling

Post by gmorgen1 »

I have a pipe-delimited Sequential File coming in that occasionally has rows truncated. It should have 3 columns, but sometimes the rows are truncated as below - this is an external provider file and we do not have control over it.

key1|10|text
key2|20|text
key3|
key4|40|text

In this case the process errors out with a fatal error -
Job1..Sequential_File_1.DSLink1: read_delimited() - row 3, column c, required column missing

How can I just write this bad row off to another file and notify someone of the erro and continue processing row-by-row. I do now want the whole process to abort in this instance.
DSGuru79
Charter Member
Charter Member
Posts: 12
Joined: Thu Nov 09, 2006 8:57 pm

Post by DSGuru79 »

In the sequential file you have an option to reject incorrect records. Use that opiton and use DSsendmail provided by datastage to send mail
DSGuru79
niranjansigeni
Participant
Posts: 7
Joined: Sat Sep 09, 2006 7:01 pm
Location: Jersey

Re: Sequential file error handling

Post by niranjansigeni »

In Seq File, go to properties and In the Output tab go to format and select Delimiter as pipe " l ".


thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Welcome Aboard :)
Read your record as a single column and count the number of pipes, if less then 2 then send it down a reject link from the transformer. The constraint for the erraneous record will look something like

Code: Select all

DCOUNT(in.Link,"|") < 2
and for the good records it will look like

Code: Select all

DCOUNT(in.Link,"|") = 2
Then you can use the after-job subroutine to check for the size of the reject file, if its greater than zero then send out an email. You can do that by writing a small routine that uses the STATUS function. Search this forum as i posted a small routine to check for the file size using the STATUS function a while back.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or just use the options available in the Sequential File stage. :wink:

For the fields that are 'optional' i.e. that you may not receive - in this case #2 and #3 - slide the Columns tab over to the right until you can see the Incomplete column column. For those two, change it from Error (which is what is aborting your processing) to Replace or Retain - typically Replace to have them set to null or whatever your 'Missing columns action' setting is on the Format tab.

You can then check for null in those fields and do whatever is appropriate, including splitting them off to Rejection City. Your call.
-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 »

O yea, the sequential file properties. Totally forgot about that. Thanks Craig.

Rejection city huh, cool :wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply