Previous Topic: Example 1: A WITH ClauseNext Topic: Example 3: WHEN-DO Statement in a Dialog


Example 2: PRINT Statement

Question

I always print the same columns. Can I replace a PRINT statement with a term?

Answer

You may want to produce several different types of reports for the same data. You could create terms that replace various print statements or various WHEN-DO statements. For instance, you may frequently print these columns in many queries you write.

      PRINT FROM CAI-CUST-REC
           SLMN-ID
           CUST-ADDRESS-1
           CUST-ADDRESS-2
           CUST-ID
           CITY
           STATE
           PHONE

You could create a term to replace this print statement whenever it is used in a query. Here is how the term definition looks on the CA Dataquery EDITOR:

=> CREATION PANEL --------------------------------------------------------------------------DQD10 DATAQUERY: EDITOR CURRENT TABLE: ________________________________ ------------------------------------------------------------------------------- NAME: CUST-LOCATION TYPE: TERM__ STATUS: PRIVATE DESCRIPTION: ___________________________________________________________ ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+. .. ================================ T O P ===================================== .. FROM CAI-CUST-REC .. SLMN-ID .. CUST-ADDRESS-1 .. CUST-ADDRESS-2 .. CUST-ID .. CITY .. STATE .. PHONE .. =========================== B O T T O M ================================== ------------------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> DISPLAY COLUMNS <PF4> DISPLAY KEYS <PF5> DISPLAY ALL <PF6> LIST TABLES <PF7> BACKWARD <PF8> FORWARD <PF9> TEMPLATE <PF10> VALIDATE <PF11> RIGHT/LEFT <PF12> PROCESS MODE

When you create another query that SORTs differently or FINDs customers from many regions, you can be sure you print the same columns by using the CUST-LOCATION term. Here is how it looks in the sample query:

=> CREATION PANEL --------------------------------------------------------------------------DQD10 DATAQUERY: EDITOR CURRENT TABLE: ________________________________ ------------------------------------------------------------------------------- NAME: CUSTOMER-RECORD TYPE: QUERY_ STATUS: PRIVATE DESCRIPTION: CUSTOMER REPORT____________________________________________ ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+. 01 FIND ALL CAI-CUST-REC 02 WITH ZIP EQUAL '75#' 03 RELATED BY CUST-ORDID-KEY TO CAI-ORDERS-REC 04 WITH DATE GTE 85 05 SET DISCOUNT = UNIT-PRICE * DISC-PCT 06 SORT BY (SLMN-ID) 07 PRINT CUST-LOCATION 08 FROM CAI-ORDERS-REC 09 ORD-ID 10 TERMS =========================== B O T T O M ================================== ------------------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> DISPLAY COLUMNS <PF4> DISPLAY KEYS <PF5> DISPLAY ALL <PF6> LIST TABLES <PF7> BACKWARD <PF8> FORWARD <PF9> TEMPLATE <PF10> VALIDATE <PF11> RIGHT/LEFT <PF12> PROCESS MODE