Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Just to let you know...what a great site you have. I posted a pretty generic question yesterday and have had 8 responses already, anyway thanks again and keep up the good work..."

Geography

Where in the world do Tek-Tips members come from?

in which there is a reduction in food stocksHelpful Member! 

jezky82 (MIS)
14 Aug 12 3:18
I make food sales program. in which there is a reduction in food stocks. such a sale spaghetti require:


250 gr Spaghetti
200 gr chicken meat
100 g carrots
100 g baby kailan
6 pieces of red chilli
3 tablespoons soy sauce
5 cloves of garlic minced
1 tablespoon instant chicken broth
1 tablespoon fried shallots
1 tsp fine salt
3 tablespoons cooking oil
1 tablespoon cornstarch
then when selling a spaghetti reduce stock as above.
so I created two databases. The first database is the data is the key ingredient of spaghetti and a negative value. The second data is a database of food stocks. so when selling spaghet the first data with the key into the spaghetti will continue my second database based on the total food ingredients will automatically be reduced. is there a shorter way than the way I mentioned please help with sample programs. thank you
Helpful Member!  GriffMG (Programmer)
14 Aug 12 4:23
No, that is the shortest way.

You essentially have a BOM (Bill of Materials, or BOQ Bill of Quantities) and use that to reduce the stock of raw materials by the right amount
when you sell a product.

CODE

FUNCTION SELLPRODUCT
  Parameter m.ProductCode, m.Quantity
  Private m.ProductCode, m.Quantity, m.Success
  m.Success = .f.
  Select tblBOM
  Set order to ProductCode
  Seek (m.ProductCode)
  If Found()
    Success = .t.
    Do While .NOT. EOF() .and. tblBOM.ProductCode = M.ProductCode
      Select tblIngrediants
      Set Order to Ingrediants
      Seek (tblBOM.IngrediantCode)
      if found()
         if tblIngrediants.Quantity >= tblBOM.Quantity * m.Quantity
            replace tblIngrediants.Quantity with tblIngrediants.Quantity -(tblBOM.Quantity * m.Quantity)
         else
            replace tblIngrediants.Quantity with 0
             m.success = .f.
         endif
      else
         m.success= .f.
      endif
      Select fblBOM
      Skip
    EndDo
  EndIF
Return(m.Success) 

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

GriffMG (Programmer)
14 Aug 12 5:50
Sorry, couple of typos in my example!

happy shades

Thank you for the star though

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

OlafDoschke (Programmer)
15 Aug 12 3:46
Well, if you have a table with inventory data and another with BOM as Griff called it, you could do one UPDATE-SQL, too.

assumed ingredients have a stock in an inventorytable and an ingredientID to identify them uniquely, and your bill of material data has a quantity to subtract from stock:

Update inventorytable set stock = stock - bom.quantity from inventorytable inner join bom on inventorytable.ingredientID = bom.ingredientID

This gives you less control about not matched ingredients and what to do about such errors. You can check if _TALLY, the number of updated records, matches the number of bom ingredients as a simple check. But if that doesn't match you have to see what data is wrong or missing.

Bye, Olaf.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close