Concatenate Reject Codes

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
rhettbutlernc
Charter Member
Charter Member
Posts: 14
Joined: Thu Dec 04, 2003 11:34 am

Concatenate Reject Codes

Post by rhettbutlernc »

Hey,

I am looking for a way to concatenate all the reject codes that are generated as part of Data validation. All the reject codes from invalid lengths, incorrect dates, record count mismatch etc are to be written as space delimited column and appended to the incoming record and sent as reject file.

Tried doing this using a gigantic if..then statement in the transformer derivation for all combinations of reject codes (7 in my case) is not efficent. I would appreciate if some one can suggest me the best approach.

Thanks in advance!
-Davis
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Use stage variables. Create one stage variable per field and give it a meaningful name. Create an IF statement in that stage variable that sets it to a reject code if the rule fails or sets it to '' if it succeeds. Have a stage variable at the bottom of your stage variable lists that concatenates all your reject codes together. If all the rules pass then your RejectCodes stage variable will concatenate empty strings become an empty string.

In your constraints use the len(RejectCodes) to determine whether you have any rejects and output the RejectCodes down your reject link.

I have been putting a char(10) carraige return as a prefix to my reject codes to push them onto seperate lines in an output text file. This gives me a text file with two record types, the original data row that failed followed by the reject codes and the field that triggered the reject. This is then processed, split and loaded into reject tables for reporting.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can extend this in lots of ways. For example if the business rules are determined using Boolean functions, the results of these can be combined with AND operators to determine whether the row satisfies all business rules.
But "use stage variables" is sage advice.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rhettbutlernc
Charter Member
Charter Member
Posts: 14
Joined: Thu Dec 04, 2003 11:34 am

Post by rhettbutlernc »

Thanks for the suggestions!! Used Stage variables and its great.

-Davis
Post Reply