Compaq COBOL
Reference Manual


Previous Contents Index

D.7 Body Group Presentation Rules

Figure D-3 points to the appropriate presentation rules for all permissible combinations of LINE NUMBER and NEXT GROUP clauses in CONTROL HEADING, DETAIL, and CONTROL FOOTING report groups.

Figure D-3 Body Group Presentation Rules


Body Group Presentation Rules

  1. Upper-limit rule:
    The first line number on which a body group can be presented is the first-detail-line value in the FIRST DETAIL phrase of the PAGE clause.
  2. Lower-limit rules:
    The last line number on which a CONTROL HEADING report group or DETAIL report group can be presented is the last-detail-line value in the LAST DETAIL phrase of the PAGE clause.
    The last line number on which a CONTROL FOOTING report group can be presented is the line number specified by the footing-line value in the FOOTING phrase of the PAGE clause.
  3. Fit test rules:
    1. If the value in LINE-COUNTER is less than the integer of the first absolute LINE NUMBER clause, then the body group will appear on the page on which the report is currently positioned.
      Otherwise, the RWCS executes page-advance processing. After the PAGE HEADING report group (if defined) has been processed, the RWCS determines whether the saved-next-group-integer location was set when the final body group was presented on the preceding page. (See final LINE-COUNTER setting rule 6a.) If saved-next-group-integer was not so set, the body group will be presented on the page on which the report is currently positioned. If saved-next-group-integer was so set, the RWCS:
      • Moves the saved-next-group-integer into LINE-COUNTER
      • Resets saved-next-group-integer to zero
      • Reapplies fit test rule 3a
    2. If a body group has been presented on the page on which the report is positioned, the RWCS computes a trial sum in a work location. The trial sum is computed by adding:
      • The contents of LINE-COUNTER
      • The integers of all LINE NUMBER clauses of the report group

      If the trial sum is not greater than the body group's lower-limit integer, then the report group is presented on the current page. If the trial sum exceeds the body group's lower-limit integer, then the RWCS executes page-advance processing. After the PAGE HEADING report group (if defined) has been processed, the RWCS reapplies fit test rule 3b.
      If no body group has yet been presented on the page on which the report is currently positioned, the RWCS determines whether the saved-next-group-integer location was set when the final body group was presented on the preceding page. (See final LINE-COUNTER setting rule 6a.)
      If saved-next-group-integer was not set, the body group appears on the page on which the report is currently positioned.
      If saved-next-group-integer was set, the RWCS:
      • Moves the saved-next-group-integer into LINE-COUNTER
      • Resets saved-next-group-integer to zero
      • Computes a trial sum in a work location

      The trial sum is computed by adding:
      • The contents of LINE-COUNTER
      • The integer 1
      • The integers of all but the first LINE NUMBER clause of the body group

      If the trial sum is not greater than the body group's lower-limit integer, then the body group is presented on the current page. If the trial sum exceeds the body group's lower-limit integer, then the RWCS executes page-advance processing. After the PAGE HEADING report group (if defined) has been processed, the RWCS presents the body group on that page.
    3. If a body group has been presented on the page on which the report is currently positioned, the RWCS executes page-advance processing. After the PAGE HEADING report group (if defined) has been processed, the RWCS reapplies Fit Test rule 3c.
      If no body group has yet been presented on the page on which the report is currently positioned, the RWCS determines whether the saved-next-group-integer location was set when the final body group was presented on the preceding page. (See final LINE-COUNTER setting rule 6a). If saved-next-group-integer was not set, the body group will be presented on the page on which the report is currently positioned. If saved-next-group-integer was set, the RWCS moves saved-next-group-integer into LINE-COUNTER and resets saved-next-group-integer to zero.
      If the value in LINE-COUNTER is less than the integer of the first absolute LINE NUMBER clause, the RWCS presents the body group on the page on which the report is currently positioned. Otherwise, the RWCS executes page-advance processing. After the PAGE HEADING report group (if defined) has been processed, the RWCS presents the body group on that page.
  4. First print line position rules:
    1. The first print line of the body group appears on the line number specified by the integer of its LINE NUMBER clause.
    2. The RWCS presents the first print line of the current body group on the line immediately following the line indicated by the value contained in LINE-COUNTER if these two conditions are true:
      • The value in LINE-COUNTER is equal to or greater than the line number specified by the first-detail-line value in the FIRST DETAIL phrase of the PAGE clause.
      • No body group has previously been presented on the page on which the report is currently positioned.

      The RWCS presents the first print line of the current body group on the line that is obtained by adding the contents of LINE-COUNTER and the integer of the first LINE NUMBER clause of the current body group if these two conditions are true:
      • The value in LINE-COUNTER is equal to or greater than the line number specified by the first-detail-line value in the FIRST DETAIL phrase of the PAGE clause.
      • A body group has previously been presented on the page to which the report is currently positioned.

      If the value in LINE-COUNTER is less than the line number specified by the first-detail-line value in the FIRST DETAIL phrase of the PAGE clause, then the RWCS presents the first print line of the body group on the line specified by the FIRST DETAIL phrase.
    3. The body group is not presented.
    4. The line number on which the RWCS presents the first print line is the sum of the contents of:
      • LINE-COUNTER
      • The integer of the first LINE NUMBER clause
  5. Next group rule:
    The integer of the absolute NEXT GROUP clause (next-group-line-num) must specify a line number that is: (a) not less than that specified in the FIRST DETAIL phrase of the PAGE clause, and (b) not greater than that specified in the FOOTING phrase of the PAGE clause.
  6. Final LINE-COUNTER setting rules:
    1. If the body group that has just been presented is a CONTROL FOOTING report group and if the CONTROL FOOTING report group is not associated with the highest level at which the RWCS detected a control break, then the final LINE-COUNTER setting is the line number on which the final print line of the CONTROL FOOTING report group was presented.
      If the line number on which the final print line of the body group was presented is less than the integer of the NEXT GROUP clause, then the RWCS places the NEXT GROUP integer into LINE-COUNTER as the final LINE-COUNTER setting. If the line number on which the final print line of the body group was presented is equal to or greater than the integer of the NEXT GROUP clause, then the RWCS places the line number specified by the FOOTING phrase of the PAGE clause into LINE-COUNTER as the final LINE-COUNTER setting. In addition, the RWCS places the NEXT GROUP integer into the saved-next-group-integer location.
    2. If the body group that has just been presented is a CONTROL FOOTING report group, and if the CONTROL FOOTING report group is not associated with the highest level at which the RWCS detected a control break, then the final LINE-COUNTER setting is the line number on which the final print line of the CONTROL FOOTING report group was presented.
      For all other cases the RWCS computes a trial sum in a work location. The trial sum is computed by adding:
      • The integer of the NEXT GROUP clause
      • The line number on which the final print line of the body group was presented

      If the sum is less than the line number specified by the footing-line value in the FOOTING phrase of the PAGE clause, then the RWCS places that sum into LINE-COUNTER as the final LINE-COUNTER setting.
      If the sum is equal to or greater than the line number specified by the footing-line value in the FOOTING phrase of the PAGE clause, then the RWCS places that line number into LINE-COUNTER as the final LINE-COUNTER setting.
    3. The final LINE-COUNTER setting is the line number on which the final print line of the CONTROL FOOTING report group was presented if:
      • The body group that has just been presented is a CONTROL FOOTING report group.
      • The CONTROL FOOTING report group is not associated with the highest level at which the RWCS detected a control break.

      For all other cases the RWCS places the line number specified by the footing-line value in the FOOTING phrase of the PAGE clause into LINE-COUNTER as the final LINE-COUNTER setting.
    4. The final LINE-COUNTER setting is the line number on which the final print line of the body group was presented.
    5. LINE-COUNTER is unaffected by the processing of a nonprintable body group.
    6. The final LINE-COUNTER setting is the line number on which the RWCS presents the final print line of the CONTROL FOOTING report group if:
      • The body group that has just been presented is a CONTROL FOOTING report group.
      • The CONTROL FOOTING report group is not associated with the highest level at which the RWCS detected a control break.

      For all other cases the RWCS uses the sum of these two items as the final LINE-COUNTER setting:
      • The line number on which the final print line was presented
      • The NEXT GROUP integer

