Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table entries

Status
Not open for further replies.

carolly

Programmer
Aug 2, 2001
27
AU
I have 2 input files to read. The first one CUSTOMER-FILE has 6 records that I can load directly into my 2 dimensional 6 x 4 table. The problem that I am having is loading the data from the USER-FILE into the same table as it has 15 records and some of those records will have the same ID number 4 times. So what I am required to do is check to see if the ID matches the ID's already in the table and increment the relevant position in the table.
At present I have the following CUSTOMER (CUST-SUB) from the CUSTOMER-FILE and USER-ID from the USER-FILE.
I have tried a PERFORM UNTIL USER-ID = CUSTOMER (CUST-SUB) OR CUST-SUB > 6
I then increment the subscript DAYS-SUB and move the records into the table - but it is not working.
 
Did the program compile?

If not what errors?

Did you Run it?

If so what made it stop running and what were the values of the incorrect subscripts when it stopped. What line of code did it stop on?

You may want to display the value of the sub-script as it cycles through the varying or what ever. Try reducing the test value by one for the varying statement and see what happens.

If you can step through the program do that till it stops. If you can print out a dump if the program crashes if that option is available. That lets you see the vallues of all of the variable at that time. If you do not like my post feel free to point out your opinion or my errors.
 
Hi Carol,

How do you have the table defined? What data from the cust & user files are moved into the tbl? What data does the user & cust files contain?

When you understand that you can code a rtn to load the tbl.

E.g.:

01 tbl.
05 cust-entry occurs 6 times.
10 cust-nbr pic x(005).
10 cust-name pic x(025).
10 cust-addr pic x(030).
10 cust-etc pic x(040).
10 cust-user-entry occurs 4 times.
cu-nbr pic x(004).
cu-etc pic x(006).

perf 7000-read-cust-rec
if cust-eof
display 'error!!!! cust file is empty - aborting run'
perf 9999-error-out
end-if
if user-eof
display 'error!!!! user file is empty - aborting run'
perf 9999-error-out
end-if
perf 1000-proc-custs varying csub from +1 by +1
until cust-eof
.
1000-proc-custs.
move cust-data, etc. to tbl-cust-data(csub)
perf 1100-proc-users varying usub from +1 by +1
until cust-cust-nbr not = user-cust-nbr
perf 7000-read-cust-rec
.
1000-proc-users.
move user-data, etc. to tbl-cust-data(csub,usub)
perf 7100-read-user-rec
.

The read routines:

read the rec INTO ws-rec area
at end move high-vals to the rec key, set eof switches

Once you've got the table loaded, you can use the AFTER clause of the perf stmt to search the table. The clause works just the way you want it to. It will search c1u1, c1u2, c1u3, etc., c2u1, c2u2, c2u3, etc.,
etc. Read the manul for the proper coding details.

HTH, Jack.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top