My input file has a trailer record that contains like this
End of File | xxxxxxx
where xxxxxxx is the record count of the whole file (including the trailer record itself).
I am trying to do file validation inside a DataStage sequence job. My approach is as follows:
Code: Select all
ExecuteActivity (CheckFileCount) --> ExecuteActivity (CheckTrailerCount) ----(countok)-------> JobActivity(ExtractSource)
| (countfailed)
Abort
CheckFileCount:
Command: wc
Parameter: -l /path/to/file | awk '{printf $1}'
Triggers: Unconditional
CheckTrailerCount:
command: grep
Parameter: "End of File" /path/to/file | awk '{printf $5}'
Triggers: (here is my trouble)
countok : Custom(Conditional) : Field(Trim(CheckTrailerCount.$CommandOutput), ' ', 1) = Field(Trim(CheckFileCount.$CommandOutput), ' ', 1)
countfailed: Custom(Conditional): Field(Trim(CheckTrailerCount.$CommandOutput), ' ', 1) <> Field(Trim(CheckFileCount.$CommandOutput), ' ', 1)
however, in DS the sequence is always branching to abort (because of the trigger). Director log is showing the output of these 2 activities as follows:
Code: Select all
JobName..JobControl (@CheckFileCount): Executed: wc -l /path/to/file | awk '{printf $1}'
Reply=0
Output from command ====>
1153047
Jobname..JobControl (@CheckTrailerCount): Executed: grep "End of File" /path/to/file | awk '{printf $5}'
Reply=0
Output from command ====>
1153047
Jobname..JobControl (@Coordinator): Summary of sequence run
17:07:47: Sequence started
17:08:04: CheckFileCount (COMMAND wc) started
17:08:08: CheckFileCount finished, reply=0
17:08:08: CheckTrailerCount (COMMAND grep) started
17:08:08: CheckTrailerCount finished, reply=0
17:08:08: Stop Executed
17:08:08: Sequence terminated
Code: Select all
Field(Trim(Convert(@FM," ",CheckTrailerCount.$CommandOutput))," ",1,1) = Field(Trim(Convert(@FM," ",CheckFileCount.$CommandOutput))," ",1,1)
Trim(CheckFileCount.$CommandOutput, @FM) = Trim(CheckTrailerCount.$CommandOutput, @FM)
I highly appreciate if someone can shed a light on this problem or suggest a better approach to solve the same task.
Thanks a million