Page 1 of 3

Legend Report

PostPosted: Wed Oct 13, 2010 8:51 pm
by fbryant2010
I have created a report which includes a legend. The legend is fairly stable but the users can add to the legend code and descriptions as needed. How can I code it so I will not have to go in and change the program every time there is an addition/change? The legend is coming from a DB2 table.

TAX CODES AND THEIR MEANING
----------------------------
CIG = Cigarettes CTL = Cigarette & Tobacco License # EGG = Egg License #
FEN = FederalEmployerIdentification# PAC = Perishable Ag Commod Act # PDL = Plant Dealer License #
PTL = Privilege Tax Lic # SBL = State Business License # STI = State Tax Id #
STP = Sales Tax Permit # TOB = Tobacco License #

01 WS-VVD-TABLES.
05 WS-VVD-ENTRIES OCCURS 15 TIMES.
10 WS-VVD-CODE PIC X(03).
10 WS-VVD-DESC PIC X(30).

Legend print line.

05 LEGEND-LINE2.
10 LEGEND-CODE1 PIC X(3).
10 FILLER PIC X(3)
VALUE ' = '.
10 LEGEND-DESC1 PIC X(30).
10 FILLER PIC X(3)
VALUE ' '.
10 LEGEND-CODE2 PIC X(3).
10 FILLER PIC X(3)
VALUE ' = '.
10 LEGEND-DESC2 PIC X(30).
10 FILLER PIC X(3)
VALUE ' '.
10 LEGEND-CODE3 PIC X(3).
10 FILLER PIC X(3)
VALUE ' = '.
10 LEGEND-DESC3 PIC X(30).
10 FILLER PIC X(3)

Moving the table to the output before printing.

PERFORM TEST AFTER VARYING WS-VVD-SUB FROM 1 BY 1
UNTIL WS-VVD-CODE (WS-VVD-SUB) = '999'
MOVE WS-VVD-CODE(WS-VVD-SUB) TO LEGEND-CODE1
MOVE WS-VVD-DESC(WS-VVD-SUB) TO LEGEND-DESC1
ADD +1 TO WS-VVD-SUB
MOVE WS-VVD-CODE(WS-VVD-SUB) TO LEGEND-CODE2
MOVE WS-VVD-DESC(WS-VVD-SUB) TO LEGEND-DESC2
ADD +1 TO WS-VVD-SUB
MOVE WS-VVD-CODE(WS-VVD-SUB) TO LEGEND-CODE3
MOVE WS-VVD-DESC(WS-VVD-SUB) TO LEGEND-DESC3
ADD +1 TO WS-VVD-SUB
MOVE WS-VVD-CODE(WS-VVD-SUB) TO LEGEND-CODE4
MOVE WS-VVD-DESC(WS-VVD-SUB) TO LEGEND-DESC4
ADD +1 TO WS-VVD-SUB

Re: Legend Report

PostPosted: Wed Oct 13, 2010 10:25 pm
by NicC
Loop through the results returned from DB2 assigning them to your print line. This should be a table rather than loads of individual variables. Write your print line after every 4 assignments or when you run out of data to assign.

Re: Legend Report

PostPosted: Wed Oct 13, 2010 11:24 pm
by dick scherrer
Hello,

Why would you not use the same solution used for your other "legend" question. . . :?

Re: Legend Report

PostPosted: Thu Oct 14, 2010 12:42 am
by fbryant2010
Would the other legend solution handle if the table had more entries without having to change the program? If the table has more entries, I am trying not to change the program in order to update the legend.

Re: Legend Report

PostPosted: Thu Oct 14, 2010 1:07 am
by NicC
If you designed it right it will handle any number of entries and not a pre-determined number of entries.

Re: Legend Report

PostPosted: Thu Oct 14, 2010 2:07 am
by dick scherrer
Hello,

How often does the legend info receive new entries?

If the current usage is 15 entries, allow for up to 100. When 90 are used begin showing a warning that the legend array has reached 90% filled. Then add another 100 entries to the array.

Re: Legend Report

PostPosted: Thu Oct 14, 2010 2:12 am
by fbryant2010
What would the print legend look like?

Legend print line now. Up to 15 legend-code15

05 LEGEND-LINE2.
10 LEGEND-CODE1 PIC X(3).
10 FILLER PIC X(3)
VALUE ' = '.
10 LEGEND-DESC1 PIC X(30).
10 FILLER PIC X(3)
VALUE ' '.
10 LEGEND-CODE2 PIC X(3).
10 FILLER PIC X(3)
VALUE ' = '.
10 LEGEND-DESC2 PIC X(30).
10 FILLER PIC X(3)
VALUE ' '.
10 LEGEND-CODE3 PIC X(3).
10 FILLER PIC X(3)
VALUE ' = '.
10 LEGEND-DESC3 PIC X(30).
10 FILLER PIC X(3)

Re: Legend Report

PostPosted: Thu Oct 14, 2010 2:21 am
by dick scherrer
Hello,

In another loop. . . The individual 15 lines will no longer be used.

Move 1 array entry to the "print line" and write it.
Increment the array until the last item has been processed.

Re: Legend Report

PostPosted: Thu Oct 14, 2010 6:26 pm
by fbryant2010
I am not following you. I don't need the legend print lines?

Re: Legend Report

PostPosted: Thu Oct 14, 2010 6:29 pm
by fbryant2010
I have this so far.

01 WS-LEGEND-TABLES.
05 WS-LEGEND-ENTRIES OCCURS 15 TIMES.
10 WS-LEGEND-CODE PIC X(03).
10 FILLER PIC X(03) VALUE ' = '.
10 WS-LEGEND-DESC PIC X(30).
10 FILLER PIC X(03) VALUE ' '.

1 01 WS-LEGEND-TABLES
02 WS-LEGEND-ENTRIES
03 WS-LEGEND-CODE
SUB(1) 'CIG'
SUB(2) 'CTL'
SUB(3) 'EGG'
SUB(4) 'FEN'
SUB(5) 'PAC'
SUB(6) 'PDL'
SUB(7) 'PTL'
SUB(8) 'SBL'
SUB(9) 'STI'
SUB(10) 'STP'
SUB(11) 'TOB'

03 WS-LEGEND-DESC
SUB(1) 'Cigarettes '
SUB(2) 'Cigarette & Tobacco License # '
SUB(3) 'Egg License # '
SUB(4) 'FederalEmployerIdentification#'
SUB(5) 'Perishable Ag Commod Act # '
SUB(6) 'Plant Dealer License # '
SUB(7) 'Privilege Tax Lic # '
SUB(8) 'State Business License # '
SUB(9) 'State Tax Id # '
SUB(10) 'Sales Tax Permit # '
SUB(11) 'Tobacco License # '