home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
clarion
/
ppstpx.zip
/
OM7.TPX
< prev
next >
Wrap
Text File
|
1993-06-08
|
54KB
|
1,258 lines
#!------------------------------------------------------------------------------
#!
#! OM7.TPX
#!
#! Report Print a report from a file
#!
#!------------------------------------------------------------------------------
#!
#PROCEDURE(Report,'Print a Report'),REPORT,SCREEN
#!------------------------------------------------------------------------------
#!
#! The Report Template
#!
#! This procedure template is designed to print most reports an application
#! may require. Secondary file relationships (1:MANY) are handled by the
#! %RptGetRelatedRecords #GROUP code, which recurses through as many levels
#! of 1:MANY relationships as are defined in the File Schematic, starting
#! with the Primary file, going down the chain of Secondary files beginning
#! with the first Child file of the Primary. Any other Child files of the
#! Primary file begin a second 1:MANY file chain -- this is not supported.
#!
#! The MANY:1 (lookup) relationships go only one level below the file it is
#! related to, for every 1:MANY (Parent-Child) relationship at each level (a
#! lookup file may not generate a second lookup from it -- write embedded
#! source code for this).
#!
#! This File Schematic is directly supported:
#! Primary
#! └──Secondary (Lookup MANY:1 from Primary)
#! └──Secondary (Lookup MANY:1 from Primary)
#! └─Secondary (Child File of Primary)
#! └──Secondary (Lookup MANY:1 from Secondary Child)
#! └──Secondary (Lookup MANY:1 from Secondary Child)
#! └─Secondary (Child File of Secondary Child)
#! └──Secondary (Lookup MANY:1 from Secondary Child)
#!
#! This File Schematic is NOT directly supported:
#! Primary
#! └──Secondary (Lookup File from Primary)
#! │ └─Secondary (Child of Lookup File) -- NO Children of Lookups
#! └─Secondary (Child File of Primary)
#! │ └──Secondary (Lookup File from Secondary Child)
#! │ └──Secondary (Lookup File from Lookup File) -- NO 2nd Lookups
#! └─Secondary (Another Child File of Primary) -- NO 2nd Child chains
#!
#! Formula Classes supported are:
#! The prefix of a Parent or Child file with :FILTER appended (Pre:FILTER).
#! Creates a record filter to skip records in which the filter
#! expression does not evaluate as true, just after the file's record
#! is read.
#! The name of a Parent or Child file (not a Lookup file).
#! Calculates the formula after each read from the file -- this is
#! immediately after any Pre:FILTER is evaluated.
#! No class --
#! Calculates the formula every time a record is read from any file.
#!
#! Multi-Up labels are supported -- they must be in the Body Detail band.
#! Group Breaks are supported -- up to four per file (Primary or Child
#! Secondary -- not on Lookups).
#!
#!------------------------------------------------------------------------------
#PROTOTYPE('')
#DISPLAY(' ')
#PROMPT('Enable ESC Key Abort',CHECK),%EscapeAbort
#PROMPT('Show Report Progress',CHECK),%ProgressScreen
#PROMPT('Primary File &Access',OPTION),%AccessMethod
#PROMPT('Keyed Order',RADIO)
#PROMPT('Record Order',RADIO)
#PROMPT('Range &Limit Field',COMPONENT),%KeyComponent
#PROMPT('Range &Value Field',FIELD),%ScopeValue
#PROMPT('Red&irect Procedure',PROCEDURE),%RedirectProc
#PROMPT('View Procedure',PROCEDURE),%ViewProc
#INSERT(%RptSetMultiples)
#INSERT(%ReportErrorCheck)
#INSERT(%StandardHeader)
%Procedure PROCEDURE
#INSERT(%LocalPPSVariables) #<! Declare Variables PPS
%LocalData
#INSERT(%ReportDataDeclares) #!Internal data declarations
#IF(%ProgressScreen)
%ScreenStructure
#ENDIF
%ReportStructure
#EMBED('Data Section')
CODE
ProcedureName = '%Procedure' #<!Fill ProcedureName var. PPS
#EMBED('Setup Procedure')
#INSERT(%OpenPrimary) #!Open primary
#INSERT(%OpenSecondaryFiles) #! and all secondary files
#IF(%RedirectProc) #!Runtime report redirection
%RedirectProc #<!Call redirection procedure
CASE GLO:FileSpec !Detect redirection selection
OF 'CANCEL' !Cancel report requested
RETURN
#IF(%ViewProc)
OF 'SCREEN' !Screen view requested
Temp" = COMMAND('CLATMP',0) !Get temporary file directory
IF NOT Temp" !None set?
Temp" = 'TempRpt.$$$' !Assign temporary filename
ELSIF SUB(CLIP(Temp"),-1,1) = '\'
Temp" = CLIP(Temp") & 'TempRpt.$$$' !Assign temporary filename
ELSE
Temp" = CLIP(Temp") & '\' & 'TempRpt.$$$' !Assign temporary filename
END
ReportDevice = Temp"
GLO:FileSpec = Temp"
#ELSE #!Redirect w/o View Proc
OF 'SCREEN' !Screen view requested
RETURN ! w/o View Procedure
#ENDIF
ELSE !All other report devices
ReportDevice = GLO:FileSpec ! go to the device
Temp" = SUB(LEFT(UPPER(GLO:FileSpec)),1,3) !Get first three characters
IF (Temp" = 'LPT' OR Temp" = 'COM') AND NUMERIC(SUB(LEFT(GLO:FileSpec),4,1))
IF Temp" = 'LPT' and NOT STATUS(GLO:FileSpec) !Check printer status
GLO:Message1 = 'The Printer is Off-Line!'
GLO:Message2 = 'Please correct this situation'
ShowWarning !Notify the user if off-line
RETURN
END
GLO:FileSpec = '' !Disable viewing
END
END
#ELSIF(%ViewProc) #!View w/o Redirect Proc
Temp" = SUB(LEFT(UPPER(%ReportDevice)),1,3) #<!Get first three characters
IF (Temp" = 'LPT' OR Temp" = 'COM') AND NUMERIC(SUB(LEFT(%ReportDevice),4,1))
IF Temp" = 'LPT' and NOT STATUS(%ReportDevice) #<!Check printer status
GLO:Message1 = 'The Printer is Off-Line!'
GLO:Message2 = 'Please correct this situation'
ShowWarning !Notify the user if off-line
RETURN
END
GLO:FileSpec = '' !Disable viewing
ELSE
GLO:FileSpec = ReportDevice !Set up filename for %ViewProc
END ! port selections
#ELSE #!No View or Redirect Proc
Temp" = SUB(LEFT(UPPER(%ReportDevice)),1,3) #<!Get first three characters
IF (Temp" = 'LPT' OR Temp" = 'COM') AND NUMERIC(SUB(LEFT(%ReportDevice),4,1))
IF Temp" = 'LPT' and NOT STATUS(%ReportDevice) #<!Check printer status
GLO:Message1 = 'The Printer is Off-Line!'
GLO:Message2 = 'Please correct this situation'
ShowWarning !Notify the user if off-line
RETURN
END
END ! port selections
#ENDIF
OPEN(%Report) #<!Prepare to print report
#EMBED('After Report OPEN before Title page')
#IF(%ReportTitle) #!Print Title Page
PRINT(%ReportPre:%ReportTitle) #<!Print Title Page
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
#ENDIF
#IF(%AccessMethod = 'Record Order') #!Determine primary file order
SET(%Primary) #<!Top of file, record order
#ELSIF(%SelectorAccess)
#FIX(%File,%Primary)
#FIX(%Key,%PrimaryKey)
#IF(%KeyIndex = 'INDEX')
#IF(%SharedFiles)
LOCK(%Primary,1) #<!Exclusive access for build
IF DiskError('Cannot Lock %Primary ') THEN RETURN. !Check for lock error
#ENDIF
BUILD(%PrimaryKey) #<!Build the index first
#IF(%SharedFiles)
UNLOCK(%Primary) #<!Unlock locked file
#ENDIF
#ENDIF
%KeyComponent = %ScopeValue
#EMBED('Immediately before SET(key,key)')
SET(%PrimaryKey,%PrimaryKey) #<!Beginning of selected records
#ELSE
#FIX(%File,%Primary)
#FIX(%Key,%PrimaryKey)
#IF(%KeyIndex = 'INDEX')
#IF(%SharedFiles)
LOCK(%Primary,1) #<!Exclusive access for build
IF DiskError('Cannot Lock %Primary ') THEN RETURN. !Check for lock error
#ENDIF
BUILD(%PrimaryKey) #<!Built the index first
#IF(%SharedFiles)
UNLOCK(%Primary) #<!Unlock locked file
#ENDIF
#ENDIF
SET(%PrimaryKey) #<!Top of file, keyed order
#ENDIF
#IF(%ProgressScreen)
OPEN(Screen)
#ENDIF
#EMBED('Before primary LOOP after SET')
LOOP #<!Primary file process loop
#EMBED('Top of primary LOOP')
NEXT(%Primary) #<!Get each %Primary record
IF ERRORCODE() THEN ErrEndFileFlag# = 1 ELSE ErrEndFileFlag# = 0. !Flag EOF
#EMBED('In primary LOOP immediately after NEXT')
#SET(%CurrentFile,%Primary)
#INSERT(%GroupBreakNumber)
#IF(%GroupCounter)
#FIX(%File,%Primary)
#SET(%CodePosition,(%FilePre&':FILTER'))
#INSERT(%RptRecordFilter) #!Generate record filter
#EMBED('In primary LOOP after Record Filter before Lookups')
#SET(%GetLookupFrom,%Primary)
#INSERT(%RptGetLookupRecords) #!Get all Lookup records
#SET(%CodePosition,%Primary) #!Class = primary file
#INSERT(%ReportFormulas) #!Generate formulas
#INSERT(%PrimaryFileGroupBrk)
#ELSE #!No group break on this file
#IF(%SelectorAccess) #!If record selector
IF %KeyComponent <> %ScopeValue | #<!Past selected records?
OR ErrEndFileFlag# #<!End of file? Terminate report
BREAK
END
#FIX(%File,%Primary)
#SET(%CodePosition,(%FilePre&':FILTER'))
#INSERT(%RptRecordFilter) #!Generate record filter
#EMBED('In primary LOOP after Record Filter before Lookups')
#SET(%GetLookupFrom,%Primary)
#INSERT(%RptGetLookupRecords) #!Get all Lookup records
#SET(%CodePosition,%Primary) #!Class = primary file
#INSERT(%ReportFormulas) #!Generate formulas
#ELSE #!No record selector
IF ErrEndFileFlag# THEN BREAK. #<!End of file? Terminate report
#FIX(%File,%Primary)
#SET(%CodePosition,(%FilePre&':FILTER'))
#INSERT(%RptRecordFilter) #!Generate record filter
#EMBED('In primary LOOP after Record Filter before Lookups')
#SET(%GetLookupFrom,%Primary)
#INSERT(%RptGetLookupRecords) #!Get all Lookup records
#SET(%CodePosition,%Primary) #!Class = primary file
#INSERT(%ReportFormulas) #!Generate formulas
#ENDIF
#ENDIF
#EMBED('In primary LOOP after Lookups')
#IF(%SecondaryExist) #!If there are secondary files
#SET(%GetRelatedTo,%Primary)
#INSERT(%RptGetRelatedRecords)
#ENDIF
#IF(%DetailPrinted <> 'PRINTED') #!If detail print not generated
#INSERT(%PrintDetail)
#INSERT(%RptAbortKey) #!Insert ESC key abort loop
#ENDIF
END #<!End %Primary file loop
#IF(%DetailPrinted <> 'PRINTED') #!If detail print not generated
#IF(%ReportLabel)
IF SAV::LabelCounter <> 0 #<!If any labels left to print
%ReportDetailPre
PRINT(%ReportPre:%ReportDetail) #<!Print last line item detail
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
%ReportDetailPost
END
#ENDIF
#ENDIF
#EMBED('After primary LOOP before grand totals & final page')
#IF(%ReportGrand) #!Print grand totals
PRINT(%ReportPre:%ReportGrand) #<!Print grand totals
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
#ENDIF
#IF(%ReportFinal) #!Print final page
PRINT(%ReportPre:%ReportFinal) #<!Print final page
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
#ENDIF
#SET(%ResetTotalType,'NONE') #!Reset report totals
#INSERT(%ResetTotals)
CLOSE(%Report) #<!Close report
#IF(%ProgressScreen)
CLOSE(Screen) #<!Close report progress screen
#ENDIF
#IF(%ViewProc)
%ViewProc #<!Call View Procedure
#ENDIF
#EMBED('End of Procedure')
#INSERT(%FileMgrExit) #!Insert File Manager Exit PPS
#INSERT(%TotalRoutines) #!Total tallys and resets
#INSERT(%SaveFooterRoutine) #!Footer save field saves
#INSERT(%PrintFooterRoutine) #!Footer save field saves
#INSERT(%RestoreFooterRoutine) #!Footer save field saves
#!***************************************************************************
#GROUP(%ReportDataDeclares) #!Internal data declarations
#FOR(%ReportGroup) #!Group break fields
#IF(%ReportGroup <> %KeyComponent) #!Group break fields
SAV::%ReportGroup LIKE(%ReportGroup) #<!Group break save
#ENDIF
#ENDFOR
#SET(%Counter1,%NULL)
#FOR(%ReportTotal) #!AVERAGE total fields
#SET(%Counter1,(%Counter1 + 1))
#IF(%ReportTotalType = 'AVERAGE')
#IF(INSTRING('[',%ReportTotalField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportTotalField,1,INSTRING('[',%ReportTotalField,1,1)-1)))
%ReportTotal::Cnt::%ArrayField::%Counter1 LONG !Average total count
%ReportTotal::Sum::%ArrayField::%Counter1 REAL !Average total sum
#ELSE
%ReportTotal::Cnt::%ReportTotalField LONG #<!Average total count
%ReportTotal::Sum::%ReportTotalField REAL !Average total sum
#ENDIF
#ENDIF
#ENDFOR
#SET(%SaveFilesQueue,%NULL)
#FOR(%ReportSave) #!Build list of the files
#FOR(%ReportSaveField) #! of footer save fields
#SET(%Temp,(SUB(%ReportSaveField,1,INSTRING(':',%ReportSaveField,1,1)-1)))
#IF(NOT INSTRING(UPPER(%Temp),%SaveFilesQueue,1,1))
#SET(%SaveFilesQueue,(%SaveFilesQueue & UPPER(%Temp) & ','))
#ENDIF
#ENDFOR
#ENDFOR
#SET(%Counter1,%NULL)
#SET(%Counter2,%NULL)
#FOR(%ReportSave) #!Footer save fields
#SET(%Counter1,(%Counter1 + 1))
#FOR(%ReportSaveField)
#SET(%Counter2,(%Counter2 + 1))
#IF(INSTRING('[',%ReportSaveField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportSaveField,1,INSTRING('[',%ReportSaveField,1,1)-1)))
#SET(%BreakField,%ReportSaveField)
#INSERT(%RptFindFile)
#FIX(%File,%FoundFile)
#FIX(%Field,%ArrayField)
#IF(%FieldType = 'STRING' OR %FieldType = 'CSTRING' OR %FieldType = 'PSTRING')
SAV1::%ReportSave::%Field::%Counter1::%Counter2 STRING(SIZE(%ReportSaveField)),AUTO #<!%ReportSave Footer save field
SAV2::%ReportSave::%Field::%Counter1::%Counter2 STRING(SIZE(%ReportSaveField)),AUTO #<!%ReportSave Footer save field
#ELSE
SAV1::%ReportSave::%Field::%Counter1::%Counter2 REAL,AUTO #<!%ReportSave Footer save field
SAV2::%ReportSave::%Field::%Counter1::%Counter2 REAL,AUTO #<!%ReportSave Footer save field
#ENDIF
#ELSE
SAV1::%ReportSave::%ReportSaveField LIKE(%ReportSaveField),AUTO #<!%ReportSave Footer save field
SAV2::%ReportSave::%ReportSaveField LIKE(%ReportSaveField),AUTO #<!%ReportSave Footer save field
#ENDIF
#ENDFOR
#ENDFOR
#FOR(%ReportTotal) #!Detect any PAGE total fields
#IF(%ReportTotalReset = 'PAGE')
#SET(%PageTotals,'YES') #!Set flag
#BREAK
#ELSIF(%ReportTotalTally = 'PAGE')
#SET(%PageTotals,'YES') #!Set flag
#BREAK
#ENDIF
#ENDFOR
#IF(%PageTotals = 'YES')
SAV::LineCounter SHORT #<!Line counter save
#ENDIF
#IF(%SelectorAccess) #!Record selector save
SAV::%KeyComponent LIKE(%KeyComponent) #<!Record selector save
#ENDIF
#IF(%ReportLabel) #!Multi-up label USE variables
SAV::LabelCounter BYTE #<!Multi-up label counter
#SET(%Counter1,%NULL)
#FOR(%ReportLabelField)
#SET(%Counter1,(%Counter1 + 1))
#IF(INSTRING('[',%ReportLabelField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportLabelField,1,INSTRING('[',%ReportLabelField,1,1)-1)))
#SET(%BreakField,%ReportLabelField)
#INSERT(%RptFindFile)
#FIX(%File,%FoundFile)
#FIX(%Field,%ArrayField)
#IF(%FieldType = 'STRING' OR %FieldType = 'CSTRING' OR %FieldType = 'PSTRING')
LBL::%ArrayField::%Counter1 STRING(SIZE(%ReportLabelField)),DIM(%ReportLabel) #<!Multi-up label USE variables
#ELSE
LBL::%ArrayField::%Counter1 REAL,DIM(%ReportLabel) #<!Multi-up label USE variables
#ENDIF
#ELSE
LBL::%ReportLabelField LIKE(%ReportLabelField),DIM(%ReportLabel) #<!Multi-up label USE variables
#ENDIF
#ENDFOR
#ENDIF
#!
#!***************************************************************************
#GROUP(%RptGetLookupRecords) #!Get all lookup records
#FOR(%Secondary) #!%GetLookupFrom must be set
#IF(%SecondaryTo = %GetLookupFrom) #! before #INSERT of this group
#IF(%SecondaryType = 'MANY:1') #!Check for Lookup files
#FIX(%File,%SecondaryTo)
#FIX(%Relation,%Secondary)
#FOR(%RelationKeyField)
%RelationKeyField = %RelationKeyFieldLink #<!Assign linking field value
#ENDFOR
GET(%Secondary,%RelationKey) #<!Lookup record
#FIX(%File,%Secondary)
IF ERRORCODE() THEN CLEAR(%FilePre:Record). #<!Clear record if unsuccessful
#SET(%SaveFile,%Secondary) #!Check for footer save fields
#INSERT(%SaveFooterFields)
#ENDIF
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%RptGetRelatedRecords) #!Get all related records
#FOR(%Secondary) #!%GetRelatedTo must be set
#IF(%SecondaryTo = %GetRelatedTo) #! before #INSERT of this group
#IF(%SecondaryType = '1:MANY') #!Check for children files
#FIX(%File,%SecondaryTo)
#FIX(%Relation,%Secondary)
#FOR(%RelationKeyField)
#IF(%RelationKeyFieldLink)
%RelationKeyField = %RelationKeyFieldLink #<!Assign linking field value
#SET(%RelateBreakField,%RelationKeyField)
#SET(%RelateBreakFieldLink,%RelationKeyFieldLink)
#ELSE
CLEAR(%RelationKeyField) #<!Clear non-linking field
#ENDIF
#ENDFOR
SET(%RelationKey,%RelationKey) #<!Set to first related record
LOOP #<!Loop through %Secondary
NEXT(%Secondary) #<! getting each record
IF ERRORCODE() THEN ErrEndFileFlag# = 1 ELSE ErrEndFileFlag# = 0. !Flag EOF
#SET(%CurrentFile,%Secondary)
#INSERT(%GroupBreakNumber)
#IF(%GroupCounter)
#FIX(%File,%Secondary)
#SET(%CodePosition,(%FilePre&':FILTER'))
#INSERT(%RptRecordFilter)
#SET(%GetLookupFrom,%Secondary)
#INSERT(%RptGetLookupRecords) #!Get all Lookup records
#SET(%CodePosition,%Secondary) #!Class = primary file
#INSERT(%ReportFormulas) #!Generate formulas
#SET(%GetRelatedTo,%Secondary) #!Recursive call to this group
#SET(%SaveFile,%Secondary) #!Check for footer save fields
#INSERT(%SaveFooterFields)
#SET(%PassField1,%GroupField1)
#SET(%PassField2,%RelateBreakField)
#SET(%PassField3,%RelateBreakFieldLink)
#INSERT(%GroupBreakSelect)
#ELSE #!No group break on this file
#SET(%SaveFile,%Secondary) #!Check for footer save fields
#INSERT(%SaveFooterFields)
IF %RelateBreakField <> %RelateBreakFieldLink | #<!Past related Records?
OR ErrEndFileFlag# #<! or End of file?
BREAK #<!Break loop
END
#FIX(%File,%Secondary)
#SET(%CodePosition,(%FilePre&':FILTER'))
#INSERT(%RptRecordFilter)
#SET(%GetLookupFrom,%Secondary)
#INSERT(%RptGetLookupRecords) #!Get all Lookup records
#SET(%CodePosition,%Secondary) #!Class = primary file
#INSERT(%ReportFormulas) #!Generate formulas
#SET(%GetRelatedTo,%Secondary) #!Recursive call to this group
#ENDIF
#INSERT(%RptGetRelatedRecords) #! to get next level deep
#IF(%DetailPrinted <> 'PRINTED')
#INSERT(%PrintDetail) #! in footer fields
#INSERT(%RptAbortKey) #!Insert ESC key abort loop
#SET(%DetailPrinted,'PRINTED') #!Set detail print flag OFF
#ENDIF
END #<!End %Secondary Loop
#ENDIF
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%PrintDetail)
#IF(%ReportLabel)
#INSERT(%MultiUpLabelBuild)
#ENDIF
%ReportDetailPre
#IF(%ReportDetail)
PRINT(%ReportPre:%ReportDetail) #<!Print line item detail
#ENDIF
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
%ReportDetailPost
#IF(%PageTotals) #!Any page total fields?
IF SAV::LineCounter > %ReportLine #<!Page overflow?
#SET(%ResetTotalType,'PAGE') #!Reset page totals
#INSERT(%ResetTotals)
#SET(%TallyType,'PAGE') #!Tally page totals
#INSERT(%TallyTotals)
END
SAV::LineCounter = %ReportLine #<!Save line counter
#ENDIF
#SET(%TallyType,'ALL') #!For totals on ALL
#INSERT(%TallyTotals) #!Tally total fields
#IF(%ReportLabel)
#INSERT(%MultiUpLabelReset)
#ENDIF
#!
#!***************************************************************************
#GROUP(%TotalRoutines) #!Total field routines
#FOR(%ReportTotal)
#IF(%ReportTotalTally = 'PAGE')
Tally::PAGE::Totals ROUTINE #<!Tallys on page break
#SET(%TallyType,'PAGE')
#INSERT(%DoTallyTotals)
#BREAK
#ENDIF
#ENDFOR
#FOR(%ReportTotal)
#IF(%ReportTotalTally = 'ALL')
Tally::ALL::Totals ROUTINE #<!Tallys on body detail
#SET(%TallyType,'ALL')
#INSERT(%DoTallyTotals)
#BREAK
#ENDIF
#ENDFOR
#FOR(%ReportGroup)
#FOR(%ReportTotal)
#IF(%ReportTotalTally = %ReportGroup)
Tally::%ReportTotalTally::Totals ROUTINE #<!Tallys on group break
#SET(%TallyType,%ReportTotalTally)
#INSERT(%DoTallyTotals)
#BREAK
#ENDIF
#ENDFOR
#ENDFOR
#FOR(%ReportTotal)
#IF(%ReportTotalReset = 'PAGE')
Reset::PAGE::Totals ROUTINE #<!Resets on page break
#SET(%ResetTotalType,'PAGE')
#INSERT(%DoResetTotals)
#BREAK
#ENDIF
#ENDFOR
#FOR(%ReportTotal)
#IF(%ReportTotalReset = 'NONE')
Reset::NONE::Totals ROUTINE #<!Resets on report close
#SET(%ResetTotalType,'NONE')
#INSERT(%DoResetTotals)
#BREAK
#ENDIF
#ENDFOR
#FOR(%ReportGroup)
#FOR(%ReportTotal)
#IF(%ReportTotalReset = %ReportGroup)
Reset::%ReportTotalReset::Totals ROUTINE #<!Resets on group break
#SET(%ResetTotalType,%ReportTotalReset)
#INSERT(%DoResetTotals)
#BREAK
#ENDIF
#ENDFOR
#ENDFOR
#!
#!***************************************************************************
#GROUP(%DoTallyTotals) #!Tally total fields
#SET(%Counter1,%NULL) #!%TallyType must be set
#FOR(%ReportTotal) #! before #INSERT this group
#SET(%Counter1,(%Counter1 + 1))
#IF(%ReportTotalTally = %TallyType)
#IF(%ReportTotalType = 'SUM')
%ReportPre:%ReportTotal += %ReportTotalField #<!SUM total of %ReportTotalField
#ELSIF(%ReportTotalType = 'COUNT')
%ReportPre:%ReportTotal += 1 #<!COUNT total of %ReportTotalField
#ELSIF(%ReportTotalType = 'HIGH')
IF %ReportTotalField > %ReportPre:%ReportTotal #<!HIGH value of %ReportTotalField
%ReportPre:%ReportTotal = %ReportTotalField
END
#ELSIF(%ReportTotalType = 'LOW')
IF %ReportTotalField < %ReportPre:%ReportTotal #<!LOW value of %ReportTotalField
%ReportPre:%ReportTotal = %ReportTotalField
END
#ELSIF(%ReportTotalType = 'AVERAGE')
#IF(INSTRING('[',%ReportTotalField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportTotalField,1,INSTRING('[',%ReportTotalField,1,1)-1)))
%ReportTotal::Cnt::%ArrayField::%Counter1 += 1 !AVERAGE of %ReportTotalField
%ReportTotal::Sum::%ArrayField::%Counter1 += %ReportTotalField
%ReportPre:%ReportTotal = %ReportTotal::Sum::%ArrayField::%Counter1 / %ReportTotal::Cnt::%ArrayField::%Counter1
#ELSE
%ReportTotal::Cnt::%ReportTotalField += 1 #<!AVERAGE of %ReportTotalField
%ReportTotal::Sum::%ReportTotalField += %ReportTotalField
%ReportPre:%ReportTotal = %ReportTotal::Sum::%ReportTotalField / %ReportTotal::Cnt::%ReportTotalField
#ENDIF
#ENDIF
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%DoResetTotals) #!Reset total fields
#SET(%Counter1,%NULL) #!%ResetTotalType must be set
#FOR(%ReportTotal) #! before #INSERT this group
#SET(%Counter1,(%Counter1 + 1))
#IF(%ReportTotalReset = %ResetTotalType)
%ReportPre:%ReportTotal = 0
#IF(%ReportTotalType = 'AVERAGE')
#IF(INSTRING('[',%ReportTotalField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportTotalField,1,INSTRING('[',%ReportTotalField,1,1)-1)))
%ReportTotal::Cnt::%ArrayField::%Counter1 = 0
%ReportTotal::Sum::%ArrayField::%Counter1 = 0
#ELSE
%ReportTotal::Cnt::%ReportTotalField = 0
%ReportTotal::Sum::%ReportTotalField = 0
#ENDIF
#ENDIF
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%TallyTotals) #!Tally total fields
#FOR(%ReportTotal) #!%TallyType must be set
#IF(%ReportTotalTally = %TallyType) #! before #INSERT this group
DO Tally::%TallyType::Totals #<!Tally %TallyType totals
#BREAK
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%ResetTotals) #!Reset total fields
#FOR(%ReportTotal) #!%ResetTotalType must be set
#IF(%ReportTotalReset = %ResetTotalType) #! before #INSERT this group
DO Reset::%ResetTotalType::Totals #<!Reset %ResetTotalType totals
#BREAK
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%SaveFooterFields) #!Call footer save routines
#FOR(%ReportSave) #!%SaveFile must be set
#FOR(%ReportSaveField) #! before #INSERT this group
#IF(%ReportSaveField <> %ReportPage)
#SET(%BreakField,%ReportSaveField)
#INSERT(%RptFindFile)
#IF(%FoundFile = %SaveFile) #!Check for save file
DO Save::%SaveFile::FooterFields #<!Save %SaveFile footer fields
#SET(%Done,'YES')
#BREAK
#ELSE
#SET(%Done,%NULL)
#ENDIF
#ENDIF
#ENDFOR
#IF(%Done = 'YES')
#BREAK
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%SaveFooterRoutine) #!Rotate footer save fields
#SET(%Temp,(SUB(%SaveFilesQueue,1,INSTRING(',',%SaveFilesQueue,1,1)-1)))
#SET(%SaveFilesQueue,(SUB(%SaveFilesQueue,LEN(%Temp)+2,LEN(%SaveFilesQueue)-LEN(%Temp)+1)))
#IF(%Temp)
#FOR(%ReportSave)
#IF(%ReportSave <> 'PAGE')
#FOR(%ReportSaveField)
#IF(%Temp = UPPER(SUB(%ReportSaveField,1,INSTRING(':',%ReportSaveField,1,1)-1)))
#SET(%BreakField,%ReportSaveField)
#INSERT(%RptFindFile)
Save::%FoundFile::FooterFields ROUTINE #<!Save footer fields
#SET(%SaveFile,%FoundFile)
#INSERT(%SaveFooterAssigns)
#SET(%GetAssigns,'YES')
#BREAK
#ELSE
#SET(%GetAssigns,%NULL)
#ENDIF
#ENDFOR
#ENDIF
#IF(%GetAssigns)
#BREAK
#ENDIF
#ENDFOR
#INSERT(%SaveFooterRoutine)
#ENDIF
#!
#!***************************************************************************
#GROUP(%SaveFooterAssigns) #!Rotate footer save fields
#SET(%Counter1,%NULL)
#SET(%Counter2,%NULL)
#FOR(%ReportSave) #!%SaveFile must be set
#SET(%Counter1,(%Counter1 + 1))
#FOR(%ReportSaveField) #! before #INSERT this group
#IF(%ReportSaveField <> %ReportPage)
#SET(%Counter2,(%Counter2 + 1))
#IF(INSTRING('[',%ReportSaveField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportSaveField,1,INSTRING('[',%ReportSaveField,1,1)-1)))
#ELSE
#SET(%ArrayField,%NULL) #!Clear array flag
#ENDIF
#SET(%BreakField,%ReportSaveField)
#INSERT(%RptFindFile)
#IF(%FoundFile = %SaveFile) #!Check for save file
#IF(%ArrayField) #!Check for array element
SAV2::%ReportSave::%ArrayField::%Counter1::%Counter2 = SAV1::%ReportSave::%ArrayField::%Counter1::%Counter2
SAV1::%ReportSave::%ArrayField::%Counter1::%Counter2 = %ReportSaveField
#ELSE
SAV2::%ReportSave::%ReportSaveField = SAV1::%ReportSave::%ReportSaveField
SAV1::%ReportSave::%ReportSaveField = %ReportSaveField
#ENDIF
#ENDIF
#ENDIF
#ENDFOR
#ENDFOR
#!
#!***************************************************************************
#GROUP(%PrintFooterFields) #!Set footer to print correct
#FOR(%ReportSave) #! before #INSERT this group
#IF(%ReportSave = %WhichFooter) #!Check for save file
DO Print::%ReportSave::FooterFields #<!Print correct footer fields
#BREAK
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%PrintFooterRoutine) #!Set footer to print correct
#SET(%Counter1,%NULL) #! footer field values
#SET(%Counter2,%NULL)
#FOR(%ReportSave) #! before #INSERT this group
#IF(%ReportSave <> 'PAGE')
Print::%ReportSave::FooterFields ROUTINE #<!Print correct footer fields
#SET(%Counter1,(%Counter1 + 1))
#FOR(%ReportSaveField) #! before #INSERT this group
#SET(%Counter2,(%Counter2 + 1))
#IF(INSTRING('[',%ReportSaveField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportSaveField,1,INSTRING('[',%ReportSaveField,1,1)-1)))
%ReportSaveField = SAV2::%ReportSave::%ArrayField::%Counter1::%Counter2
#ELSE
%ReportSaveField = SAV2::%ReportSave::%ReportSaveField
#ENDIF
#ENDFOR
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%RestoreFooterFields) #!Restore changed footer
#FOR(%ReportSave) #! before #INSERT this group
#IF(%ReportSave = %WhichFooter) #!Check for save file
DO Restore::%ReportSave::FooterFields #<!Restore current footer fields
#BREAK
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%RestoreFooterRoutine) #!Restore changed footer
#SET(%Counter1,%NULL) #! footer field values
#SET(%Counter2,%NULL)
#FOR(%ReportSave) #! before #INSERT this group
#IF(%ReportSave <> 'PAGE')
Restore::%ReportSave::FooterFields ROUTINE #<!Restore current footer fields
#SET(%Counter1,(%Counter1 + 1))
#FOR(%ReportSaveField) #! before #INSERT this group
#SET(%Counter2,(%Counter2 + 1))
#IF(INSTRING('[',%ReportSaveField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportSaveField,1,INSTRING('[',%ReportSaveField,1,1)-1)))
%ReportSaveField = SAV1::%ReportSave::%ArrayField::%Counter1::%Counter2
#ELSE
%ReportSaveField = SAV1::%ReportSave::%ReportSaveField
#ENDIF
#ENDFOR
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%ReportFormulas) #!Generate formula field code
#FOR(%Formula) #!%CodePosition must be set
#! before #INSERT this group
#IF((UPPER(LEFT(%FormulaClass)) = UPPER(%CodePosition) OR %FormulaClass = %NULL) AND %FormulaType = 'COMPUTED')
%Formula = %FormulaComputation #<!%FormulaDescription
#ENDIF
#ENDFOR
#FOR(%Formula) #!All computed fields before
#IF((UPPER(LEFT(%FormulaClass)) = UPPER(%CodePosition) OR %FormulaClass = %NULL) AND %FormulaType = 'CONDITION')
IF %FormulaCondition #<!%FormulaDescription
%Formula = %FormulaTrue
ELSE
%Formula = %FormulaFalse
END
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%RptRecordFilter) #!Generate record filter code
#FOR(%Formula) #!%CodePosition must be set
#! and must contain the file
#! prefix followed by :FILTER
#IF(UPPER(LEFT(%FormulaClass)) = UPPER(%CodePosition))
#IF(%FormulaType = 'COMPUTED')
IF NOT (%FormulaComputation) #<!%FormulaDescription
CYCLE #<!%File record filter
END
#ELSE
IF NOT (%FormulaCondition) #<!%FormulaDescription
CYCLE #<!%File record filter
END
#ENDIF
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%GroupBreakNumber)
#SET(%GroupCounter,%NULL)
#SET(%GroupField1,%NULL)
#SET(%GroupField2,%NULL)
#SET(%GroupField3,%NULL)
#SET(%GroupField4,%NULL)
#FOR(%ReportGroup)
#SET(%BreakField,%ReportGroup)
#INSERT(%RptFindFile)
#IF(%FoundFile = %CurrentFile) #!Check breaks on current file
#SET(%GroupCounter,(%GroupCounter + 1))
#IF(%GroupCounter = 1)
#SET(%GroupField1,%BreakField)
#ELSIF(%GroupCounter = 2)
#SET(%GroupField2,%BreakField)
#ELSIF(%GroupCounter = 3)
#SET(%GroupField3,%BreakField)
#ELSIF(%GroupCounter = 4)
#SET(%GroupField4,%BreakField)
#ELSIF(%GroupCounter > 4)
#SET(%ErrorMessage,(%Procedure & ' ERROR:'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage,(' ' & %FoundFile & ' --Too many Group Breaks - 4/file Maximum'))
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%PrimaryFileGroupBrk)
#IF(%SelectorAccess) #!If record selector
#SET(%PassField1,%GroupField1)
#SET(%PassField2,%KeyComponent)
#SET(%PassField3,%ScopeValue)
#INSERT(%GroupBreakSelect)
#ELSE #!No record selector
#SET(%SaveFile,%Primary)
#INSERT(%SaveFooterFields)
IF NOT SAV::%GroupField1 AND NOT ErrEndFileFlag# #<!Print first group header
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakHeader) #!Print group header
#IF(%GroupField2)
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakHeader) #!Print group header
#ENDIF
#IF(%GroupField3)
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakHeader) #!Print group header
#ENDIF
#IF(%GroupField4)
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakHeader) #!Print group header
#ENDIF
ELSIF SAV::%GroupField1 AND ErrEndFileFlag# #<!Print last group footer
#IF(%GroupField4)
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakFooter) #!Print last group footer
#ENDIF
#IF(%GroupField3)
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakFooter) #!Print last group footer
#ENDIF
#IF(%GroupField2)
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakFooter) #!Print last group footer
#ENDIF
#IF(%GroupField1)
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakFooter) #!Print last group footer
#ENDIF
BREAK
ELSIF ErrEndFileFlag# #<!Print nothing - no records
BREAK
END
IF %GroupField1 <> SAV::%GroupField1 #<!Normal group break?
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakHeader) #!Print group header
END
#IF(%GroupField2)
IF %GroupField2 <> SAV::%GroupField2 #<!Normal group break?
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#IF(%GroupField3)
IF %GroupField3 <> SAV::%GroupField3 #<!Normal group break?
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#IF(%GroupField4)
IF %GroupField4 <> SAV::%GroupField4 #<!Normal group break?
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#ENDIF
#!
#!***************************************************************************
#GROUP(%GroupBreakSelect)
#IF(%PassField1 = %PassField2) #!1st Break field & link field same
IF %PassField2 <> %PassField3 | #<!Group Break?
OR ErrEndFileFlag# #<! or end of file?
IF SAV::%PassField1 #<!Print group footer
#IF(%ReportLabel)
IF SAV::LabelCounter <> 0 #<!If any labels left to print
%ReportDetailPre
PRINT(%ReportPre:%ReportDetail) #<!Print last line item detail
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
%ReportDetailPost
#INSERT(%MultiUpLabelReset)
END
#ENDIF
#IF(%GroupField4)
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakFooter) #!Print last group footer
CLEAR(SAV::%GroupField4) #<!Clear group print flag
#ENDIF
#IF(%GroupField3)
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakFooter) #!Print last group footer
CLEAR(SAV::%GroupField3) #<!Clear group print flag
#ENDIF
#IF(%GroupField2)
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakFooter) #!Print last group footer
CLEAR(SAV::%GroupField2) #<!Clear group print flag
#ENDIF
#IF(%GroupField1)
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakFooter) #!Print last group footer
CLEAR(SAV::%GroupField1) #<!Clear group print flag
#ENDIF
BREAK #<!Terminate report processing
ELSE #<!Print group header
BREAK
END
END
IF NOT SAV::%PassField1 #<!Print first group header
#IF(%GroupField1)
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakHeader) #!Print first group header
#ENDIF
#IF(%GroupField2)
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakHeader) #!Print first group header
#ENDIF
#IF(%GroupField3)
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakHeader) #!Print first group header
#ENDIF
#IF(%GroupField4)
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakHeader) #!Print first group header
#ENDIF
END
#IF(%GroupField2)
IF %GroupField2 <> SAV::%GroupField2 #<!Normal group break?
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#IF(%GroupField3)
IF %GroupField3 <> SAV::%GroupField3 #<!Normal group break?
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#IF(%GroupField4)
IF %GroupField4 <> SAV::%GroupField4 #<!Normal group break?
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#ELSE #!Break & link field not same
IF %PassField2 <> %PassField3 | #<!End of related records?
OR ErrEndFileFlag# #<! or end of file?
IF SAV::%PassField1 #<!Print last group footer
#IF(%ReportLabel)
IF SAV::LabelCounter <> 0 #<!If any labels left to print
%ReportDetailPre
PRINT(%ReportPre:%ReportDetail) #<!Print last line item detail
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
%ReportDetailPost
#INSERT(%MultiUpLabelReset)
END
#ENDIF
#IF(%GroupField4)
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakFooter) #!Print last group footer
CLEAR(SAV::%GroupField4) #<!Clear group print flag
#ENDIF
#IF(%GroupField3)
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakFooter) #!Print last group footer
CLEAR(SAV::%GroupField3) #<!Clear group print flag
#ENDIF
#IF(%GroupField2)
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakFooter) #!Print last group footer
CLEAR(SAV::%GroupField2) #<!Clear group print flag
#ENDIF
#IF(%GroupField1)
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakFooter) #!Print last group footer
CLEAR(SAV::%GroupField1) #<!Clear group print flag
#ENDIF
END
BREAK #<!Terminate loop
END
IF NOT SAV::%PassField1 #<!Print first group header
#IF(%GroupField1)
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakHeader) #!Print first group header
#ENDIF
#IF(%GroupField2)
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakHeader) #!Print first group header
#ENDIF
#IF(%GroupField3)
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakHeader) #!Print first group header
#ENDIF
#IF(%GroupField4)
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakHeader) #!Print first group header
#ENDIF
END
#IF(%GroupField1)
IF %GroupField1 <> SAV::%GroupField1 #<!Normal group break?
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField1)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#IF(%GroupField2)
IF %GroupField2 <> SAV::%GroupField2 #<!Normal group break?
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField2)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#IF(%GroupField3)
IF %GroupField3 <> SAV::%GroupField3 #<!Normal group break?
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField3)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#IF(%GroupField4)
IF %GroupField4 <> SAV::%GroupField4 #<!Normal group break?
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakFooter) #!Print group footer
#FIX(%ReportGroup,%GroupField4)
#INSERT(%GroupBreakHeader) #!Print group header
END
#ENDIF
#ENDIF
#!
#!***************************************************************************
#GROUP(%GroupBreakFooter) #!Print group footers
#SET(%ThisReportGroup,%ReportGroup) #!Save work Group
#SET(%WhichFooter,%ThisReportGroup) #!Ensure footer fields contain
#INSERT(%PrintFooterFields) #! correct values to print
#FIX(%ReportGroup,%ThisReportGroup) #!Fix to saved work Group
#SET(%CodePosition,%ThisReportGroup) #!Class = group break field
#INSERT(%ReportFormulas) #!Generate formulas
#FIX(%ReportGroup,%ThisReportGroup) #!Fix to saved work Group
%ReportGroupFooterPre
#IF(%ReportGroupFooter)
PRINT(%ReportPre:%ReportGroupFooter) #<!Print group footer
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
#ENDIF
%ReportGroupFooterPost
#SET(%WhichFooter,%ThisReportGroup) #!Ensure footer fields contain
#INSERT(%RestoreFooterFields) #!Restore saved footer fields
#IF(%PageTotals) #!Any footer save fields?
IF SAV::LineCounter > %ReportLine #<!Page overflow?
#SET(%ResetTotalType,'PAGE') #!Reset page totals
#INSERT(%ResetTotals)
#SET(%TallyType,'PAGE') #!Tally page totals
#INSERT(%TallyTotals)
END
SAV::LineCounter = %ReportLine #<!Save line counter
#ENDIF
#SET(%ResetTotalType,%ThisReportGroup) #!Reset group total fields
#INSERT(%ResetTotals)
#!
#!***************************************************************************
#GROUP(%GroupBreakHeader) #!Check for group breaks
#SET(%ThisReportGroup,%ReportGroup) #!Save work Group
%ReportGroupHeaderPre
#IF(%ReportGroupHeader)
PRINT(%ReportPre:%ReportGroupHeader) #<!Print group header
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
#ENDIF
%ReportGroupHeaderPost
#IF(%PageTotals) #!Any footer save fields?
IF SAV::LineCounter > %ReportLine #<!Page overflow?
#SET(%ResetTotalType,'PAGE') #!Reset page totals
#INSERT(%ResetTotals)
#SET(%TallyType,'PAGE') #!Tally page totals
#INSERT(%TallyTotals)
END
SAV::LineCounter = %ReportLine #<!Save line counter
#ENDIF
SAV::%ThisReportGroup = %ThisReportGroup #<!New break field value
#SET(%TallyType,%ThisReportGroup) #!Tally group total fields
#INSERT(%TallyTotals)
#!
#!***************************************************************************
#GROUP(%MultiUpLabelBuild)
SAV::LabelCounter += 1 #<!Increment label counter
#SET(%Counter1,%NULL)
#FOR(%ReportLabelField)
#SET(%Counter1,(%Counter1 + 1))
#IF(INSTRING('[',%ReportLabelField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportLabelField,1,INSTRING('[',%ReportLabelField,1,1)-1)))
LBL::%ArrayField::%Counter1[SAV::LabelCounter] = %ReportLabelField
#ELSE
LBL::%ReportLabelField[SAV::LabelCounter] = %ReportLabelField
#ENDIF
#ENDFOR
IF SAV::LabelCounter < %ReportLabel
CYCLE
END
#!
#!***************************************************************************
#GROUP(%MultiUpLabelReset)
SAV::LabelCounter = 0 #<!Reset label counter
#SET(%Counter1,%NULL)
#FOR(%ReportLabelField)
#SET(%Counter1,(%Counter1 + 1))
#IF(INSTRING('[',%ReportLabelField,1,1)) #!Check for array element
#SET(%ArrayField,(SUB(%ReportLabelField,1,INSTRING('[',%ReportLabelField,1,1)-1)))
CLEAR(LBL::%ArrayField::%Counter1) #<!Reset label USE variable
#ELSE
CLEAR(LBL::%ReportLabelField) #<!Reset label USE variable
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%RptAbortKey)
#IF(%EscapeAbort) #!Enable ESC checked?
LOOP WHILE KEYBOARD() #<!If any keystrokes waiting
ASK #<! in the buffer, get them
IF KEYCODE() = EscKey #<!Detect the ESC key
CLOSE(%Report) #<! close the report
RETURN #<! and get out
END
END #<!End abort key loop
#ENDIF
#!
#!***************************************************************************
#GROUP(%RptSetMultiples)
#SET(%SelectorAccess,(%AccessMethod = 'Keyed Order' AND %KeyComponent <> %NULL))
#FOR(%Secondary)
#SET(%SecondaryExist,'YES')
#BREAK
#ENDFOR
#FOR(%Formula)
#SET(%FormulaExist,'YES')
#BREAK
#ENDFOR
#FOR(%ReportGroup)
#SET(%ReportGroupExist,'YES')
#BREAK
#ENDFOR
#FOR(%ReportTotal)
#SET(%ReportTotalExist,'YES')
#BREAK
#ENDFOR
#FOR(%ReportSave)
#FOR(%ReportSaveField)
#IF(%ReportSaveField <> %ReportPage)
#SET(%ReportSaveExist,'YES')
#BREAK
#ENDIF
#ENDFOR
#IF(%ReportSaveExist)
#BREAK
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%RptFindFile)
#SET(%FoundFile,%NULL)
#FOR(%File)
#IF(UPPER(%FilePre) = UPPER(SUB(%BreakField,1,INSTRING(':',%BreakField,1,1)-1)))
#SET(%FoundFile,%File)
#BREAK
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%ReportErrorCheck)
#SET(%ErrorMessage,(%Procedure & ' ERROR:'))
#IF(%Primary = %NULL)
#ERROR(%ErrorMessage)
#ERROR(' You MUST define a Primary File in the File Schematic.')
#ENDIF
#IF(%KeyComponent)
#FIX(%File,%Primary)
#FIX(%Key,%PrimaryKey)
#FOR(%KeyField)
#IF(%KeyField = %KeyComponent)
#SET(%FoundComponent,'YES')
#BREAK
#ENDIF
#ENDFOR
#IF(%FoundComponent = %NULL)
#ERROR(%ErrorMessage)
#ERROR(' Range Limit Field must be a component of ')
#ERROR(' the Primary file Access Key.')
#ENDIF
#IF(%ScopeValue = %NULL)
#ERROR(%ErrorMessage)
#ERROR(' Must define a Range Value Field')
#ELSIF(%KeyComponent = %ScopeValue)
#ERROR(%ErrorMessage)
#ERROR(' Range Value Field and Range Limit Field')
#ERROR(' must be separate fields.')
#ENDIF
#ENDIF
#!
#!
#CHAIN('OM8.TPX')