D.8 PAGE FOOTING Group Presentation Rules

Figure D-4 shows the appropriate presentation rules for all permissible combinations of LINE NUMBER and NEXT GROUP clauses in a PAGE FOOTING report group.

Figure D-4 PAGE FOOTING Group Presentation Rules


The PAGE FOOTING Group Presentation Rules are:

  1. Upper-limit rule:
    The first line number on which the PAGE FOOTING report group can be presented is the line number obtained by adding:
  2. Lower-limit rule:
    The last line number on which the PAGE FOOTING report group can be presented is the line number specified by page-size of the PAGE clause.
  3. First print line position rules:
    1. The first print line of the PAGE FOOTING report group is presented on the line specified by the integer of its LINE NUMBER clause.
    2. The PAGE FOOTING report group is not presented.
  4. Next group rules:
    1. The NEXT GROUP integer must be greater than the line number on which the final print line of the PAGE FOOTING report group is presented. In addition, the NEXT GROUP integer must not be greater than the line number specified by the page-size value of the PAGE clause.
    2. The sum of the following two items must not be greater than the line number specified by page-size of the PAGE clause:
      • The NEXT GROUP integer
      • The line number on which the final print line of the PAGE FOOTING report group is presented
  5. Final LINE-COUNTER setting rules:
    1. The final LINE-COUNTER setting after the RWCS presents the PAGE FOOTING report group is the NEXT GROUP integer.
    2. The final LINE-COUNTER setting after the RWCS presents the PAGE FOOTING report group is the sum of:
      • The NEXT GROUP integer
      • The line number on which the final print line of the PAGE FOOTING report group was presented
    3. After the PAGE FOOTING report group is presented, the final LINE-COUNTER setting is the line number on which the final print line of the PAGE FOOTING report group was presented.
    4. LINE-COUNTER is unaffected by the processing of a nonprintable report group.

