Legend Report



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Legend Report

Postby fbryant2010 » Fri Oct 15, 2010 9:41 pm

Here is what I am trying to do and the code I have so far that is not accomplishing what I need. Fetching code and desc from DB2 table. Data will change periodically (add/delete). Loading a table with fetched data. Need to take the loaded data into 5 legend print lines. I need to code it so if a codes/desc are added or deleted, I will not have to keep changing the program. Presently I am getting the data into the print lines using the code listed at the end because I know the number of entries right now.

01 WS-VVD-TABLES.
05 WS-VVD-ENTRIES OCCURS 1 TO 30 TIMES
DEPENDING ON WS-VVD-SUB.
10 WS-VVD-CODE PIC X(03).
10 WS-VVD-DESC PIC X(30).

1220-FETCH-VVDCSR.

EXEC SQL
FETCH VVD_CSR
INTO :SQL-VVD-CODE
,:SQL-VVD-DESC
END-EXEC.

EVALUATE SQLCODE
WHEN +0
MOVE WS-VVD-LIC TO SQL-VVD-TYPE
ADD +1 TO WS-VVD-ROWS
WHEN +100
ADD +1 TO WS-VVD-SUB
MOVE '999' TO WS-VVD-CODE (WS-VVD-SUB)
MOVE 'Y' TO WS-VVD-DONE-SW

1230-LOAD-VVD-TBL.

ADD +1 TO WS-VVD-SUB
IF WS-VVD-SUB <= WS-VVD-TAB-SIZE
MOVE SQL-VVD-CODE TO WS-VVD-CODE (WS-VVD-SUB)
MOVE SQL-VVD-DESC TO WS-VVD-DESC (WS-VVD-SUB)
ELSE
CONTINUE
END-IF

Loaded table:
03 WS-VVD-CODE
SUB(1) 'CIG'
SUB(2) 'CTL'
SUB(3) 'EGG'
SUB(4) 'FEN'
SUB(5) 'NEW'
SUB(6) 'PAC'
SUB(7) 'PDL'
SUB(8) 'PTL'
SUB(9) 'SBL'
SUB(10) 'STI'
SUB(11) 'STP'
SUB(12) 'TOB'
SUB(13) 'TST'
SUB(14) '999'
03 WS-VVD-DESC
SUB(1) 'Cigarettes '
SUB(2) 'Cigarette & Tobacco License # '
SUB(3) 'Egg License # '
SUB(4) 'FederalEmployerIdentification#'
SUB(5) 'New License # '
SUB(6) 'Perishable Ag Commod Act # '
SUB(7) 'Plant Dealer License # '
SUB(8) 'Privilege Tax Lic # '
SUB(9) 'State Business License # '
SUB(10) 'State Tax Id # '
SUB(11) 'Sales Tax Permit # '
SUB(12) 'Tobacco License # '
SUB(13) 'Test License # '

I need to get the above data into the 5 print lines below. Print lines 3-6.

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)
VALUE ' '.

This is how I am getting the data to the print lines.
PERFORM TEST BEFORE 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
MOVE WS-VVD-CODE(WS-VVD-SUB) TO LEGEND-CODE5
MOVE WS-VVD-DESC(WS-VVD-SUB) TO LEGEND-DESC5
ADD +1 TO WS-VVD-SUB
MOVE WS-VVD-CODE(WS-VVD-SUB) TO LEGEND-CODE6
fbryant2010
 
Posts: 20
Joined: Fri Oct 08, 2010 9:52 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Legend Report

Postby fbryant2010 » Fri Oct 15, 2010 9:45 pm

This is what the legend will look like:

TAX CODES AND THEIR MEANING
----------------------------
CIG = Cigarettes CTL = Cigarette & Tobacco License # EGG = Egg License #
FEN = FederalEmployerIdentification# NEW = New License # 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 #
TST = Test License # = =
fbryant2010
 
Posts: 20
Joined: Fri Oct 08, 2010 9:52 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Legend Report

Postby NicC » Fri Oct 15, 2010 11:24 pm

try OCCURS
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Legend Report

Postby dick scherrer » Sat Oct 16, 2010 2:29 am

Hello,

When posting sample data or a report (or code/jcl) use the "Code" tag to presereve alignment and improve readability.

Either copy/paste from a "screen" or from Notepad, hilight the pasted text and click the "Code" tag.

Use Preview to see your post as it will appear to the forum (rather than how it looks in the Reply Editor). When the sppearance is as you want, Submit.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Legend Report

Postby dick scherrer » Sat Oct 16, 2010 2:33 am

Hello,

There will be 2 OCCURS - one for the code/desc array and one for the print line.

You just need a loop that works as i mentioned earlier:
Then the print line becomes another array and you move from "where you are" in the legend array to the "next" print item. Once 3 have been moved to the print array, print the line and reset to the beginning of the print array.

When the last row has been processed, print the last print line that was being built (unless it has no data).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post