Reject file message

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Reject file message

Post by agathaeleanor »

Hi,

I have a parallel job which designed in such a way that,

Code: Select all

seq file --> transformer --> dataset
                   |
              reject file
In the reject file, if there are >2 columns in a record hitting the constraint and being reject, it would only show one reject reason. For better visualization,

reject file:
col1|col2_notnull|co3_date|col4|col5|Reject_Reason
a1||20110345|data|data|col2_notnull is empty

desire output:
col1|col2_notnull|col3_date|col4|col5|Reject_Reason
a1||20110345|data|data|col2_notnull is empty, col3_date invalid date format

May i know how to concatenate the reject message in transformer stage?
Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just... concatenate them when you derive the reason. :?

Check to see if one or both conditions were true and write one or both messages in that column. If you are still stuck, post your constraint expression.
-craig

"You can never have too many knives" -- Logan Nine Fingers
agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Post by agathaeleanor »

In the transformer link out to reject file, i added a MESSAGE column contained rule,

If Trim(Col1) = '' Then 'Col1 is empty ' Else If Len(Trim(Col1)) > 20 Then 'Col1 length is > 20 ' Else If Trim(Col2) = '' Then 'Col2 is empty ' Else If Len(Trim(Col2)) > 10 Then 'Col2 length is > 10 '


say, one of the record in the source file, Col1 is null and length of Col2 is 15.

The existing job can only output MESSAGE as 'Col1 is empty'

How to concatenate the error message to display 'Col1 is empty, Col2 length is > 10'? It has more than two validation.

Thanks in advance.
nbalegar
Participant
Posts: 9
Joined: Fri Jul 08, 2011 2:47 am

Post by nbalegar »

Hi use the modified if condition
if col1=''
then
if col2=''
then 'col1 is empty and col2 is empty'
else if col2 > 10
then 'col1 is empty and Col2 length is > 10'
else ''
else if col1 > 20
then
if col2=''
then 'Col1 length is > 20 and col2 is empty'
else if col2 > 10
then 'Col1 length is > 20 and Col2 length is > 10'
else ''
else ''

or

one more method is use two stage variables for col1 and col2 as
If Trim(Col1) = ''
Then 'Col1 is empty '
Else If Len(Trim(Col1)) > 20
Then 'Col1 length is > 20 '
else ''

If Trim(Col2) = ''
Then 'Col2 is empty '
Else If Len(Trim(Col2)) > 10
Then 'Col2 length is > 10 '
else ''

and concatenate the two stage variables in the derivation svar1:svar2.

NOTE: The dummy else part you have to take care as if has to end with else, so i have put dummy else.
agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Post by agathaeleanor »

Thanks nbalegar.

I used the stage variable method and it works.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It can all be done at once:

Column Derivation

Code: Select all

Trim((If Trim(Col1) = '' Then 'Col1 is empty' Else If Len(Trim(Col1)) > 20 Then 'Col1 length is > 20' else '' ) : (If Trim(Col2) = '' Then ',Col2 is empty ' Else If Len(Trim(Col2)) > 10 Then ',Col2 length is > 10 ' else '' ),",","B")
Remove the outer trim if you don't add the commas in the text.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply