Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > COBOL-two-level table
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 24th March 08:21
nc1200
External User
 
Posts: 1
Default COBOL-two-level table


Hello, new to this group. I am taking COBOL and the topic is
multidimensional tables. We are Loading a two-level table from a input
file. There are no indexes. We are required to use subscripts. Does
anyone have an example on how to declare the table in the data division
and working storage section. I think I have that right. Next, I need to
see an example on how to load a two-level table and how to access it. I
have not problems with a inbedded table. A simple example would be
appreciated. Thank you
  Reply With Quote


  sponsored links


2 24th March 12:06
heybub
External User
 
Posts: 1
Default COBOL-two-level table


01 MY-TABLE.
02 FILLER OCCURS 3.
05 MY-TABLE-1 OCCURS 4 PIC 9. .....
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 3
PERFORM VARYING J FROM 1 BY 1 UNTIL J > 4
MOVE I TO MY-TABLE-1(I J)
END-PERFORM
END-PERFORM.

results in a memory layout of

111122223333

whereas (changing I to J in the MOVE statement) results in

123412341234

I've never had much reason to use multi-dimensional tables in the real
world. It's a necessary tool to have in your kit, though. At least
understanding how they work may be useful.
  Reply With Quote
3 24th March 12:06
james j. gavan
External User
 
Posts: 1
Default COBOL-two-level table


Without doubt you are going to get one reply "Do your own homework" -
just watch.

We don't mind helping people but generally it starts, "You show me yours
and I'll show you mine". So take a crack at the problem and then post
what you have done here.

Hopefully you've realized that a two-dimensional is not a big challenge
to understand; but depending upon what you are doing, you could have
more dimensions. First off - your instructor probably has already
illustrated a one-dimensional table - hint, hint, think of extracting a
description of a month-name using a REDEFINES.

01 MonthTable.
05 MonthTableA pic x(48) value
"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec," .
05 <---- now figure out what the next Level 05 looks like, plus its
Level 10s, if you are using commas

Quite often you will see the above as a pic x(36) without the
intervening commas. But if you are playing with tables containing
numerics, I prefer to include commas, so that as the author I can easily
see what I have set up, i.e. if the table already has predetermined
values as for Months, or perhaps a range of Temperatures.

01 MileageTable.

This is where the two dimensional comes in - you've seen them often in
tourists maps - distance from Town A on the vertical list to Town B on
the horizontal. You are pigeon-holing each mileage value with a
reference indicating which row/line and column.

Whether loading or accessing a table you are zeroing in on a particular
pigeon-hole. Take a piece of paper and have 2 rows and 6 columns for
each. Now number the boxes so that you have the ability to go directly
to any one of them - and I DON'T mean box number 10 ! You have to be
more specific than that. Sure working your way through the table, finger
fashion, until you get to 10 is a way of doing it. But would you want to
do the same with a 2-dimensional table, such as I have, where it is 24
rows times 10 columns !

Think it through manually - and you should get there.

Jimmy, Calgary AB
  Reply With Quote
4 24th March 12:06
james j. gavan
External User
 
Posts: 1
Default COBOL-two-level table


Please, please, please before jumping in again.

A respected heart surgeon is teaching qualified doctors as student
surgeons. He takes them through the theory, implications etc., and they
through the glass in an operating room watch him perform real surgeries.

Close to qualification he now wants to get them into the real world.
Perform their own heart operations. Naturally he's stood away from the
table to give his student leeway, but he's there should something go
terribly wrong. Student does quite well, but makes a bit of a mess of
the final suturing - so the surgeon takes over to refine it a bit.

Now ask yourself, is the surgeon doing the student or patient any good,
by jumping in, picking up the cutters, knife or whatever and doing it
showing the student how it should be done. He qualifies the student as
'passed'. Perhaps the former student surgeon on his third op makes a
goof - one very dead patient. Jimmy
  Reply With Quote
5 24th March 20:37
docdwarf@panix.com
External User
 
Posts: 1
Default COBOL-two-level table


On my present client's site they're used as a backbone to the processing
and this might provide a kind of readily-grasped demonstration. For
reporting hours worked by a given employee... the simplest sort of record
would show that employee-number XA1 worked regular hours (type 100) on
Monday through Friday. Given an input layout of:

01 HRS-WKD-REC.
05 EMPNO PIC X(03).
05 HRSTYP PIC X(03).
05 DAYWKD OCCURS 14 PIC 99V99.

.... then the actual data-record (given DAYWKD(1) = Sunday and DAYWKD(7) =
Saturday) might look something like:

XA11000000080008000800080008000000

.... or a reasonable facsimile thereof. Now assume a similar week with a
paid holiday (Hours TYPe 200) on Tuesday; to accurately reflect the
employee's time one would need two records:

XA11000000080000000800080008000000
XA12000000000008000000000000000000

.... showing 0 Regular Hours on Tuesday and 8 Paid Holiday hours on the
same Tuesday. When the working-storage record is coded to reflect the
possibility of multiple records of this sort it might be:

01 HRS-WKD-REC OCCURS 100.
05 EMPNO PIC X(03).
05 HRSTYP PIC X(03).
05 DAYWKD OCCURS 14 PIC 99V99.

.... and after loading with this employee's data the empty Tuesday in
Regular Hours record would be DAYWKD(1,3) while the Paid Holiday hours
would be found in DAYWKD(2,3).

It ain't graphically interfaced, no... it's just the guts of a system that
close to 70,000 people rely on to get paid every other week.

DD
  Reply With Quote
6 25th March 00:56
judson mcclendon
External User
 
Posts: 1
Default COBOL-THREE-level table


