home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR36
/
C7101.ZIP
/
REPORT.TPX
< prev
next >
Wrap
Text File
|
1994-01-12
|
14KB
|
277 lines
#!┌───────────────────────────┤Template Segment├───────────┬─────────────────┐
#!│ Report.TPX │Version: 3007.000│
#!├───────────────────────────────┤Contents├───────────────┴─────────────────┤
#!│Structure Type Description │
#!│──────────────────── ───────── ─────────────────────────────────────────│
#!│Report PROCEDURE Print a report from a file │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
#PROCEDURE(Report,'Print a Report'),REPORT,SCREEN
#!
#!┌──────────────────────────┤Procedure Template├──────────┬─────────────────┐
#!│ Report │Version: 3007.000│
#!├──────────────────────────────┤Description├─────────────┴─────────────────┤
#!│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 multiple levels below the first file │
#!│related to, for every 1:MANY (Parent-Child) relationship at each level. │
#!│A lookup file may generate a second related lookup. │
#!│ │
#!│This File Schematic is directly supported: │
#!│ Primary │
#!│ └──Secondary (Lookup MANY:1 from Primary) │
#!│ │ └──Secondary (Lookup File from Lookup File) │
#!│ └──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 (Lookup File from Lookup File) │
#!│ └─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 (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. │
#!│Multiple Group Breaks are supported on every (Primary or Child Secondary │
#!│file not on Lookups. │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
#PROTOTYPE('')
#DISPLAY(' ')
#PROMPT('Enable ESC Key Abort',CHECK),%EscapeAbort
#PROMPT('Show Report Progress',CHECK),%ProgressScreen
#PROMPT('CLEAR Record &First',CHECK),%ClearRecord
#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(%RptSetFlags)
#INSERT(%ReportErrorCheck)
#INSERT(%StandardHeader)
#IF(%RedirectProc AND %ViewProc)
#MAP('TEMPFILE.INC')
#ENDIF
%Procedure PROCEDURE
#INSERT(%FileControl)
%LocalData
#INSERT(%ReportDataDeclares) #!Internal data declarations
#IF(%ProgressScreen)
%ScreenStructure
#ENDIF
%ReportStructure
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#INSERT(%RptRedirectGroup) #!Printer Redirection handling
#INSERT(%FileControl)
OPEN(%Report) #<!Prepare to print report
#EMBED('After Report OPEN before Title page')
#SET(%CodePosition,'SETUP') #!Class = SETUP report
#INSERT(%ReportFormulas) #!Generate formulas
#IF(%ReportTitle) #!Print Title Page
PRINT(%ReportPre:%ReportTitle) #<!Print Title Page
#IF(%ProgressScreen)
DISPLAY #<!Display report progress
#ENDIF
#ENDIF
#IF(%ClearRecord)
#FIX(%File,%Primary)
CLEAR(%FilePre:Record) #<!Clear record buffer
#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('Before Initial SET()')
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
#EMBED('Before Initial SET()')
SET(%PrimaryKey) #<!Top of file, keyed order
#ENDIF
#IF(%ProgressScreen)
OPEN(%Screen)
#ENDIF
#FIX(%File,%Primary)
%FilePre::PRINTED = 0 #<!Set records printed flag
#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')
#IF(%ReportSaveExist)
#SET(%SaveFile,%Primary) #!Check for footer save fields
#INSERT(%SaveFooterFields)
#ENDIF
#IF(INSTRING(%Primary,%BreakFilesQueue,1,1)) #!Check for group breaks
#SET(%CurrentFile,%Primary)
#INSERT(%GroupBreakNumber)
#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(%PrimaryGroupBreak)
#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(%Parent,%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)
#INSERT(%PrintDanglingLabels)
#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
CLOSE(%Report) #<!Close report
#SET(%ResetTotalType,'NONE') #!Reset report totals
#INSERT(%ResetTotals)
#IF(%ProgressScreen)
CLOSE(%Screen) #<!Close report progress screen
#ENDIF
#IF(%ViewProc)
%ViewProc #<!Call View Procedure
#IF(%RedirectProc)
IF TempFile #<!Check for temporary file
IF RemoveFile(TempFile) #<! and delete it
#INSERT(%DelTempFileErrMsg)
END
END
#ENDIF
#ENDIF
DO ProcedureReturn
!─────────────────────────────────────────────────────────────────────────────
ProcedureReturn ROUTINE
#EMBED('Before Closing Files')
#INSERT(%FileControl)
DO EndOfProcedureEmbed
RETURN
!─────────────────────────────────────────────────────────────────────────────
EndOfProcedureEmbed ROUTINE
#EMBED('End of Procedure')
#EMBED('Custom Routines')
#IF(%ReportGroupExist)
#INSERT(%BreakFooterRoutines) #!Print Group Break footers
#INSERT(%BreakHeaderRoutines) #!Print Group Break headers
#ENDIF
#INSERT(%RptTotalRoutines) #!Total tallys and resets
#IF(%ReportSaveExist)
#SET(%TempQueue,%SaveFilesQueue)
#INSERT(%SaveFooterRoutine) #!Footer save field saves
#INSERT(%PrintFooterRoutine) #!Footer save field saves
#INSERT(%RestoreFooterRoutine) #!Footer save field saves
#ENDIF
#CHAIN('Print.tpx')