Products in stock problem

Documents, Catalogs, Registers, Forms, Controls, Interfaces etc.
Posts: 4
Joined: Thu Sep 03, 2009 2:52 pm

Products in stock problem

Postby openhaymer » Wed Sep 09, 2009 2:05 pm

Hello everyone ! :D

I am a begginer in 1C (totally) and I was wondering if there is someone capable to help me in a task that I need to do.Unfortunately as I said before I am a total beginner and my problem is something like this : I need to automatically check the quantity ( in stock )of products that are receipt by a document and this must happen when I post a document that expends them.So my question is simple "How to do that ?"

I have:
Catalog objects : "Products","Warehouses","Clients"
Document objects : "ReceiptOfGoods" and "ExpenseOfGoods" both creating movements in an Accumulation register "BalanceOfMaterials".

I need to get that done soon and thats why I am searching for help everywhere ( I study 1C at home with one book !) I would really be in debt to whoever post me an answer !

IN CONCLUSION : I would fall of my chair if someone posts me the CODE ... Remember that I am a complete novice here in 1C and I need that "check" in the comming week !

Thank you beforehand !


Posts: 74
Joined: Fri Jan 23, 2009 3:15 am

Re: Products in stock problem

Postby Elisy » Mon Sep 14, 2009 4:22 am

It's difficult to write code without information about your document and accumulation register specification.
You should check the quantity in document Posting event. And if you have no quantity you should set Cancel parameter to True to prevent data storing.
You should create Query object with SQL-like request to document Left join AccumulationRegister.BalanceOfMaterials.Balance(...). Then check records in the cycle through Query.Execute().Choose(). Please set the parameter DocumentRef through: Query.SetParameter("DocumentRef", ThisObject.Ref);
The query may be like this (please use Query Builder dialog to construct your own correctly):

Doc.Product AS Product,
Doc.Warehouse AS Warehouse,
Doc.Quantity AS DocumentQuantity,
Balance.QuantityBalance AS BalanceQuantity,
Document.ReceiptOfGoods.Products AS Doc

Product IN (
WHERE Ref = &DocumentRef)

) AS Balance
Doc.Product = Balance.Product
AND Doc.Warehouse = Balance.Warehouse

Doc.Ref = &DocumentRef

Posts: 4
Joined: Thu Sep 03, 2009 2:52 pm

Re: Products in stock problem

Postby openhaymer » Mon Sep 21, 2009 2:17 pm

Thanks Elisy !
You were very helpfull despite my lack of description ! I will try to fix that problem and get the work done.I have some time and now I am confident enough ( after I saw your comment :D )

Thank you again and keep up the good work !

EDIT: I understand the CODE that you've posted me.I've tried it but it's hard for me to get certain things ... Could you explain me the part with the example Query code? I don't know what you mean by

Balance.QuantityBalance AS BalanceQuantity, ... and this "Documents.ReceiptOfGoods.Products AS Doc" ( when I write "Documents.ReceiptOfGoods" out fom the query text , there is no such thing as "Products" after the dot )

Furthermore : my "Product" is a part of the tabular part of the document "ReceiptOfGoods" (the tabular part is called "Products")The "Product" being received is a row from the tabular part and not an Attribute.
My point is that I dont know how to SELECT that field from the tabular part which represents the "Product" that is being received !

~ I'm sorry for being soooo annoying and a waste of time ...

Posts: 74
Joined: Fri Jan 23, 2009 3:15 am

Re: Products in stock problem

Postby Elisy » Tue Sep 22, 2009 6:09 am

Let's clarify how you try to use Query expression because 1C Editor has no IntellySense feature for Queries and it cannot show you members after dot. Your program should be like this:

Query = New Query();

Query.Text =
| Doc.Product AS Product,
| Doc.Quantity AS DocumentQuantity
| Document.ReceiptOfGoods.Products AS Doc
| Doc.Ref = &DocumentRef";

Query.SetParameter("DocumentRef", ThisObject.Ref);

DataReader = Query.Execute().Choose();

This code uses simplified query to view the problem. It selects all Product and Quantity from tabular part Products of ReceiptOfGoods document. If it runs correctly you can add SELECT with balance. The best way is to do this is right clicking on the "SELECT ..." expression and choose Query Builder...

Posts: 4
Joined: Thu Sep 03, 2009 2:52 pm

Re: Products in stock problem

Postby openhaymer » Tue Sep 29, 2009 3:31 pm

Thank you ! I've got it running now ! It works and I added several features to ensure correct output after incorrect user input :) Thank you again and I'm seeing forward to write comments and eventually ask far more speciffic questions in the future.

Return to “User input and data storing”

Who is online

Users browsing this forum: No registered users and 1 guest