  | 
		
HP COBOL Reference Manual
 
 
6.8.15 GENERATE
Function 
 
 
The GENERATE statement directs the Report Writer Control System (RWCS)
to produce a report according to the Report Description entry (RD) in
the Report Section of the Data Division.
  
 
report-item
names either a report-name in a Report Description entry, or the
group-data-name of a TYPE IS DETAIL report group.
 
Syntax Rules 
 
 
  - If report-item references a group-data-name, it must name
  a TYPE DETAIL report group. Group-data-name can be qualified by
  report-name.
  
 - If report-item references a report-name, its report
  description must contain:
  
    - A CONTROL clause
    
 - At least one CONTROL HEADING, DETAIL, or CONTROL FOOTING report
    group
    
 - No more than one DETAIL report group
  
  
  
General Rules 
 
 
  - An INITIATE statement must be executed before a GENERATE statement
  is executed for a specific report.
  
 - The RWCS produces a summary report if all of the GENERATE
  statements for a report reference report-name. A summary report
  contains no TYPE IS DETAIL report groups.
  
 - The RWCS produces a detail report if a GENERATE statement
  references a DETAIL report group.
  
 - To detect and trigger control breaks for a specific report, the
  RWCS:
  
    - Saves the initial values within control data items as prior values
    when the GENERATE statement executes.
    
 - Compares the prior values to the current values of control data
    items when subsequent GENERATE statements execute. Only if the current
    values change does a control break occur. If a control break occurs,
    the current values are saved as prior values.
    
 - Repeats the preceding step until the last control break is
    processed.
  
  
   - The RWCS automatically processes any PAGE HEADING and PAGE FOOTING
  report groups when it must start a new page to present a CONTROL
  HEADING, DETAIL, or CONTROL FOOTING.
  
 - When the first GENERATE statement for a specific report is
  executed, the RWCS processes these report groups, if present in the
  report description, in this order:
  
    - The REPORT HEADING report group.
    
 - The PAGE HEADING report group.
    
 - All CONTROL HEADING report groups from major to minor.
    
 - For GENERATE group-data-name statements (detail reporting), the
    RWCS presents the specific DETAIL report group for processing.
    
 - For GENERATE report-name statements (summary reporting), the RWCS
    does not present the DETAIL report group for processing; however, the
    RWCS does perform all other DETAIL report group functions.
  
  
   - When subsequent GENERATE statements are executed for a specific
  report, the RWCS:
  
    - Checks for control breaks. The rules governing the inequality of
    control data items are identical to the rules for relation conditions.
    If a control break occurs, the RWCS:
    
      - Enables the CONTROL FOOTING USE procedures and CONTROL FOOTING
      SOURCE clauses. This allows program access to the control data item
      values that the RWCS uses to detect a given control break.
      
 - Processes the CONTROL FOOTING report groups starting with the
      minor. Only CONTROL FOOTING report groups less major than the highest
      level at which a control break occurs are processed.
      
 - Processes the CONTROL HEADING report groups in the order major to
      minor. Only the CONTROL HEADING report groups less major than the
      highest level at which a control break occurs are processed.
    
  
     - Processes the GENERATE statement. For GENERATE group-data-name
    statements (detail reporting), the RWCS processes the specific DETAIL
    report group. For GENERATE report-name statements (summary reporting),
    the RWCS does not present the DETAIL report group for processing;
    however, the RWCS does perform all other DETAIL report group functions.
  
  
   - No GENERATE statements can reference a file after executing a
  TERMINATE statement for the same file.
  
Additional References 
 
 
6.8.16 GO TO
Function 
 
 
The GO TO statement transfers control from one part of the Procedure
Division to another.
  
 
proc-name
is a procedure-name.
num
is the identifier of an elementary numeric item described with no
positions to the right of the assumed decimal point.
 
Syntax Rules 
 
 
  - A Format 1 GO TO statement that is in a consecutive sequence of
  imperative statements in a sentence must be the last statement in the
  sentence.
  
 - If an ALTER statement refers to a paragraph, the paragraph must
  consist of only a paragraph header followed by a Format 1 GO TO
  statement.
  
 - A Format 1 GO TO statement without proc-name can only be
  in a single-statement paragraph.
  