D.9 REPORT FOOTING Group Presentation Rules

Figure D-5 points to the appropriate presentation rules for all permissible combinations of LINE NUMBER and NEXT GROUP clauses in a REPORT FOOTING report group.

Figure D-5 REPORT FOOTING Group Presentation Rules


REPORT FOOTING Group Presentation Rules

  1. Upper-limit rules:
    1. The first line number on which the REPORT FOOTING report group can be presented is one greater than the final LINE-COUNTER setting established by the PAGE FOOTING report group if a PAGE FOOTING report group has been presented on the page on which the report is positioned.
      Otherwise, the first line number on which the REPORT FOOTING report group can be presented is the line number obtained by adding 1 and the footing-line value of the PAGE clause.
    2. The first line number on which the REPORT FOOTING report group can be presented is the line number specified by the HEADING phrase of the PAGE clause.

  2. Lower-limit rule:
    The last line number on which the REPORT FOOTING report group can be presented is the line number specified by the page-size value of the PAGE clause.
  3. First print line position rules:
    1. The first print line of the REPORT FOOTING report group is presented on the line specified by the integer of its LINE NUMBER clause.
    2. If the RWCS presents a PAGE FOOTING report group on the page to which the report is positioned, then the sum of the following two items defines the line number on which the RWCS presents the first print line of the REPORT FOOTING report group:
      • The final LINE-COUNTER setting established by the PAGE FOOTING report group
      • The integer of the first LINE NUMBER clause of the REPORT FOOTING report group

      Otherwise, the sum of the following two items defines the line number on which the RWCS presents the first print line of the REPORT FOOTING report group:
      • The integer of the first LINE NUMBER clause of the REPORT FOOTING report group
      • The line number specified by the footing-line value of the FOOTING phrase of the PAGE clause
    3. The NEXT PAGE phrase in the first absolute LINE NUMBER clause directs the REPORT FOOTING report group to appear on a page on which no other report group has been presented. The first print line of the REPORT FOOTING report group is presented on the line number specified by the integer of its LINE NUMBER clause.
    4. The line number on which the RWCS presents the first print line is the sum of:
      • The contents of LINE-COUNTER
      • The integer of the first LINE NUMBER clause
    5. The REPORT FOOTING report group is not presented.
  4. Final LINE-COUNTER setting rules:
    1. The final LINE-COUNTER setting is the line number on which the RWCS presents the final print line of the REPORT FOOTING report group.
    2. LINE-COUNTER is unaffected by the processing of a nonprintable report group.


