Purchase Register - Header level query issue

Hi Guru's,
I tried the following query for Purchase Register (Header Level) but I am not able to get the following details -                              1) AP Invoices which are without PO
2) Freight amount not getting reflected
SELECT T0.DocNum as 'PO. No.',
T0.DocDate as 'PO. Date',
M.DocNum as 'A/P Invoice No.',
M.DocDate as 'Inv. Date',
M.CardName as 'Vendor Name',
M.NumAtCard as 'Bill No. & Date',
(Select Sum(LineTotal) FROM PCH1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=8 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
(SELECT Sum(TaxSum) FROM PCH4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
(SELECT Sum(TaxSum) FROM PCH4 where statype=-80 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
(SELECT Sum(TaxSum) FROM PCH4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
(SELECT Sum(TaxSum) FROM PCH4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=7 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
(Select Sum(LineTotal) From PCH3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
M.WTSum AS 'TDS (Rs.)',
M.DocTotal as 'Total (Rs.)'
FROM OPOR T0 INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OPDN T2 ON T2.DocEntry = T1.TrgetEntry
INNER JOIN PDN1 T3 on T3.DocEntry = T2.Docentry
INNER JOIN OPCH M ON M.DocEntry = T3.TrgetEntry
LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry
WHERE M.DocDate >= '[%0]' AND M.DocDate <= '[%1]'
GROUP BY
T0.DocNum,T0.DocDate,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
ORDER BY
T0.DocNum,T0.DocDate,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
Regards,
Abhishek

Hi Abhishek,
Try this Query Report, you will be get the exact result in  this Query.
your requirement.
1. A/P Invoice with Purchase Order.
2. The Freight amount will display the Freight Column in the query.
Try this below Query,
SELECT T0.DocNum as 'PO. No.',
T0.DocDate as 'PO. Date',
M.DocNum as 'A/P Invoice No.',
M.DocDate as 'Inv. Date',
M.CardName as 'Vendor Name',
M.NumAtCard as 'Bill No. & Date',
(Select Sum(LineTotal) FROM PCH1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=7 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
(SELECT Sum(TaxSum) FROM PCH4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
(SELECT Sum(TaxSum) FROM PCH4 where statype=10 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
(SELECT Sum(TaxSum) FROM PCH4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
(SELECT Sum(TaxSum) FROM PCH4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
(SELECT Sum(TaxSum) FROM PCH4 where statype=8 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
(Select Sum(LineTotal) From PCH3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
M.WTSum AS 'TDS (Rs.)',
M.DocTotal as 'Total (Rs.)'
FROM OPOR T0 INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OPDN T2 ON T2.DocEntry = T1.TrgetEntry
INNER JOIN PDN1 T3 on T3.DocEntry = T2.Docentry
INNER JOIN OPCH M ON M.DocEntry = T3.TrgetEntry
LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry
WHERE M.DocDate >= '[%0]' AND M.DocDate <= '[%1]'
GROUP BY
T0.DocNum,T0.DocDate,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
ORDER BY
T0.DocNum,T0.DocDate,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
Regards,
Madhan.

Similar Messages

  • How to Configure Invoice Address tab on Purchase Order - Header Level

    Hi Gurus
    Please assist
    My client want to add the Invoice address on the Purchase Order level Tab, it must be automatically pull through to all the Purchase Orders as they have one Invoicing address.
    Currently the suppliers send invoices to plants instead of HEAD OFFICE for payment
    Regards
    Susan

    Hi,
    Tax condtions shd be given by functional consultants.ABAPers cant decide the tax condtions.
    you can have these condtions in KONV table.
    In item level vbrp-posnr = konv-kposn.
                      ekpo-ebelp = konv-kposn
    at header level as said in the below thread
    Just see this and get back if any concerns
    Regards
    Edited by: Rasheed salman on Dec 2, 2008 6:20 AM
    Edited by: Rasheed salman on Dec 2, 2008 6:22 AM

  • PO HEADER LEVEL의 TOTAL AMOUNT 계산 LOGIC

    제품 : MFG_PO
    작성날짜 : 2004-10-13
    PO HEADER LEVEL의 TOTAL AMOUNT 계산 LOGIC
    ==========================================
    PURPOSE
    Purchase Order 화면의 Header level에 보여주는 Total Amount 계산 logic을
    알아본다.
    Explanation
    Purchase Order 화면에서 PO를 입력하거나 조회해 본 사람은 PO Header level
    에 보이는 Total amount 값은 어느곳에도 저장되지 않는다는 것을 확인 할
    수 있을 것이다.
    이 header level total amount 계산 logic은 다음과 같다.
    1.Purchase Order 화면에서 price와 quantity가 입력될 때 POXPOPOL.pld에
    있는 maintain_po_total이 불려진다.
    이 maintain_po_total procedure는 line amount를 뿌려주기 위해 line에
    정의된 quantity와 price를 고려한다.
    이 line amount sum 되고, header total에 뿌려준다.
    sum(round((quantity*unit_price),precision))-> Header_total
    2.PO를 query 할 때 header amount를 조회하기 위해 POXCOCOB.pls의
    po_core_s.get_total procedure가 불려진다.
    아래의 query가 PO header level total amount 계산을 하게 된다.
    SELECT sum(round((pll.quantity - nvl(pll.quantity_cancelled,0))*
    nvl(pll.price_override,0),x_precision))
    FROM PO_LINE_LOCATIONS PLL
    WHERE PLL.po_header_id = <<po_header_id>>
    AND PLL.shipment_type in ('STANDARD','PLANNED','BLANKET')
    여기에서 precision은 PO.(PO Currency = Functional Currency)에서 사용
    되는 것으로 fnd_currencies에 정의된 currency이다.
    Example
    Reference Documents
    Note 226697.1

    Thought so.
    And therein lies your problem.
    You should avoid updating Oracle tables directly unless you are 100% sure that no relationships are getting violated.
    Updating po line price should be done via interface. I would suggest that you use the po documents interface to change the po line prices. Then you will see the header totals get updated automatically.
    Hope this answers your question
    Sandeep Gandhi
    Independent Consultant
    513-325-9026

  • Additional Data in Header Level for ME51N / ME52N / ME53N

    Dear Gurus,
    I have one requirement related to apply enhancement for additional fields in purchase requisition header level.
    After searching a lot , I dint found any solution for this.
    Does anybody have any solution for this.
    Regards,
    Shibashis.

    I need to add on Tabstrip "Account assignment" for fields
    CO Area and Cost Center text field description ( right side ) for each one.
    How can I do this? Thanks in advance.

  • Down Payment Request at Header Level of PO

    Dear Friends
    We want to create Down Payment Request and subsequently the Down Payment at Purchase Order Header Level. We are looking for a standard solution without any Custom Development.
    While creating a Down Payment Request (F-47) the system does not ask for the reference of the Purchase Order. But if Purchase Order Number is referred then the system will ask for the line item also.
    When we convert this Down Payment Request to Down Payment (F-48), we can refer the Purchase Order Number. If referred, the system asks for the line item also, which becomes mandatory.
    However we want to understand if there is a possibility of posting the Down Payment against the Purchase Order Header.
    This is required, since if there are multiple line items in the purchase order, then creation of Down Payment Request as well as Down Payment becomes a tedious activity in SAP.
    Someone innovative and has already worked on such requirement please reply.
    Regards
    Ketan Patel

    Hi,
    Try the following steps to pay to Vendor w.r.t PO:
    1.Check the Vendor reconciliation A/C,
    2.Go to FS00, and check Filed Status Group,
    3.Go to OBC4, check the Filed Status Group, what u have mentioned for the Vendor reconciliation account.
    4. Go To material management segment and put optional entry for the field of Purchase Order and save.
    5.Now come to F-48, enter the date, vendor, assign the sp.G/L transaction(A),bank sub account, amount,
    then enter, it will take to next screen
    Here you enter amount & your purchase order number with reference to your are going to make the payment. Now simulate and save.
    After the GR & IR is done, Perform F-54 for Down Payment Clearing
    Regards,
    Biju K

  • Purchase register query based on down payment invoice

    Hai All,
    I am creating an invoice based on purchase order.The vat  tax is being calculated in the downpayment. I want the vat to be displayed in the downpayment invoice as well as the a/p invoice but i m not getting it in the a/p invoice. Pls guide me with the linking of tables to get the query working. I have formatted the fields req but could not link the tables...Pls guide me with that...
    Thanks & Regards,
    Neela

    Hi Neela,
    Check the thread.
    Re: Purchase register query based on down payment invoice
    FROM PCH1 T0
    INNER JOIN OPCH T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
    LEFT OUTER JOIN PCH12 T3 ON T1.DocEntry = T3.DocEntry
    LEFT JOIN ODPI T4 ON T1.CardCode = T4.CardCode
    INNER JOIN DPO1 T5 ON T0.ItemCode = T5.ItemCode
    Close the thread, if issue solved.
    Regards,
    Madhan.

  • Purchase Register query

    Hi
    I wrote query for Purchase register
    SELECT M.DocNum AS 'AP Inv. #', M.DocDate as 'Date', M.CardName as 'Vendor Name',M.NumAtCard as 'Bill No. & Dt.',L.ItemCode, L.Dscription,
    (Select Sum(LineTotal) FROM PCH1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=7 and DocEntry=M.DocEntry) as 'ACD (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-55 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=10 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=8 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
    (Select Sum(LineTotal) From PCH3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM OPCH M LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry
    WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]')
    GROUP BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal,L.ItemCode,L.Dscription
    ORDER BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal
    I want the row level amount for Base amount field But it is giving me the total amount including every line item. excluding of tax.
    Same with the tax amount. I tried removing sum but it is not helped
    Regards
    Shashi
    Edited by: shashi mantripragada on Dec 29, 2008 10:11 AM
    Edited by: shashi mantripragada on Dec 29, 2008 12:05 PM
    Edited by: shashi mantripragada on Dec 29, 2008 2:14 PM

    Hi Shashi,
    You could use this query for tax amount and row level base amount
    SELECT M.DocNum AS 'AP Inv. #', M.DocDate as 'Date', M.CardName as 'Vendor Name',M.NumAtCard as 'Bill No. & Dt.',L.ItemCode, L.Dscription,L.LineTotal,L.vatsum,
    (Select Sum(LineTotal) FROM PCH1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=7 and DocEntry=M.DocEntry) as 'ACD (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-55 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=10 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=8 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
    (Select Sum(LineTotal) From PCH3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM OPCH M LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry
    WHERE (M.DocDate >= %0 AND M.DocDate <= %1)
    GROUP BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal,L.ItemCode,L.Dscription,L.LineTotal,L.vatsum
    ORDER BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal,L.LineTotal,L.vatsum
    Regards,
    Vijay Kumar
    SAP Business One Forums Team

  • Purchase Order Total Amount at Header level and Report Execution

    Dear Experts,
    Here by i am facing problem with Purchase Order Total amount.
    I have local Pricing Procedure for price stipulations (like discounts, Freight, packaging). the calculation at item level is correct. tax calculation is done by tax code. The total PO Price is including all items in PO and tax amount. But at header level conditions net value is showing only gross price.
    How to pick up total price including tax amount at header level conditions?
    Please provide me solution on it ?

    Dear Experts,
    Here by i am facing problem with Purchase Order Total amount.
    I have local Pricing Procedure for price stipulations (like discounts, Freight, packaging). the calculation at item level is correct. tax calculation is done by tax code. The total PO Price is including all items in PO and tax amount. But at header level conditions net value is showing only gross price.
    How to pick up total price including tax amount at header level conditions?
    Please provide me solution on it ?
    Edited by: Kiran Mujumdar on Feb 23, 2009 7:08 PM

  • Customized Query for purchase register

    Hi All,
    I need a query for purchase register which gives excise information with biferication.
    OPCH, PCH1, ORPC, RPC1 and IEI4
    In excel reporter we get the purchase register report But excise amount does not come in that report.
    So, I need Customised report for that.
    Regards
    Shashi

    hi shashi,
    SELECT M.DocNum AS 'AP Inv. #', M.DocDate as 'Date', M.CardName as 'Vendor Name',M.NumAtCard as 'Bill No. & Dt.',
    (Select Sum(LineTotal) FROM PCH1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=7 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=10 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=8 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
    (Select Sum(LineTotal) From PCH3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM OPCH M LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry
    WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND (T.TrgetEntry = ' ')
    GROUP BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    ORDER BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    Jeyakanthan

  • Issue in Purchase Register

    Hi All,
    I am facing a  typical scenario while running the purchase register.
    Most of the grpo's that were created during the period of 01-04-09 to 30-09-09 are with the excise tax codes and while creation of the a/p invoices, the tax code has been changed to exempt. Also, a good number of GRPO's are still open.
    Also, in a few cases, the grpo has been created on 11-10-09 and the invoice for this grpo has been created on 30-09-09 (the system should not have allowed this.. is this a bug in the system??)
    How do I correct these go get a proper report in the purchase register??
    A. Should I copy the open GRPO's to the A/P invoice and then run the purchase register??
    B. Correct the entries and then run the purchase register? (What about the GRPO's that have been copied to A/P Invoices? Should i create a credit memo for this?)
    C. First follow point A, get the reports and then manually reconcile these??
    Please provide solutions to solve this issue.
    Thanks in advance,
    Joseph Antony

    Hi Joseph......
            from your scenario it seems you are not keeping any link in between base and target document.
            Your should always put the link by copying.....
    Regards,
    Rahul

  • Error in Purchase Register Query

    Hello All..
    I made a Query of Purchase Register and its working fine when my Invoice is of One item But when i am taking two or three items then its showing wrong result of all the taxes..
    Please Sort it out as soon as possible
    ELECT M.DocNum AS 'AP Inv. #', M.DocDate as 'Date', M.CardName as 'Vendor Name',M.NumAtCard as 'Bill No. & Dt.',L.ItemCode, L.Dscription,
    (Select Sum(LineTotal) FROM PCH1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=7 and DocEntry=M.DocEntry) as 'ACD (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-55 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=10 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=8 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
    (Select Sum(LineTotal) From PCH3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM OPCH M LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry
    WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]')
    GROUP BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal,L.ItemCode,L.Dscription
    ORDER BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal

    Hi  Gordon..
    Can you explain with any example..
    Thanks

  • Message Mapping Issue on header level

    HI all,
    I am doing File to IDOC scenario where I am having issue wiht mapping :
    Flat File
    Row -0Unbound
    FieldA1..1
    FieldB1..1
    IDOC
    --Segment
    ---Field1
    ---Field2
    Segment1
    Field11
    FieldA is Order number.. IDOCs will generate up on order numbers change... FieldB is discount... If Discount is avaliable in any of the order number then I need to Pass YES orelse NO... Segment is a header segment where I need to pass whether discount is YES or NO... Suppose there are 5 rows of same order with discount in 4 row then I need to pass YES if discount doesnt avaliable in all 5 rows then NO..
    Row
    --FieldA<123>
    --FieldB<>
    </Row>
    Row
    --FieldA<123>
    --FieldB<>
    </Row>
    Row
    --FieldA<123>
    --FieldB<10>
    </Row>
    Row
    --FieldA<222>
    --FieldB<>
    </Row>
    Row
    --FieldA<222>
    --FieldB<>
    </Row>
    IDOC
    --Segment
    ---Field1<123>
    ---Field2<YES>
    Segment1
    Field11
    </IDOC>
    IDOC
    --Segment
    ---Field1<222>
    ---Field2<NO>
    Segment1
    Field11
    </IDOC>
    Any inputs how to get value on header level? I tried but I am able to get only first value..not drilling down to each value depending on order number?
    Thanks
    Rajeev.

    Hi Prakasu,
    Its working but there is one issue: 
    If one fo the discount value is 99.00 then I need to pass NO.. How can I achieve this? I used the UDF but it is taking only the highest value which is 99.00 but even if it is 99.00 I need to pass NO..
    Suppose if first row discount is 99.00 and second row its 2,00 then I need to pass YES as it has 2,00 in the second row..
    Row
    --FieldA<123>
    --FieldB
    </Row>
    Row
    --FieldA<123>
    --FieldB<99>
    </Row>
    Row
    --FieldA<123>
    --FieldB<>
    </Row>
    Row
    --FieldA<222>
    --FieldB<8>
    </Row>
    Row
    --FieldA<222>
    --FieldB
    </Row>
    IDOC
    --Segment
    ---Field1<123>
    ---Field2<NO>
    Segment1
    Field11
    </IDOC>
    IDOC
    --Segment
    ---Field1<222>
    ---Field2<YES>
    Segment1
    Field11
    </IDOC>
    First row value is 99 and Null it has to give NO as if discount has 99 then it should pass NO.. in the second order first row is 8 and second row is null.. it should give YES but it is giving NO becuase if is taking only the last value in the Context change..
    Any inputs how to achieve this?
    Thanks
    Rajeev.
    Edited by: rajeev raj on Nov 23, 2009 2:52 PM

  • PO Form Issue with Header Level Changes

    Issue:
    It has been observed that whenever changes are done in PO Header (e.g. Header Text), system prints Billing Address and Communications Details as blank. If the changes are made to Line Item level along with header then system prints the Billing address and Communication Details correctly.
    Analyse:
    we are using the SELECT statement below to fetch the field for
    Billing Address and Communications Details.
    SELECT SINGLE
    mandt z_plant z_company_code z_toll_free_no z_local_no z_fax_no
    z_email z_name1 z_name2 z_street z_house_no z_district z_post_code
    z_city z_country z_vat_no z_loc_term_cond z_langu
      FROM zptp_poformdata
      INTO w_poformdata
      WHERE z_plant = ls_ekpo-werks
    AND   z_company_code = ls_ekpo-bukrs .  
    And when we only change the header level  data no value is passing for comany code and plant . as a result Select statement gets failed and we are getting blank window.
    NOTE: we are getting blank box only when we fire a print or fax.The preview is coming fine.

    by asking so many questions in a single post,you are violating the rule of engagement given below
    Only One Question Per Posting
    For each question that you have, make a separate posting. Don't ask multiple questions in one posting, this is confusing for people and might not get answered, since the subject line does not reflect all your problems. If a new and unrelated question comes up during a thread, start a new thread.

  • Partywise & Itemwise purchase register query

    Dear Expert,
    I am new in SAP.
    I need Partywise & Itemwise purchase register query.
    BR
    Deep

    Dear Deep,
    Welcome To SAP Community Network Forum...
    Check this link...
    http://forums.sdn.sap.com/thread.jspa?messageID=6730337#6730337
    Thanks,
    Srujal Patel

  • ERLA/NORM, Header and Item Level Pricing Issue

    Dear All,
    I have an issue wherein, even though I have used ERLA for BoM Item and NORM for Subitems, in sales order Conditions, both header level and item level pricings are active.
    Correct me if I am wrong, item level pricing should get deactivated.
    Kindly let me know if there is any issue in the settings.
    The default item categories appearing in the sales document is TAQ for higher level item and TAE for subitems
    Thanks and Regards
    Adithya
    Edited by: Adi1976 on Feb 6, 2012 12:08 PM

    Item Category group for Subitems should be ERLA, not NORM.
    Sales Order
    - Item Cat Group
    - Higher I Cat
    - I Cat
    OR
    ERLA
    TAQ
    OR
    ERLA
    TAQ
    TAE
    Try & share feedback.
    Regards
    JP

Maybe you are looking for