New programmer / Coding "do loop" process

butros33

New Member
I am relatively new to programming in Progress and I am currently trying to add some new code to an existing program to allow for the following scenario:

A pricing record contains various levels based on quantity breaks ( ex - qty less than 2 gets prc1, qty of 2 gets prc2, qty of 3 gets prc3, etc.) and I am trying to figure out the best approach to read the record and determine the correct price based on the quantity being input.

The record can contain up to 9 price levels associated with up to 8 quantity break levels

prc1 qty1
prc2 qty2
prc3 qty3
prc4 qty4
prc5 qty5
prc6 qty6
prc7 qty7
prc8 qty8
prc9

As i mentioned above in this example anything less than qty1 gets prc1, qty equal to qty1 but less than qty2 gets prc2, and so on.

Any time either the qty or prc level contains a zero I would need to go back to the last available level greater than zero and use that if the qty is greater and no further levels exist.

Any suggestions on how to write a code loop to read the record based on the qty input and pull the correct prc level would be greatly appreciated!
 

Gasoline

New Member
Hi,

What is the structure of the table?
Does it have a quantity field with 8 extents and a price field with 9 extents or does it have 8 quantity fields and 9 price fields?
 

whwar9739

Member
I might suggest using something more along the lines of:

qty1 qty2 prc1
qty3 qty4 prc2

where you could do if the quantity is between qty1 and qty2 then prc1 is the price and it would be inclusive.


Or you could do a case statement:

Code:
CASE quantity:
  WHERE quantity <= qty1 THEN prc1.
  WHERE quantity <= qty2 THEN prc2.
  WHERE quantity <= qty3 THEN prc3.
  ...
  OTHERWISE qty9.
 
Top