General Rules 
 
 
Format 1 
 
 
  - The GO TO statement transfers control to proc-name.
  
 - If there is no proc-name, the GO TO statement cannot
  execute before an ALTER statement changes its destination.
  
Format 2 
 
 
  - The GO TO statement transfers control to the proc-name in
  the ordinal position indicated by the value of num. 
 No
  transfer occurs, and control passes to the next executable statement if
  the value of num is one of the following:
  
    - Not greater than zero
    
 - Greater than the number of proc-names in the statement
  
  
  
Examples 
 
 
  - Format 1:
 
   - Format 2:
 
  
    
       
      
GO TO FRESHMAN
      SOPHOMORE
      JUNIOR
      SENIOR
        DEPENDING ON YEAR-LEVEL.
MOVE ...
 |   
     Sample Results
  
    | YEAR-LEVEL  | 
    Transfers to  | 
   
  
    | 
      1
     | 
    
      FRESHMAN label
     | 
   
  
    | 
      2
     | 
    
      SOPHOMORE label
     | 
   
  
    | 
      3
     | 
    
      JUNIOR label
     | 
   
  
    | 
      4
     | 
    
      SENIOR label
     | 
   
  
    | 
      5
     | 
    
      MOVE statement
     | 
   
  
    | 
      0
     | 
    
      MOVE statement
     | 
   
  
    | 
      -10
     | 
    
      MOVE statement
     | 
   
 
  
6.8.17 IF
Function 
 
 
The IF statement evaluates a condition. The condition's truth value
determines the program action that follows.
  
 
stment-1
is an imperative or conditional statement. An imperative statement can
precede a conditional statement.
stment-2
is an imperative or conditional statement. An imperative statement can
precede a conditional statement.
 
Syntax Rules 
 
 
  - The ELSE NEXT SENTENCE phrase is optional if it immediately
  precedes a separator period.
  
 - If the END-IF phrase is specified, the NEXT SENTENCE phrase must
  not be specified.
  
General Rules 
 
 
  - The scope of an IF statement ends with any of the following:
  
    - An END-IF phrase at the same nesting level
    
 - A separator period
    
 - An ELSE phrase associated with an IF statement at a higher nesting
    level
  
  
   - If the condition is true, the following control transfers occur:
  
    - If there is a stment-1, it executes. 
 stment-1
    can contain a procedure branching or conditional statement. Control
    then transfers according to the rules of the statement.  Otherwise,
    the ELSE phrase (if any) is ignored. Control passes to the end of the
    IF statement.
     - If you use NEXT SENTENCE instead of stment-1, the ELSE
    phrase (if any) is ignored. Control passes to the next executable
    sentence.
  
  
   - If the condition is false, the following control transfers occur:
  
    - stment-1 or its substitute NEXT SENTENCE is ignored. If
    stment-2 is used, it executes. 
 stment-2 can
    contain a procedure branching or conditional statement. Control then
    transfers according to the rules of the statement. Otherwise, control
    passes to the end of the IF statement.
     - If there is no ELSE phrase, stment-1 is ignored. Control
    passes to the end of the IF statement.
    
 - If the ELSE NEXT SENTENCE phrase is present, stment-1 is
    ignored. Control passes to the next executable sentence.
  
  
   - An IF statement can appear in either or both stment-1 and
  stment-2. In this case, the IF statement is considered nested,
  because its scope is entirely within the scope of another IF statement.
  
 - IF statements within IF statements are paired combinations,
  beginning with IF and ending with ELSE or END-IF; this pairing proceeds
  from left to right. Thus, an ELSE or END-IF phrase applies to the first
  preceding unpaired IF.
  
Additional References 
 
 
Examples 
 
 
  - No ELSE phrase:
 
  
    
       
      
IF ITEMA < 20
  MOVE "X" TO ITEMB.
 
 |   
  
    | ITEMA  | 
    ITEMB  | 
   
  
    | 
      4
     | 
    
      "X"
     | 
   
  
    | 
      35
     | 
    
      ?
     | 
   
  
    | 
      19
     | 
    
      "X"
     | 
   
 
   - With ELSE phrase:
  
  
		   |