Skip to Content
author's profile photo Former Member
Former Member

Batch detail report Purchase against sale problem

Hello

i want batch detail as follows

Batch Num , ItemCode, Pur Qty,Pur Price, Vendor Name, Sale Qty , Sale Price, Cust Code/Name Balance QTY

When i enter the Doc no of Purchase Invoice the result should shows as follows,(Items are Batchwise ) (I want to show Purchase Invoice against sale)

I done in crystal Report for that I take OPCH,PCH1,IBT1,INV1,OINV,IBT1_SALE

The Query i copy from Crystal is as follows, My result is as i want but only sale price can't display properly

SELECT "IBT1"."BatchNum", "IBT1"."DocDate", "IBT1"."ItemName", "IBT1"."Quantity", "PCH1"."Price", "IBT1"."ItemCode", "IBT1_SALE"."Direction", "IBT1_SALE"."Quantity", "IBT1"."CardName", "IBT1"."CardCode", "IBT1_SALE"."CardCode", "IBT1_SALE"."CardName", "OPCH"."DocNum", "OPCH"."NumAtCard"

FROM (("satyam"."dbo"."OPCH" "OPCH" INNER JOIN "satyam"."dbo"."PCH1" "PCH1" ON "OPCH"."DocEntry"="PCH1"."DocEntry") INNER JOIN "satyam"."dbo"."IBT1" "IBT1" ON (("PCH1"."ItemCode"="IBT1"."ItemCode") AND ("PCH1"."DocEntry"="IBT1"."BaseEntry")) AND ("PCH1"."LineNum"="IBT1"."BaseLinNum")) INNER JOIN "satyam"."dbo"."IBT1" "IBT1_SALE" ON ("IBT1"."BatchNum"="IBT1_SALE"."BatchNum") AND ("IBT1"."ItemCode"="IBT1_SALE"."ItemCode")

WHERE "OPCH"."DocNum"=541 AND "IBT1"."DocDate">={ts '2011-04-01 00:00:01'}

ORDER BY "IBT1"."BatchNum"

Suppose i enter Doc No 540 result show without attaching INV1.Pice in Sale price

Batch Num , ItemCode, Pur Qty,Pur Price, Vendor Name, Sale Qty , Sale Price, Cust Code/Name,Balance QTY

PU540-1 I01 05 100 ABCD 3 ZXCV 02

PU540-2 I02 10 120 ABCD - - 10

PU540-3 I03 08 100 ABCD - - 08

But When I attach INV1.Price in sale Price field then result Show,

Batch Num , ItemCode, Pur Qty,Pur Price, Vendor Name, Sale Qty , Sale Price, Cust Code/Name,Balance QTY

PU540-1 I01 05 100 ABCD 3 150 ZXCV 02

I create group by IBT1.BatchNum

But i want it should be Show as,

Batch Num , ItemCode, Pur Qty,Pur Price, Vendor Name, Sale Qty , Sale Price, Cust Code/Name,Balance QTY

PU540-1 I01 05 100 ABCD 3 150 ZXCV 02

PU540-2 I02 10 120 ABCD - - 10

PU540-3 I03 08 100 ABCD - - 08

For Cust Code i create formula as

if {IBT1_SALE.Direction}=1 then

{IBT1_SALE.CardCode}

ELSE

""

For sale Qty i create formula as,

If {IBT1_SALE.Direction}=1 then

{IBT1_SALE.Quantity}

And for Balance Qty formula are,

{IBT1.Quantity}-{@Saleqty}

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2011 at 02:40 PM

    Hi,

    The code you posted doesn't include INV1. Please post the query that has issue.

    Thanks,

    Gordon

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Change:

      INNER JOIN "satyam"."dbo"."IBT1" "IBT1_SALE" ON ("IBT1"."BatchNum"="IBT1_SALE"."BatchNum") AND ("IBT1"."ItemCode"="IBT1_SALE"."ItemCode")) INNER JOIN "satyam"."dbo"."INV1" "INV1" ON (("IBT1_SALE"."ItemCode"="INV1"."ItemCode") AND ("IBT1_SALE"."BaseEntry"="INV1"."DocEntry")) AND ("IBT1_SALE"."BaseLinNum"="INV1"."LineNum")

      To:

      Left JOIN "satyam"."dbo"."IBT1" "IBT1_SALE" ON ("IBT1"."BatchNum"="IBT1_SALE"."BatchNum") AND ("IBT1"."ItemCode"="IBT1_SALE"."ItemCode")) INNER JOIN "satyam"."dbo"."INV1" "INV1" ON (("IBT1_SALE"."ItemCode"="INV1"."ItemCode") AND ("IBT1_SALE"."BaseEntry"="INV1"."DocEntry")) AND ("IBT1_SALE"."BaseLinNum"="INV1"."LineNum")

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.