Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > two lines of one product in report

Forum

Search UsersRules
two lines of one product in report
#1
Interested
Points:: 0
Joined:: Nov 10, 2011

Hello!

I have following query:

Code
SEL ECT DISTINCT
   InventoryJrnlBalanceAndTurnovers.QtyOpeningBalance AS QtyOpeningBalance,
   InventoryJrnlBalanceAndTurnovers.Product AS Product,
   InventoryJrnlBalanceAndTurnovers.QtyClosingBalance AS QtyClosingBalance,
   InventoryJrnlBalanceAndTurnovers.QtyExpense AS Sold,
   InventoryJrnlBalanceAndTurnovers.Product.Description AS ProductDescription2,
   InventoryJrnl.Recorder,
   InventoryJrnlBalanceAndTurnovers.QtyReceipt - CASE
      WHEN VALUETYPE(InventoryJrnl.Recorder) = TYPE(Document.Adjustment)
         THEN InventoryJrnl.Qty
      ELSE 0
   END AS AdjustedPurchase,
   CASE
      WHEN VALUETYPE(InventoryJrnl.Recorder) = TYPE(Document.Adjustment)
         THEN InventoryJrnl.Qty
      ELSE 0
   END AS QtyAdjusted,
   InventoryJrnl.Period
FR OM
   AccumulationRegister.InventoryJrnl.BalanceAndTurnovers(&BeginOfPeriod, &EndOfPeriod, , , ) AS InventoryJrnlBalanceAndTurnovers,
   AccumulationRegister.InventoryJrnl AS InventoryJrnl
WH ERE
   InventoryJrnl.Period >= &BeginOfPeriod
   AND InventoryJrnl.Period <= &EndOfPeriod
   AND InventoryJrnl.Product = InventoryJrnlBalanceAndTurnovers.Product


There is one document "Adjustment" for corrections of quantity. I need to extract this quantity fr om purchase.

For example there were 10 peaces purchased, 7 sold, but 4 were lost. So the user put -3 peaces in the document adjustment. QtyClosingBalance is 10-7-3 = 0.

But after this query for products that had adjusted quantity I get two lines in the report:

Product | BegBalances | Purchased | Sold | ClosingBalance | QtyAdjusted
-----------------------------------------------------------------------

Product1 | 0           | 600      | 577  | 0              | -23
Product1 | 0           | 577      | 577  | 0              | 0
Product2 | 235         | 0        | 210  | 25             | 0

As you can see Product1 had an adjustment -23, that's why there are two lines. I need only one line for each product.

Thank you for any advise!

Profile
#2
Interested
Points:: 0
Joined:: Dec 4, 2017

Dear Lioudmila,

You can use the GROUP BY clause to group your query results by products.

Best regards,
Vladimir Gurov

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.