Filters
How to use filters to filter repeated control block data.
Some control blocks like the ASCB are Repeated. When extracting these Repeated control blocks, you may want to only extract the entries that match one or more Filters. CBXP allows Filters to be provided when extracting Repeated control block data.
Filter Basics
Filters are specified as key-value pairs, where the key is a Control Block Field and the value is a Filter Value.
The following example extracts all ASSB control blocks where the Control Block Field ASSBJBNI matches the Filter Value IBMUSER.
Python Script
from cbxp import CBXPFilter, CBXPFilterOperation, cbxp
cbdata = cbxp(
"assb",
filters=[
CBXPFilter(
"assbjbni",
CBXPFilterOperation.EQUAL,
"IBMUSER"
)
]
)
Shell Script
cbxp -f assbjbni=IBMUSER assb
Using Multiple Filters
Multiple Filters can be used.
The following example extracts all ASSB control blocks where both the Control Block Field ASSBJBNI matches the Filter Value IBMUSER and the Control Block Field ASSBJBNS matches the Filter Value BPXAS.
Python Script
from cbxp import CBXPFilter, CBXPFilterOperation, cbxp
cbdata = cbxp(
"assb",
filters=[
CBXPFilter(
"assbjbni",
CBXPFilterOperation.EQUAL,
"IBMUSER"
),
CBXPFilter(
"assbjbns",
CBXPFilterOperation.EQUAL,
"BPXAS"
)
]
)
Shell Script
cbxp -f assbjbni=IBMUSER -f assbjbns=BPXAS ascb
Using Filters With Include Patterns
Filters can be use with control blocks included using Include Patterns.
The following example extracts all ASCB and corresponding ASSB control blocks where the Control Block Field ASSBJBNI matches the Filter Value IBMUSER.
Python Script
from cbxp import CBXPFilter, CBXPFilterOperation, cbxp
cbdata = cbxp(
"ascb",
includes=["assb"],
filters=[
CBXPFilter(
"assb.assbjbni",
CBXPFilterOperation.EQUAL,
"IBMUSER"
)
]
)
Shell Script
cbxp -i assb -f assb.assbjbni=IBMUSER ascb
Using Filters With fnmatch Patterns
fnmatch patterns can be used as Filter Values.
The following example extracts all ASSB control blocks where the Control Block Field ASSBJBNI matches the Filter Value IBMUSER*.
Python Script
from cbxp import CBXPFilter, CBXPFilterOperation, cbxp
cbdata = cbxp(
"assb",
filters=[
CBXPFilter(
"assbjbni",
CBXPFilterOperation.EQUAL,
"IBMUSER*"
)
]
)
Shell Script
cbxp -f 'assbjbni=IBMUSER*' assb
Filtering Numeric Data
>, >=, <, and >= can be used when filtering Numeric Control Block Fields.
The following example extracts all ASSB control blocks where the Control Block Field ASSB_TIME_ON_CP is Less Than 30000.
Python Script
from cbxp import CBXPFilter, CBXPFilterOperation, cbxp
cbdata = cbxp(
"assb",
filters=[
CBXPFilter(
"assb_time_on_cp",
CBXPFilterOperation.LESS_THAN,
30000
]
)
Shell Script
cbxp -f 'assb_time_on_cp<3000' assb