Curious, I did a brief search for times I had used a 3 dimensional table
(don't think I ever used more than 3), and came up with the following. I
think the background for this program is interesting.

county, then make that information available to any other OB/GYN in the
county to whom the mother might go for a problem or delivery. It was an easy
system to write, but boring, no challenge. As part of OBAR, they wanted a
separate but related Ultrasound component that collected a number of
measurements from the ultrasound exams, and for each exam print a data sheet
with graphic charts plotting fetal growth against norms using several
different formulas for calculating fetal growth. Everything but printing the
graphical charts was a piece of cake. But writing a COBOL program (the user
didn't have any other language programmers and wanted to be able to maintain
the program) on an EBCDIC mainframe to print a graphics chart on an 8-bit
graphics laser printer connected over a 7-bit ASCII communication line
running Burroughs/Unisys Poll/Select protocol was a seriously non-trivial
task. My client was convinced it was impossible without inordinate costs.

I started by writing a basic graphics library in COBOL, bit plot, line draw,
character draw, the works. For simplicity, I used 4-bit digits as 'bits',
which the Unisys A Series could easily access in COBOL. It was really
strange writing Bressenham's line drawing algorithm in COBOL. Anyway, that
was lots of fun and permitted creating a graphic chart in the COBOL program.

But the really fun part was printing the chart on the laser printer. I wound
up constructing the printer graphics command sequences in memory, breaking
them down into 6-bit chunks, translating those into EBCDIC characters which,
when translated to ASCII by the commuincations hardware, would result in
printable ASCII characters which, when bit shifted to the left, resulted in
the original 6-bit chunk. I sent these to the printer, delimited by escape
in and escape out character sequences. I then wrote an assembly language
printer driver that, when loaded onto the PCs where the laser printers were
connected, that were running the terminal emulation software that connected
the PCs and printers to the mainframe, would work normally until it saw the
escape in sequence denoting the beginning of the graphics chunks. The driver
then reassembled the chunks and sent them to the laser printer, until the
escape out sequence was encountered. It worked great, but explaining how
this worked to the MIS director caused his eyes to become a bit unfocused.
:-)

Anyway, below is a section of the table used for character plotting, and it
is a 3 dimensional table: character, bit-row, bit-column.

************************************************** ****************
* *
* L E T T E R B I T M A S K T A B L E *
* *
* THIS IS THE LETTER 'BIT MASK' TABLE FOR THE GRAPHICS *
* PRIMITIVE DRAW LETTER ROUTINE. *
* *
************************************************** ****************
01 LETTER-BIT-TABLE.
03 LBT-VALUES.
05 FILLER PIC X(01) VALUE "?".
05 FILLER PIC 9(08) COMP VALUE 01111100.
05 FILLER PIC 9(08) COMP VALUE 11000110.
05 FILLER PIC 9(08) COMP VALUE 11000110.
05 FILLER PIC 9(08) COMP VALUE 00001100.
05 FILLER PIC 9(08) COMP VALUE 00011000.
05 FILLER PIC 9(08) COMP VALUE 00011000.
05 FILLER PIC 9(08) COMP VALUE 00011000.
05 FILLER PIC 9(08) COMP VALUE 00000000.
05 FILLER PIC 9(08) COMP VALUE 00011000.
05 FILLER PIC 9(08) COMP VALUE 00011000.
05 FILLER PIC 9(08) COMP VALUE 00000000.
*
...
*
05 FILLER PIC X(01) VALUE ",".
05 FILLER PIC 9(08) COMP VALUE 00000000.
05 FILLER PIC 9(08) COMP VALUE 00000000.
05 FILLER PIC 9(08) COMP VALUE 00000000.
05 FILLER PIC 9(08) COMP VALUE 00000000.
05 FILLER PIC 9(08) COMP VALUE 00000000.
05 FILLER PIC 9(08) COMP VALUE 00000000.
05 FILLER PIC 9(08) COMP VALUE 00000000.
05 FILLER PIC 9(08) COMP VALUE 00001100.
05 FILLER PIC 9(08) COMP VALUE 00001100.
05 FILLER PIC 9(08) COMP VALUE 00001100.
05 FILLER PIC 9(08) COMP VALUE 00011000.
*
03 LBT-LETTERS REDEFINES LBT-VALUES
OCCURS 18 TIMES
INDEXED BY LBT-XLET.
05 LBT-LETTER PIC X(01).
05 LBT-ROW OCCURS 11 TIMES
INDEXED BY LBT-XROW.
07 LBT-BIT PIC 9(01) COMP
OCCURS 8 TIMES
INDEXED BY LBT-XBIT.
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
  Reply With Quote
7 25th March 00:56
heybub
External User
 
Posts: 1
Default COBOL-two-level table


The problem occurs only if the student/doctor has never been in a room with
two tables.
  Reply With Quote
8 25th March 00:56
docdwarf@panix.com
External User
 
Posts: 1
Default COBOL-two-level table


There was an old, bad joke about something similar... the punch-line being
'So the doctor says to the waiter 'I'm sorry, this isn't my table.'!'

DD
  Reply With Quote
9 25th March 00:56
chuck stevens
External User
 
Posts: 1
Default COBOL-THREE-level table


It's not surprising that you didn't use more than three dimensions very
often; in ANSI X3.23-1974, anything beyond that is an implementor-defined
extension. ANSI X3.23-1985 increased this to require support for
seven-dimensional tables.

-Chuck Stevens
  Reply With Quote
10 25th March 08:30
judson mcclendon
External User
 
Posts: 1
Default COBOL-THREE-level table


I don't remember ever using a compiler that didn't support more than three.
Didn't the old Medium System COBOL 68 compiler support subscripts up to the
limit imposed by having only 59 level numbers (i.e. 58)? Or am I imagining
that?
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666