Page 1 of 1

Pattern Action File Coding Help

Posted: Mon Aug 10, 2015 1:56 pm
by QualityStageatGM
Hello,

I've been trying to do some work with the Pattern Action File for Rulesets and have been looking at the IBM knowledge center site here,

http://www-01.ibm.com/support/knowledge ... alues.html

but am running into problems successfully running a job with a ruleset with a conditional pattern specification.

For example, suppose I have a pattern that DataStage recognizes as this

A|B|?|^|G|G|F|D|E|> where A, B, D, E, F, and G are all classes that I've specificed, suppose for values of "?" where "?" equals a specific value like "metal chassis", I wanted to output a specific value in one of my output columns, how would I edit this command for it to work correctly?

A|B|?|^|G|G|F|D|E|>
*?|^= "metal chassis"
Copy "specialpattern" {OutputColumn}

where OutputColumn is just a column I defined in the Dictionary File.

Is there a default ruleset that I can use as a template or some editing to the above command that I can do for the ruleset to do this task?

Thanks!

Posted: Mon Aug 10, 2015 4:20 pm
by ray.wurlod
Does what you've done throw an error, or merely an incorrect result?
^ is a numeric token, so would never match any part of "metal chassis". Try this pattern/action instead:

Code: Select all

A|B|? [ {} = "metal chassis" ]|^|**
COPY "specialpattern" {OutputColumn}

Posted: Tue Aug 11, 2015 4:57 am
by boxtoby
Try this:

* ?="metal chassis"
COPY_A [1] {OutputColumn}

or if you want to be more specific:

A|B|?|^
COPY_A [3] {OutputColumn}

COPY_A will copy tokens containing a space

If you want to clear the value of the token afterwards add RETYPE [x] 0

Hope this helps.

Bob.

Posted: Tue Aug 11, 2015 8:32 am
by QualityStageatGM
It originally did throw an error. The messages are:

Standardize_2,0: Pattern lines and actions sets out of synch, or command misspelled
Standardize_2,0: The syntax error above was found on line 76 of the pattern-action file ./RT_QS2264/V0S2/Controls/Testing.PAT as follows:
Copy "specialpattern" {OutputColumn}


From the suggestions, I got the following code to work

A|B|? [ {} = "metalchassis" ]|^|**
COPY "specialpattern" {OutputColumn}

It looks like there can't be a space between metal and chassis.

Bob, I'm still investigating the code you provided and trying to combine it with the searching done with Ray's code.

Thanks!

Posted: Thu Aug 13, 2015 9:00 am
by QualityStageatGM
Thanks everyone,

A|B|? [ {} = "metalchassis" ]|^|**
COPY_A [1] {OutputColumn}

The above code works also and standardizes the value of A.