Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
Accessing Query ParametersOverview:The Query specifications used to produce a report are stored in three memory files, defined in the --- application. These files are: You can find the current data dictionary definitions of these files below. Note that these files may change without notice in the future and you should be prepared to lose any functionality that you add. Each file can contain records for multiple active query processes. The primary key of each file contains the application ID and process name of the query. These files are populated when you run a query process, in query setup phase. They are read when the query is actually evaluated. A query setup process populates the Q-files based on the specifications entered by the query designer. It is possible to change the contents of the Q-files after the query setup processor has populated them. This is a dangerous practice and you are on your own if you do, but it can be useful. Two important rules apply if you decide to twiddle the Q-files: 1) You will probably break something in an unpredictable way if you make a mistake. 2) You cannot introduce a reference to file or work field that was not already referenced by the query. This means that if you think you might need to add a selection constraint or sort ordering, you have to mention that file (or a field from that file) or that work field somewhere in the query process. A simple do-nothing statement will suffice (such as RESTORE DEFAULT RECORD). If you want to edit the QSLCT records after query setup (Sort, and Designer & Enduser Selection at Runtime) has populated them, try it in "End of Process (Query Setup)". If you wait until the Start of Query Execution, the OUTPUT or UPDATE processor has already read the QLSCT records, so any changes that you might make will have no effect. Each of the Q-files can be divided into two sets of fields: fields which control the result set of the query (i.e. the sort order and selection criteria), and fields which control the query setup phase. Here is a quick description of interesting fields in each of the files:QPARMQPARM QRY EXPR DSPL contains the selection expression seen by the user. QPARM QRY EXPR HIDE contains the hidden selection expression (the "Designer Selections"). Note that these expressions may contain references to criteria which are not actually used. For example, your selection expression might be "100 and 200", but if constraint 200 is not active (ie. the right-hand side is blank), the query processor will effectively trim off the "and 200" part of the selection expression.QSLCTEach QSLCT record contains two operands (the left and right hand fields), one relation ( EQ, GT, LE, IN, etc.), and some extra information. The operands are stored in the group fields QSLCT OPND L and QSLCT OPND R (each contains an application ID, field name, and occurrence number). The relation is stored in QSLCT REL. The QSLCT ACTV field can be examined to determine whether a constraint is actually going to be used. A constraint is active if the relation is non-null and the right-hand operand is also non-null. Don't forget that if your goal is to print selection criteria on the report you will have to somehow account for records excluded (or included) by ILF code.QSORTEach QSORT record specifies an ordering segment. The sort field is identified by the QSORT FLD AP, QSORT FLD NAM, and QSORT FLD OCC parameters. QSORT ORD determines whether an ordering segment will be ascending (+) or descending (-). QSORT ACTV tells you whether a QSORT record is active. QSORT SUBH controls whether a subheading will be executed when the value of the sort field changes, and whether the subheading will generated a form-feed. QSORT SUBT and QSORT SUBT NEW PG determine whether a subtotal will be executed when the value of the sort field changes, and whether that subtotal will generate a form-feed.Below you will find detailed Technical Documentation for the Q-files. The fields in the tech doc below, and not described in the descriptions above, either control the query setup process, or are not implemented.
Here's another way of looking at it (from ECR #2783):How might one report on the contents of --- QSORT, --- QSLCT, and --- QPARM in an OUTPUT start-of-Report frame? (These APPX tables contain QUERY Sort and Record Selection information, for a particular execution of a QUERY/OUTPUT or QUERY/UPDATE.) You can access each of these files within ilf code and also within screen painting, using the SCAN key to get the actual fields within these 3 files. Designer and Enduser Selections both come out of the --- QSLCT file, at runtime. (You can scan on them when editing a SET stmt by setting the Application-ID to "---", pressing SCAN, and giving it a filename/SeqNo of "QSLCT/100".) A couple of the QSLCT fields of interest are:QSLCT 2200 QSLCT ACTV DOMAIN y/n /* Is this an "Active" Record Selection (at run time)? */ QSLCT 2300 QSLCT MOD DOMAIN y/n /* Is this "Modifiable"? (Designer=N, Enduser=Y) */
Example of accessing Enduser Sort Criteria:One might put this ILF into a REPORT START frame, with Sort and Selection criteria painted in multiple rows, displayed here by 'Appearance #', and with "TRAILING BLANK LINES" compressed out.SET --- II = 0 BEG READ --- QSORT HOLD 0 KEY IS QSORT KEY COMPUTE --- II + 1 DISPLAY --- QSORT SNO (AT APPEARANCE # II ) DISPLAY --- QSORT FLD NAM (AT APPEARANCE # II ) DISPLAY --- QSORT ACTV (AT APPEARANCE # II ) END READ --- QSORT
Example of accessing Record Selection Criteria:When editing an ILF SET statement, you can scan on valid field names in the QSLCT table by setting the Application-ID to "---", then pressing SCAN, giving it a starting Filename/SeqNo of "QSLCT/100".SET --- II = 0 BEG READ --- QSLCT HOLD 0 KEY IS QSLCT KEY COMPUTE --- II + 1 DISPLAY --- QSLCT SNO (AT APPEARANCE # II ) DISPLAY --- QSLCT REL (AT APPEARANCE # II ) DISPLAY --- QSLCT ACTV (AT APPEARANCE # II ) DISPLAY --- QSLCT MOD (AT APPEARANCE # II ) DISPLAY --- QSLCT FLD NAM L (AT APPEARANCE # II ) END READ --- QSLCT QUERY PROCESSProcess Name- 2783
|