Page 1 of 1

Reject file message

Posted: Thu Aug 04, 2011 1:44 am
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.

Posted: Thu Aug 04, 2011 7:27 am
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.

Posted: Thu Aug 11, 2011 1:55 am
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.

Posted: Thu Aug 11, 2011 3:18 am
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.

Posted: Thu Aug 11, 2011 3:57 am
by agathaeleanor
Thanks nbalegar.

I used the stage variable method and it works.

Posted: Thu Aug 11, 2011 6:43 am
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.