by COBS Tech Support » Sat Apr 22, 2006 12:25 am
There are many ways you could approach doing this. One way is to design a card file that holds the stock group, and a number range for assignment to product items. Then add a script to the stock control screen to automatically assign these numbers to your inventory.
1. Build a new card file with these fields:
CODE, 8 wide, type character, ascending sort, specify the Input Clause as: @!
ID1, (whatever length is applicable), type numeric.
ID2, (whatever length is applicable but make it the same as ID1), type numeric.
When you save the card file call it "CardNum"
2. Open the Screen Builder, and then the Stock screen.
From menu select File|Screen Script
Paste the following script here:
* Save event
If Mode = 3
If IsEmpty(SCRRead("NAME")) .AND. .NOT. IsEmpty(SCRRead("TYPE"))
OpenTable("Cardnum")
If CardNum->(Find(SCRRead("TYPE")))
If CardNum->ID1 >= CardNum->ID2
Echo("No more numbers are available for this product. Please revise number range in Cardnum card file.")
Return FALSE
Endif
If CardNum->(LockRecord())
SCRWrite("NAME", CardNum->ID1)
CardNum->ID1 := CardNum->ID1 + 1
CardNum->(UnlockRecord())
Endif
Endif
Endif
Endif
Return TRUE
Some things to note about the above script:
A. You'll have to add number ranges for each stock group you're setting up inside the card file.
B. If the stock item has a stock group and a product code isn't assigned, this script will automatically assign the next available number within the range specified inside the card file.
C. If the product code is filled in, this script does nothing.
D. If the card file record for the group has not been entered, this script does nothing.