Appendix E
RTL Routines for Accessing the RAB and FAB Structures (OpenVMS Only)

In Compaq COBOL, when a file is successfully opened, the file's RAB pointer is placed in its RMS_STV field and its FAB pointer is placed in the FABPTR field of the RAB. The two RTL routines documented here (DCOB$RMS_CURRENT_RAB and DCOB$RMS_CURRENT_FAB) enable Compaq COBOL programmers to access the RAB and FAB data structures. However, the content and format of the RAB and FAB are not covered by any external standards (such as the ANSI standard for COBOL) and are subject to change.


DCOB$RMS_CURRENT_FAB


RETURNS

VMS usage: fab
type: longword (unsigned)
access: write only
mechanism: by reference

Arguments

None.

Description

DCOB$RMS_CURRENT_FAB returns the address of the RMS FAB structure for the most recently used COBOL file connector. Some fields of the FAB are filled in by the RMS SYS$OPEN routine.

This routine can be used to obtain the address of the RMS FAB structure. The FAB is filled in by SYS$OPEN to reflect the actual attributes of the file in the cases where the actual attributes differ from the attributes specified by the COBOL file connector.

The FAB is a structure used internally by the Compaq COBOL run-time system to implement COBOL semantics. Modification of the FAB can result in abnormal program behavior, including unexpected program termination.


Example

See the example for DCOB$RMS_CURRENT_RAB.


DCOB$RMS_CURRENT_RAB


RETURNS

VMS usage: rab
type: longword (unsigned)
access: write only
mechanism: by reference

Arguments

None.

Description

DCOB$RMS_CURRENT_RAB returns the address of the RMS RAB structure for the most recently used COBOL file connector.

This routine can be used to obtain the address of the RMS RAB structure. The RAB describes attributes of the connection to a file.

The RAB is a structure used internally by the Compaq COBOL run-time system to implement COBOL semantics. Modification of RAB fields can result in abnormal program behavior, including unexpected program termination.


Example


*+ 
* PROGRAM : RMSEXAMPLE 
* 
* PROGRAM DESCRIPTION: 
* 
*       This program is an example of use of DCOB$RMS_CURRENT_FAB 
*   and DCOB$RMS_CURRENT_RAB. 
* 
*- 
IDENTIFICATION DIVISION. 
PROGRAM-ID. RMSEXAMPLE. 
 
ENVIRONMENT DIVISION. 
INPUT-OUTPUT SECTION. 
FILE-CONTROL. 
    SELECT EMPLOYEE-FILE 
     ASSIGN TO "employee.dat" 
     ORGANIZATION IS SEQUENTIAL. 
 
 
DATA DIVISION. 
FILE SECTION. 
FD EMPLOYEE-FILE 
    BLOCK CONTAINS 2048 CHARACTERS. 
01 EMPLOYEE. 
    03 NAME PIC X(30). 
    03 OFFICE PIC X(10). 
    03 PHONE PIC X(10). 
 
WORKING-STORAGE SECTION. 
01  EMPLOYEE-FAB USAGE IS POINTER. 
01  EMPLOYEE-RAB USAGE IS POINTER. 
 
PROCEDURE DIVISION. 
P0. 
* 
* Open the file to establish EMPLOYEE-FILE as the current file. 
* 
    OPEN INPUT EMPLOYEE-FILE. 
 
* 
* Get the pointer to the RMS FAB structure for EMPLOYEE-FILE.  Store 
* the pointer in EMPLOYEE-FAB.  Do the same for the RAB. 
* 
    CALL "DCOB$RMS_CURRENT_FAB" GIVING EMPLOYEE-FAB. 
    CALL "DCOB$RMS_CURRENT_RAB" GIVING EMPLOYEE-RAB. 
 
