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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Length Records

Status
Not open for further replies.

gonzilla

Programmer
Apr 10, 2001
125
US
Hi everyone,

The final part of our lab deals with order entry. We are using variable length records to allow for up to 10 items to be ordered in a single transaction. There is no stipulation on quantity of each item (well, actually 9(4)), just that no more than 10 items can be ordered. Here is the order-file rec:

(THESE ARE NOT MY DATA-NAMES)

01 ORDER-REC
05 ORD-DATE PIC X(8)
05 ORD-PO PIC X(6)
05 ORD-CUST-ID PIC X(5)
05 ORD-TOTAL-COST PIC 9(5)V99
05 NUM-OF-PRODUCTS PIC 9(2)
05 ORDERED-ITEMS
OCCURS 1 TO 10 TIMES
DEPENDING ON NUM-OF-PRODUCTS
10 ITEM-PROD-ID PIC X(5)
10 ITEM-QUANTITY PIC 9(4)
10 ITEM-UNIT-COST PIC 9(3)V99
10 ITME-TOTAL-COST PIC 9(4)V99

Since our book doesn't cover variable length records, I'm just wondering how this is handled.

I need the screen to show up to 10 lines of orders, entered one at a time. Does this get read in like a table and I display INFORMATION (SUB) for each line? I don't want the previous oreder line to dissappear when the next on is being accepted. Does the table get loaded after each order line is complete and the record only get written once to the order-file when the order is complete?

I'm also wondering how DEPENDING ON NUM-OF-PRODUCTS
works because the number of products (1 - 10) isn't known until after the order is complete...

I'm not looking for any code because I haven't really begun it myself, just a direction to go in. I think I'm on the right track, just not too sure. Thanks!

-Tyler
 
We meet again, Dr Tyler:

In no particular order:

Your guess about the subscript was right on. You should code the 10 screen lines as a table w/10 entries (no odo).

You don't know how many prods were ordered till you finish screen processing (right again!). What I suggest is first move 10 to NUM-OF-PRODS; process the screen keeping count of the prods: when finished move the count to NUM-OF-PRODS.

The important thing to remember is to keep track of what the NUM fld s/b as you're moving data to the ODO table. For example, if the table had 2 items in it and you add 2 more, it's your responsibility to update the NUM fld to 4. You don't have to update it immediately, just make sure you set it before you have to reference the table again.

The O/P file is written only once for each screen interaction w/the term user. You loop thru the read-line proc line logic till youv'e processed all 10 display lines. Notice I said 10 even if they only fill 1. Reason: no guarantee they won't skip a line between entries.

I may have left something out, but this should get you going.

Regards, Jack.

One final warning: make sure the ODO fld is set to the correct value before you write the rec. That's what makes the file variable.

 
Jack,

Thanks for the help! You have always given great advice and I appreciate it.

Now, off to code I go.

-Tyler
 
Hi,

I guess after attempting some of this I realize that I don't understand tables as well as I thought. I'm just a little confused as to what I ACCEPT in the proc div. Using ORDER-REC from above, if the screen looks like this:

Prod # Quantity Item Description Unit $ Total $
x(6) 99 x(40) $999.99 $9999.99

After the user enters in the prod #, the description and unit cost pops up, then they enter the quantity and the total pops up and moves to the next line. Here is what I have for the table to read in these values:

01 SCREEN-TABLE.
05 EACH-LINE OCCURS 10 TIMES.
10 T-PROD-ID PIC X(6).
10 T-PROD-QUAN PIC 99.
10 T-PROD-DESC PIC X(40).
10 T-PROD-COST PIC 9(3)V99.
10 T-TOTAL-COST PIC 9(4)V99.

I have to ACCEPT the PROD-ID from the indexed product file:

01 INDEX-PROD-REC
05 PROD-ID PIC X(5).
05 PROD-DESC PIC X(40).
05 PROD-COST PIC 9(2)V99.

...so that I can check to make sure it's in there - no problem. Now, do I then move that to the T-PROD-ID (LINE-SUB) or the ITEM-PROD-ID (ORDER-SUB)? Then, do I ACCEPT the T-PROD-QUAN (LINE-SUB)...or do I ACCEPT the ITEM-PROD-QUAN (ORDER-SUB) as per the ORDER-REC?

You see, I'm confused as to how that odo table in the
ORDER-REC is loaded after all of the information is ACCEPTED. Is it...

PERFORM VARYING (ORDER-SUB) UNTIL (ORDER-SUB) > NUM-OF-PRODUCTS
MOVE T-VALUE (LINE-SUB) to ITEM-VALUE (ORDER-SUB)
END-PERFORM

How does the (LINE-SUB) get incremented along with the (ORDER-SUB)? I think I'm confused because that odo table is part of a record instead of just a stand alone table and I've never loaded a table into a table. Does that make it different?

Hope this makes sense as to where I'm confused. Thanks again for your help.

-Tyler
 
Hi Tyler,

I'm not sure how the app works, but I aasume that the screen you present to the user begins a new order, that is, when you present the screen to the user you have to "calculate" the new ord# and present it along w/the other info.

e.g. ord date: the 10 product lines; who keyed the order; etc.

When you retrieve all the data entered and process the ord, the last thing you do is WRITE an order rec to the ord file. If the prob stmt calls for "order updates" it's a little more complicated, but I'll leave that for you.

A hint re. the tbl handling: you'll be moving from one table to another, so you'll have to index (or subscript) both the sending & recving flds. You're pretty much on target with the perform; just remember that the scrn-sub and the rec-sub may not be the same (because of possible blank lines in the screen), just add 1 to the non-
varied sub from the performed pgraph.

One thing that confuses me: you mention that you supply the prod price after the user enters the prod id, but you don't mention a product file. There should be one.

This is getting a little involved. If you want to you can send the specs to me via e-Mail: jacksleight@hotmail.com. Maybe it's better no to clutter up the forum w/detail stuff.

Regards, Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top