[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Printing multiple reports -Reply



This can be a tricky practice, especially if you are printing to multiple
reports simultaneously.  There are a number of responses regarding
multiple report printing on the archive list, but each of these deals with
writing to each report exclusively.  To write to multiple reports you must...

1.  In the SETUP declare each report using the DECLARE-REPORT
command
2.  Also in the SETUP you may wish to declare different headings/footings
for each of your reports.  For this you need to use the
DECLARE-PROCEDURE command and associated the specific heading or
footer with the report name (as declared in step 1) and to which
procedure it is to fire.
3.  In the main body of your program you need to utilize the
USE-PROCEDURE command and identify the report.
4.  In the main body of your program you need to specify the report you
want to write to via the USE-REPORT command
5.  Every print statement will write to that report until another
USE-REPORT is executed.  The resulting files should be filenam.l##.

Attached is the snippets of code that may be useful as an example.  THIS
CODE WILL NOT EXECUTE.

Good Luck,
Dave
!******************************************************************************
BEGIN-SETUP
!******************************************************************************
#define ColR    160             !Column number referenced by Standard Headings
#include 'setupdb.sqc'  !Defines database specific parameters

declare-layout Default
        paper-size      =       (11, 8.5)
        orientation     =       LANDSCAPE
        top-margin      =       0.5
        left-margin     =       0.05
        max-columns     =       177
        max-lines       =       58
        char-width      =       4.32
        line-height     =       9
end-declare

declare-printer HPLaserJet
        type            =       HPLASERJET
        font            =       0
        point-size      =       6
        pitch           =       17
end-declare

declare-report Report9          !Debug Report
        layout          =       Default
        printer-type=   HPLaserJet
end-declare

declare-report Report0          !Dollars Report - Current Activity
        layout          =       Default
        printer-type=   HPLaserJet
end-declare

declare-report Report1          !Hours Report - Current Activity
        layout          =       Default
        printer-type=   HPLaserJet
end-declare

declare-report Report2          !Dollars Report - YTD Activity
        layout          =       Default
        printer-type=   HPLaserJet
end-declare

declare-report Report3          !Hours Report - YTD Activity
        layout          =       Default
        printer-type=   HPLaserJet
end-declare

declare-report Report4          !Payroll Statistics
        layout          =       Default
        printer-type=   HPLaserJet
end-declare

declare-report Report5          !Other Payroll Statistics
        layout          =       Default
        printer-type=   HPLaserJet
end-declare

declare-procedure               !Current Activity - Dollars
        for-reports=(Report0)
        before-page=Wages-Activity-Header
end-declare

declare-procedure               !Current Activity - Hours
        for-reports=(Report1)
        before-page=Hours-Activity-Header
end-declare

declare-procedure               !Year to Date Activity - Dollars
        for-reports=(Report2)
        before-page=Wages-YTD-Activity-Header
end-declare

declare-procedure               !Year to Date Activity - Hours
        for-reports=(Report3)
        before-page=Hours-YTD-Activity-Header
end-declare

declare-procedure               !Payroll Statistics
        for-reports=(Report4)
        before-page=Payroll-Statistics-Header
end-declare

declare-procedure               !Other Payroll Statistics
        for-reports=(Report5)
        before-page=Other-Payroll-Statistics-Header
end-declare

declare-procedure               !Debug Report
        for-reports=(Report9)
        before-page=Debug-Report-Header
end-declare

end-setup

!******************************************************************************
BEGIN-PROCEDURE DEBUG-REPORT-HEADER
!******************************************************************************
        move 'Debug Report' to $ReportTitle
        move 'HPAY642g.sqr' to $ReportID
        #include 'hfhdg642.sqc'         !Standard Headings for this program
        print   'Emplid'                        (+1,1)
        print   'Company'                       (+0,10)
        print   'CostCenter'            (+0,20)
        print   'Acct Cd'                       (+0,30)
        print   'Record Type'           (+0,40)
        print   'HF Code'                       (+0,47)
        print   'Tax Class'                     (+0,54)
        print   'State'                         (+0,61)
        print   'Locality'                      (+0,68)
        print   'Erncd_Spcl'            (+0,75)
        print   'Year'                          (+0,82)
        print   'Pay End Dt'            (+0,89)
        print   'Hours'                         (+0,101)
        print   'Dollars'                       (+0,111)
        print   'FTE'                           (+0,127)
        print   'Hours'                         (+0,137)
        print   'Dollars'                       (+0,146)
        print   'FTE'                           (+0,159)

END-PROCEDURE

!******************************************************************************
BEGIN-PROCEDURE Payroll-Statistics-Header
!******************************************************************************
        move 'Payroll Statistics' to $ReportTitle
        move 'HPAY642e.sqr' to $ReportID
        #include 'hfhdg642.sqc'         !Standard Headings for this program
        print   '|-------------- DOLLAR AMOUNT --------------|'                         (+2,40)
        print   '|-------- FULL TIME EQUIVALENTS ---------|'                            (+0,90)
        print   '|---------- EMPLOYEE COUNTS -----------|'                                      (+0,137)

        print   'Account'                                                                                                       (+1,1)
        print   'Productive   Non-Productive            Total'                          (+0,41)
        print   'Productive   Non-Productive          Total'                            (+0,90)
        print   'Full Time  Part Time      Temp     Total'                                      (+0,137)

END-PROCEDURE

!******************************************************************************
BEGIN-PROCEDURE Other-Payroll-Statistics-Header
!******************************************************************************
        move 'Other Payroll Statistics' to $ReportTitle
        move 'HPAY642f.sqr' to $ReportID
        #include 'hfhdg642.sqc'         !Standard Headings for this program
        print   'Current'                                                                                                       (+2,40)
        print   'Average'                                                                                                       (+0,53)
        print   'Average'                                                                                                       (+0,68)
        print   'Average'                                                                                                       (+0,83)
        print   'Average'                                                                                                       (+0,98)
        print   'Average'                                                                                                       (+0,113)

        print   'Pay'                                                                                                           (+1,44)
        print   'YTD'                                                                                                           (+0,57)
        print   $Qtr0                                                                                                           (+0,66)
        print   $Qtr1                                                                                                           (+0,81)
        print   $Qtr2                                                                                                           (+0,96)
        print   $Qtr3                                                                                                           (+0,111)

END-PROCEDURE

!******************************************************************************
BEGIN-PROCEDURE Wages-Activity-Header
!******************************************************************************
        move 'Current Activity - WAGES' to $ReportTitle
        move 'HPAY642a.sqr' to $ReportID
        #include 'hfhdg642.sqc'         !Standard Headings for this program
        print   '|---------------------PRODUCTIVE---------------------|'        (+2,51)
        print   '|-------NON PRODUCTIVE-----|'                                                          (+0,107)

        print   'Account'                                                                                                       (+1,1)
        print   'Full/'                                                                                                         (+0,45)
        print   'Additional Earnings'                                                                           (+0,86)
        print   'Additional            CTO'                                                                     (+0,110)
        print   'Gross        CTO           CTO'                                                        (+0,147)

        print   'Job Title'                                                                                                     (+1,1)
        print   'Employee'                                                                                                      (+0,24)
        print   'Part'                                                                                                          (+0,46)
        print   'Base'                                                                                                          (+0,59)
        print   'Overtime'                                                                                                      (+0,69)
        print   'On-Call'                                                                                                       (+0,84)
        print   'Other'                                                                                                         (+0,100)
        print   'Earnings'                                                                                                      (+0,112)
        print   'Used'                                                                                                          (+0,131)
        print   'Wages'                                                                                                         (+0,147)
        print   'Earned'                                                                                                        (+0,157)
        print   'Balance'                                                                                                       (+0,170)
END-PROCEDURE

!******************************************************************************
BEGIN-PROCEDURE Hours-Activity-Header
!******************************************************************************
        move 'Current Activity - HOURS' to $ReportTitle
        move 'HPAY642b.sqr' to $ReportID
        #include 'hfhdg642.sqc'         !Standard Headings for this program
        print   '|---------------------PRODUCTIVE---------------------|'        (+2,51)
        print   '|-------NON PRODUCTIVE-----|'                                                          (+0,107)

        print   'Account'                                                                                                       (+1,1)
        print   'Full/'                                                                                                         (+0,45)
        print   'Additional Earnings'                                                                           (+0,86)
        print   'Additional            CTO'                                                                     (+0,110)
        print   'Gross        CTO           CTO'                                                        (+0,147)

        print   'Job Title'                                                                                                     (+1,1)
        print   'Employee'                                                                                                      (+0,24)
        print   'Part'                                                                                                          (+0,46)
        print   'Base'                                                                                                          (+0,59)
        print   'Overtime'                                                                                                      (+0,69)
        print   'On-Call'                                                                                                       (+0,84)
        print   'Other'                                                                                                         (+0,100)
        print   'Earnings'                                                                                                      (+0,112)
        print   'Used'                                                                                                          (+0,131)
        print   'Hours'                                                                                                         (+0,147)
        print   'Earned'                                                                                                        (+0,157)
        print   'Balance'                                                                                                       (+0,170)
END-PROCEDURE

!******************************************************************************
BEGIN-PROCEDURE Wages-YTD-Activity-Header
!******************************************************************************
        move 'Year to Date - WAGES' to $ReportTitle
        move 'HPAY642c.sqr' to $ReportID
        #include 'hfhdg642.sqc'         !Standard Headings for this program

        print   '|---------------------PRODUCTIVE---------------------|'        (+2,51)
        print   '|-------NON PRODUCTIVE-----|'                                                          (+0,107)

        print   'Account'                                                                                                       (+1,1)
        print   'Full/'                                                                                                         (+0,45)
        print   'Additional Earnings'                                                                           (+0,86)
        print   'Additional            CTO'                                                                     (+0,110)
        print   'Gross        CTO           CTO'                                                        (+0,147)

        print   'Job Title'                                                                                                     (+1,1)
        print   'Employee'                                                                                                      (+0,24)
        print   'Part'                                                                                                          (+0,46)
        print   'Base'                                                                                                          (+0,59)
        print   'Overtime'                                                                                                      (+0,69)
        print   'On-Call'                                                                                                       (+0,84)
        print   'Other'                                                                                                         (+0,100)
        print   'Earnings'                                                                                                      (+0,112)
        print   'Used'                                                                                                          (+0,131)
        print   'Wages'                                                                                                         (+0,147)
        print   'Earned'                                                                                                        (+0,157)
        print   'Balance'                                                                                                       (+0,170)
END-PROCEDURE

!******************************************************************************
BEGIN-PROCEDURE Hours-YTD-Activity-Header
!******************************************************************************
        move 'Year to Date - HOURS' to $ReportTitle
        move 'HPAY642d.sqr' to $ReportID
        #include 'hfhdg642.sqc'         !Standard Headings for this program

        print   '|---------------------PRODUCTIVE---------------------|'        (+2,51)
        print   '|-------NON PRODUCTIVE-----|'                                                          (+0,107)

        print   'Account'                                                                                                       (+1,1)
        print   'Full/'                                                                                                         (+0,45)
        print   'Additional Earnings'                                                                           (+0,86)
        print   'Additional            CTO'                                                                     (+0,110)
        print   'Gross        CTO           CTO'                                                        (+0,147)

        print   'Job Title'                                                                                                     (+1,1)
        print   'Employee'                                                                                                      (+0,24)
        print   'Part'                                                                                                          (+0,46)
        print   'Base'                                                                                                          (+0,59)
        print   'Overtime'                                                                                                      (+0,69)
        print   'On-Call'                                                                                                       (+0,84)
        print   'Other'                                                                                                         (+0,100)
        print   'Earnings'                                                                                                      (+0,112)
        print   'Used'                                                                                                          (+0,131)
        print   'Hours'                                                                                                         (+0,147)
        print   'Earned'                                                                                                        (+0,157)
        print   'Balance'                                                                                                       (+0,170)
END-PROCEDURE

!******************************************************************************
BEGIN-REPORT
#debug show 'Begin Report'
!******************************************************************************
        do Init-DateTime
        do Init-Number
        do Get-Current-DateTime
        do Init-Report
        do Messaging
        do Array-Creation
        do Process-Main
        commit

        use-procedure
                for-reports=(Report9)
                before-page=Debug-Report-Header
        use-procedure
                for-reports=(Report0)
                before-page=Wages-Activity-Header
        use-procedure
                for-reports=(Report1)
                before-page=Hours-Activity-Header
        use-procedure
                for-reports=(Report2)
                before-page=Wages-YTD-Activity-Header
        use-procedure
                for-reports=(Report3)
                before-page=Hours-YTD-Activity-Header
        use-procedure
                for-reports=(Report4)
                before-page=Payroll-Statistics-Header
        use-procedure
                for-reports=(Report5)
                before-page=Other-Payroll-Statistics-Header

        use-report Report9
        move 9 to #ReportNumber
        #debug do Print-Details

        clear-array name=EE_Activity
        move 'Current' to $ReportType
        do Current-Activity-Reporting                           !Current Activity

        clear-array name=EE_Activity
        move 'YTD' to $ReportType
        do YTD-Activity-Reporting                                       !YTD Activity

        use-report Report4
        do Payroll-Statistic-Ordering

        use-report Report5
        do Other-Payroll-Statistics

        do Reset
        do Stdapi-Term
        do Get-Current-DateTime()
        move $AsOfNow to $Ended
        show ' '
        show $ReportTitle ', ' $ReportID ' completed at ' $Ended '.'

END-REPORT

....

!******************************************************************************
BEGIN-PROCEDURE DETERMINE-COST-CENTER-ORDER
#debug show 'Determine Cost Center Order'
!******************************************************************************
begin-select distinct
GL1.HF_GL_Company
ACN.HF_Cost_Center
GL1.HF_Cost_Cntr_Descr
        move &GL1.HF_Cost_Cntr_Descr to $Descr
        move &ACN.HF_Cost_Center to $Cost_Center
        move &GL1.HF_GL_Company to $CompanyName
        evaluate $ReportType
                when = 'Current'
                        use-report Report1
                        move 1 to #ReportNumber
                        print   'ASSIGNED EMPLOYEES'            (+1,1)  Bold    Underline
                        use-report Report0
                        move 0 to #ReportNumber
                        print   'ASSIGNED EMPLOYEES'            (+1,1)  Bold    Underline
                        move 'Assigned' to $Type
                        move 'E.GL_Pay_Type ' to $Criteria
                        let $Driver1 = 'E.GL_Pay_Type = '
                        let $Driver2 = 'HCDT.HF_Cost_Center = '
                        #debug show 'ASSINGED Employees'
                        do Identify-Employees-Current

                        use-report Report1
                        move 1 to #ReportNumber
                        move 'Charged' to $Type
                        print   'CHARGED EMPLOYEES'             (+2,1)  Bold    Underline
                        use-report Report0
                        move 0 to #ReportNumber
                        print   'CHARGED EMPLOYEES'             (+2,1)  Bold    Underline
                        let $Driver1 = 'E.GL_Pay_Type = '
                        let $Driver2 = 'HCDT.HF_Cost_Center <> '
                        #debug show 'CHARGED Employees'
                        do Identify-Employees-Current

                        use-report Report1
                        move 1 to #ReportNumber
                        move 'Non-Assigned' to $Type
                        print   'NON-ASSIGNED EMPLOYEES'                (+2,1)  Bold    Underline
                        use-report Report0
                        move 0 to #ReportNumber
                        print   'NON-ASSIGNED EMPLOYEES'                (+2,1)  Bold    Underline
                        let $Driver1 = 'HCDT.HF_Cost_Center = '
                        let $Driver2 = 'E.GL_Pay_Type <> '
                        #debug show 'NON-ASSIGNED Employees'
                        do Identify-Employees-Current

                        do Determine-Print-Overall
                        use-report Report1
                        new-page
                        use-report Report0
                        new-page

                when = 'YTD'
                        use-report Report3
                        move 1 to #ReportNumber
                        print   'ASSIGNED EMPLOYEES'            (+1,1)  Bold    Underline
                        use-report Report2
                        move 0 to #ReportNumber
                        print   'ASSIGNED EMPLOYEES'            (+1,1)  Bold    Underline
                        move 'Assigned' to $Type
                        move 'E.GL_Pay_Type ' to $Criteria
                        let $Driver1 = 'EY.GL_Pay_Type = '
                        let $Driver2 = 'HCYT.HF_Cost_Center = '
                        #debug show 'ASSINGED Employees'
                        do Identify-Employees-YTD

                        use-report Report3
                        move 1 to #ReportNumber
                        move 'Charged' to $Type
                        print   'CHARGED EMPLOYEES'             (+2,1)  Bold    Underline
                        use-report Report2
                        move 0 to #ReportNumber
                        print   'CHARGED EMPLOYEES'             (+2,1)  Bold    Underline
                        let $Driver1 = 'EY.GL_Pay_Type = '
                        let $Driver2 = 'HCYT.HF_Cost_Center <> '
                        #debug show 'CHARGED Employees'
                        do Identify-Employees-YTD

                        use-report Report3
                        move 1 to #ReportNumber
                        move 'Non-Assigned' to $Type
                        print   'NON-ASSIGNED EMPLOYEES'                (+2,1)  Bold    Underline
                        use-report Report2
                        move 0 to #ReportNumber
                        print   'NON-ASSIGNED EMPLOYEES'                (+2,1)  Bold    Underline
                        let $Driver1 = 'HCYT.HF_Cost_Center = '
                        let $Driver2 = 'EY.GL_Pay_Type <> '
                        #debug show 'NON-ASSIGNED Employees'
                        do Identify-Employees-YTD

                        do Determine-Print-Overall
                        use-report Report3
                        new-page
                        use-report Report2
                        new-page
        end-evaluate

from    PS_HF_CHK_DTL_TBL ACN,
                PS_HF_GL_ROLUP_TBL GL1
where   ACN.HF_Cost_Center = GL1.HF_Cost_Center
order by GL1.HF_GL_Company, ACN.HF_Cost_Center
end-select

END-PROCEDURE