* 
* Pass the address of the FAB to a subroutine that will use 
* the contents. 
* 
    CALL "PRINT-FIELDS" USING BY VALUE EMPLOYEE-FAB EMPLOYEE-RAB. 
 
* 
* CLOSE the file before exiting. 
* 
    CLOSE EMPLOYEE-FILE. 
    STOP RUN. 
END PROGRAM RMSEXAMPLE. 
IDENTIFICATION DIVISION. 
PROGRAM-ID. PRINT-FIELDS. 
 
DATA DIVISION. 
WORKING-STORAGE SECTION. 
01 TEMP-W. 
    03 TEMP-WORD PIC S9(4) COMP. 
01 TEMP-W1 REDEFINES TEMP-W. 
    03 TEMP-B1 PIC X. 
    03 TEMP-B2 PIC X. 
 
LINKAGE SECTION. 
01 FAB. 
  05 FAB_ID     PIC S9(9) COMP VALUE 20483. 
  05 FOP        PIC S9(9) COMP. 
  05 STS        PIC S9(9) COMP. 
  05 STV        PIC S9(9) COMP. 
  05 ALQ        PIC S9(9) COMP. 
  05 DEQ        PIC S9(4) COMP. 
  05 FAC        PIC X. 
  05 SHR        PIC X. 
  05 CTX        PIC S9(9) COMP. 
  05 RTV        PIC X. 
  05 ORG        PIC X. 
  05 RAT        PIC X. 
  05 RFM        PIC X. 
  05 JNL        PIC S9(9) COMP. 
  05 XAB-ADD    USAGE IS POINTER. 
  05 NAM-ADD    USAGE IS POINTER. 
  05 FNA        USAGE IS POINTER. 
  05 DNA        USAGE IS POINTER. 
  05 FNS        PIC X. 
  05 DNS        PIC X. 
  05 MRS        PIC S9(4) COMP. 
  05 MRN        PIC S9(9) COMP. 
  05 BLS        PIC S9(4) COMP. 
  05 FILLER     PIC X(18). 
01 RAB. 
  05 RAB_ID PIC S9(9) COMP VALUE 17409. 
  05 ROP PIC S9(9) COMP. 
  05 STS PIC S9(9) COMP. 
  05 STV PIC S9(9) COMP. 
  05 RFA PIC S9(4) COMP OCCURS 3 TIMES. 
  05 RESERVED   PIC S9(4) COMP. 
  05 CTX PIC S9(9) COMP. 
  05 RAC PIC X. 
  05 TMO PIC X. 
  05 USZ PIC S9(4) COMP. 
  05 RSZ PIC S9(4) COMP. 
  05 UBF PIC S9(9) COMP. 
  05 RBF PIC S9(9) COMP. 
  05 RHB PIC S9(9) COMP. 
  05 KBF PIC S9(9) COMP. 
  05 KSZ PIC X. 
  05 KRF PIC X. 
  05 MBF        PIC X. 
  05 MBC PIC X. 
  05 BKT PIC S9(9) COMP. 
  05 FABPTR PIC S9(9) COMP. 
  05 XAB PIC S9(9) COMP. 
 
PROCEDURE DIVISION USING FAB RAB. 
* 
* Convert the MBF PIC X value to a PIC S9(5) COMP VALUE. 
* 
    MOVE 0 TO TEMP-WORD. 
    MOVE MBF TO TEMP-B1. 
 
* 
* Display the multibuffer count and file allocation. 
* 
    DISPLAY "Multibuffer count is " TEMP-WORD WITH CONVERSION " blocks". 
    DISPLAY "File allocation is " ALQ WITH CONVERSION. 
 
    EXIT PROGRAM. 
END PROGRAM PRINT-FIELDS. 
 
      

Output:


$ 
$ LINK RMSEXAMPLE 
$ RUN RMSEXAMPLE 
File allocation is       1206 
$                               <>                         
      


Previous Next Contents Index