On 4/30/2017 10:17 PM, Mark S Waterbury wrote:
So,  if someone  really wanted to use Auto-Report with ILE RPG IV, you
could  run this command, specify the name of the source file, lbirary
and member name for  the output, then use that as input to CVTRPGSRC,
and "Voila!" -- you have an ILE Auto-Report program.
Here, for the truly bored among us, is a brand new, written from scratch
(and memory - oh look, a zeugma!) Auto Report program.  I can't believe
I just wrote those words.
First, let's create a table.  I could have used DDS, and then written a
program to populate some sample data, but this seemed easier for readers
to reproduce.
create table buck.autorep (
  county char(20),
  city char(20),
  sales numeric(7, 2)
);
insert into buck.autorep
values
('Albany', 'Albany', 100.00),
('Albany', 'Albany', 20.00),
('Albany', 'Rennselaerville', 10.00),
('Schenectady', 'Schenectady', 15.00),
('Schenectady', 'Schenectady', 17.00),
('Schenectady', 'Schenectady', 105.00),
('Schenectady', 'Niskayuna', 22.50),
('Schenectady', 'Niskayuna', 12.95),
('Schenectady', 'Niskayuna', 107.42),
('Schenectady', 'Rotterdam', 10.50),
('Schenectady', 'Rotterdam', 17.50)
;
-- RPG will want an index
create index buck.autorepl
on buck.autorep
(county, city);
Here's what Auto Report will do for me, using SQL:
select county, city, sum(sales)
from buck.autorep
group by county, city with rollup
order by county, city;
Albany              	Albany              	120.00
Albany              	Rennselaerville     	10.00
Albany              	-	130.00
Schenectady         	Niskayuna           	142.87
Schenectady         	Rotterdam           	28.00
Schenectady         	Schenectady         	137.00
Schenectady         	-	307.87
-	-	437.87
Here it is, in gleaming new Auto Report:
QRPGSRC, member AUTOREPORT, SRCTYPE(RPT:
U
H        1
FAUTOREPLIPE F      47 40AI     1 DISK
FQSYSPRT O   F     132     OF    LPRINTER
LQSYSPRT 066FL060OL
IAUTOREPLAA  01
I                                        1  20 COUNTYL2
I                                       21  40 CITY  L1
I                                       41  472SALES
OQSYSPRT H                *AUTO
O                                      'MARMOTA MUSA INT''L'
OQSYSPRT D                *AUTO
O                       L2COUNTY       'COUNTY'
O                       L1CITY         'CITY'
O                         SALES JA     'SALES'
That 'U' in column 6 isn't anomalous.  You forgot about the Auto Report
Spec, didn't you?  :-)  Should I tell you which columns mean what?
PDM option 14 with RPTOPT(*SRC) creates this:
H        1
FAUTOREPLIPE F      47 40AI     1 DISK
FQSYSPRT O   F     132     OF    LPRINTER
LQSYSPRT 066FL060OL
IAUTOREPLAA  01
I                                        1  20 COUNTYL2
I                                       21  40 CITY  L1
I                                       41  472SALES
C                     EXSR A$$SUM
CL1         SALES2    ADD  SALES1    SALES2  92
CL2         SALESR    ADD  SALES2    SALESR  92
CSR         A$$SUM    BEGSR
CSR         SALES1    ADD  SALES     SALES1  92
CSR                   ENDSR
OQSYSPRT H  206   1P
O       OR        OF
O                         UDATE Y    8
O                                   38 'MARMOTA MUSA INT''L'
O                                   56 'PAGE '
O                         PAGE  Z   60
OQSYSPRT H  2     1P
O       OR        OF
O                                    6 'COUNTY'
O                                   26 'CITY'
O                                   57 'SALES'
OQSYSPRT T 11     L1
O                         COUNTY    20
O                       CITY      42
O                         SALES1JB  57
OQSYSPRT T 12     L2
O                         SALES2JB  57
O                                   59 '**'
OQSYSPRT T 12     LR
O                         SALESRJB  57
O                                   60 '***'
The results look like this:
 5/01/17            MARMOTA MUSA INT'L             PAGE    1
COUNTY                CITY                          SALES
Albany                Albany                      120.00 *
Albany                Rennselaerville              10.00 *
                                                  130.00 **
Schenectady           Niskayuna                   142.87 *
Schenectady           Rotterdam                    28.00 *
Schenectady           Schenectady                 137.00 *
                                                  307.87 **
                                                  437.87 ***
I'm not going to go into the detail of how this works because frankly I
think its time has passed.  If you want to play, here are some things
for you to try now that you have some source:
1) Group indicate the county name so it doesn't repeat
2) Show the detail
3) Add your own C-specs to generate a separate printed line for the two
cases where the county name is the same as the city name
4) Eliminate the asterisks on the total lines
This is how I would have done this sort of query-ish report on System/3,
although for maximum utility I would not have used an indexed file, I
would have used an ADDROUT sort.  That's an extra F-spec and an E-spec,
plus a FMTDTA and usually all wrapped up in a CLP.  If someone wants to
see /that/ let me know and I'll extend the thread one more round.  For
now, the System/3 heritage is easy to see in the primary F-spec: It's
program described.  What happens if I change it to externally described?
 CRTRPTPGM generates this diagnostic pass:
0001     FAUTOREPLIPE E           K        DISK
0002     F            AUTOREP                           KRENAMERAUTO
0003     FQSYSPRT O   F     132     OF    LPRINTER
0004     LQSYSPRT 066FL060OL
0005     IRAUTO       01
0006     I                                              COUNTYL2
0007     I                                              CITY  L1
0008     OQSYSPRT H                *AUTO
0009     O                                      'MARMOTA MUSA INT''L'
0010     OQSYSPRT D                *AUTO
0011     O                       L2COUNTY       'COUNTY'
0012     O                       L1CITY         'CITY'
0013     O                         SALES JA     'SALES'
   * * * * *   E N D   O F   S O U R C E   * * * * *
                           F i n a l   S u m m a r y
* RPT0034 Severity:  10   Statement:  0006
          Message . . . . :   The Definition of field is invalid.
Definition ignored.
* RPT0034 Severity:  10   Statement:  0007
          Message . . . . :   The Definition of field is invalid.
 Definition ignored.
* RPT0016 Severity:  10   Statement:  0011
          Message . . . . :   The field-name entry is not valid.
            Specification line ignored.
* RPT0016 Severity:  10   Statement:  0012
          Message . . . . :   The field-name entry is not valid.
            Specification line ignored.
* RPT0016 Severity:  10   Statement:  0013
          Message . . . . :   The field-name entry is not valid.
            Specification line ignored.
Yeah, the preprocessor doesn't handle externally described files.
Nor will it handle sub-procedures,
Or **free,
Or extended Factor 2,
Or anything newer than what, System/36 RPG?
I myself don't have a use for this in 2017, but if all you have is S36EE
and program described files...
As an Amazon Associate we earn from qualifying purchases.