Query - A/P Invoice

Hi all experts.
I wonder if you could help me create a query. The information I'm looking for is contained in the A/P Invoices and also involves profit centres and accounts.
We have a case where our client has made transactions containing profit centre on the rows of the A/P Invoice u2013 and this used to be attached in the journal entry (In SAP B1 2005A at least). In SAP B1 2007A it seems that GL accounts defined as type u201COtheru201D doesnu2019t support the use of profit centre. The account type needs to be of type u201CIncomeu201D or u201CCostu201D to be able to maintain the profit centre in the journal entry. We have now changed this, but have some transactions from February and March that we need to change (update) the profit centre on. The plan is to do this through some bookkeeping, but for that I need the amounts to use.
So here is the query I would require for this task:
I would like to list all instances of A/P Invoices and their corresponding (from rows table) account code (user select the account code) and also their corresponding profit centre - for a given period of time (selected by user, date between dateA and dateB). It would also be essential to have the amount summarized for each profit centre and a total amount for the account.
Anyone care to give it a try?
Appreciate all help I can get on this case.
Thanks and regards, Runar Wigestrand.
Edited by: Runar Wigestrand on Mar 18, 2009 2:58 PM

Please try this to start:
SELECT DISTINCT T0.Project, T0.AcctCode, T2.AcctName, SUM(T0.LineTotal) 'Total'
FROM DBO.PCH1 T0
INNER JOIN DBO.OPCH T1 ON T1.DocEntry = T0.DocEntry
INNER JOIN DBO.OACT T2 ON T2.AcctCode = T0.AcctCode
WHERE T1.DocDate Between '[%0]' AND '[%1]' AND T2.AcctCode LIKE '[%2]%'
GROUP BY T0.Project, T0.AcctCode, T2.AcctName
Thanks,
Gordon

Similar Messages

  • Table for 2way,3way matching .query to generate invoice with 2 ways matchin

    hi
    table for 2way,3way matching .query to generate invoice with 2 ways matching
    plz help me
    thanks

    Hello John, I put the (1,2,3) list in the query to show it works with multiple invoices.
    You should comment out the conditions:
    select a.invoice_no, b.child, sum(a.amount) from invoice_detail a,
    select
    child,
    decode (instr(scbp,'.'),0,scbp,
           substr(scbp, 1, instr(scbp,'.') -1)
           ) starting_child
    from (
    select ltrim(sys_connect_by_path(child,'.'),'.') scbp,
    child from
    element_relation
    start with child in (select element_id from invoice_detail /* where invoice_no in (1,2,3) */)
    connect by child = prior parent
    ) b
    where a.element_id = b.starting_child
    /* and a.invoice_no in (1,2,3) */
    group by a.invoice_no,b.child
    order by 1,2to show it works for all invoices
    regards, Tony

  • Query for multiple invoice numbers.

    Hi,
    My question is if I can add multiple invoice numbers in the search field "invice number"?
    For example when I receive a balance confirmation request from a supplier and their list contains 10 invoices. Can I do a search for all 10 at the same time or I can olny do a search one by one?
    Thank you!
    Angie

    Hi,
    there's no direct possibility to query for multiple Invoice number in terms of entering e.g. 5 number for a query.
    But you can work with placeholders '_' and '%' to find multiple invoices at one time. Underscore sign stands
    for exactly one character which can have multiple value, percentage sign for multiple ones.
    Example (assuming you are using letters and numbers for invoice numbering):
    When entering 'A12_' as search String, invoices from 'A120' to 'A12z' would be found.
    When using 'A12_01_' all invoices from 'A120010' to 'A12z01z' would be found.
    When using 'A12%' all invoices starting with 'A12' - no matter about the rest would be found.
    These are only a few examples but i think when using a clever combination of wildcards and parts of the
    invoices - which often share a common component, if the invoices come from the same vendor - you'll get
    at least a small step farther.
    Regards

  • Query help on Goods Receipt Query with AP Invoice

    Looking for a little help on a query.  I would like to list all the goods receipts for a given date range and then display the AP Invoice information (if its been copied to an AP Invoice).  I think my problem is in my where clause, I plagerized an SAP query to show GR and AP from a PO as a start.  SBO 2005 SP01.  Any help would be great appreciated.  Thanks
    SELECT distinct 'GR',
    D0.DocStatus,
    D0.DocNum ,
    D0.DocDate,
    D0.DocDueDate,
    D0.DocTotal,
    'AP',
    I0.DocStatus,
    I0.DocNum ,
    I0.DocDate,
    I0.DocDueDate,
    I0.DocTotal,
    I0.PaidToDate
    FROM
    ((OPDN  D0 inner Join PDN1 D1 on D0.DocEntry = D1.DocEntry)
    full outer join
    (OPCH I0 inner join PCH1 I1 on I0.DocEntry = I1.DocEntry)
    on (I1.BaseType=20 AND D1.DocEntry = I1.BaseEntry AND D1.LineNum=I1.BaseLine))
    WHERE
    (D1.BaseType=22 AND D1.DocDate>='[%0]' AND D1.DocDate<='[%1]')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry
    FROM PDN1 WHERE BaseType=22 AND DocDate>='[%0]' AND DocDate<='[%1]'))

    Hi Dalen ,
    I  believe it is because of the condition
    (D1.BaseType=22 AND D1.DocDate>='%0' AND D1.DocDate<='%1')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry FROM PDN1 WHERE PDN1.BaseType=22 AND DocDate>='%0' AND DocDate<='%1'))
    Try changing
    D1.BaseType=22 OR D1.DocDate>='%0' AND D1.DocDate<='%1
    PDN1.BaseType=22 OR DocDate>='%0' AND DocDate<='%1'))
    Lets see what would be the result . Lets have some fun with troubleshooting
    See what would be the difference in the result .
    Thank you
    Bishal

  • Help on Query - A/p Invoice Tax Breakup

    Hi Xperts,
    declare @todate as datetime
    declare @enddate as datetime
    SELECT @todate= /*min(T0.DocDate) FROM OINM T0 WHERE T0.DocDate=*/ '[%0]'
    SELECT @enddate= /*max(T0.DocDate) FROM OINM T0 WHERE T0.DocDate=*/'[%1]'
    select DISTINCT a.Docnum as "Invoice No" ,a.Numatcard AS "Customer Reference" ,a.comments, a.cardcode as "Cust.Code", a.cardname as "Customer Name" ,(Select max (T2.TaxId2) from CRD7 T2 where T2.CardCode = a.CardCode) [Tin#],  a.docdate AS "Invoice Date" ,(SELECT SUM(Quantity) FROM INV1 where docentry =a.docentry)as "Quantity" ,
    (select sum(LineTotal) from INV1 where docentry = a.docentry)as "Basic Value" ,(Select sum(taxsum) FROM INV4 where docentry = a.docentry and statype=-90) as "BED" ,
    (Select SUM(taxsum) FROM INV4 where docentry = a.docentry and statype=-60) as "Cess" ,(Select SUM(taxsum) FROM INV4 where docentry = a.docentry and statype=7) as "HeCess" ,(Select SUM(taxsum) FROM INV4 where docentry = a.docentry and statype=1) as "VAT" ,
    (Select SUM(taxsum) FROM INV4 where docentry = a.docentry and statype=4) as "CST" ,
    A.VatSum as "Total Tax" ,(select sum(linetotal) from inv3 where docentry = a.docentry) as 'Freight' ,
    A.DocTotal as "Net Value"
    FROM OINV A left OUTER JOIN INV3 B ON A.DOCENTRY = B.DOCENTRY left OUTER JOIN INV4 C ON A.DOCENTRY = C.DOCENTRY left outer join INV3 h on A.DocEntry = h.DocEntry left outer join INV1 d on a.docentry = d.docentry left outer join crd7 e on a.cardcode = e.cardcode, oitm g left outer join ochp f on f.absentry= g.chapterid where a.Docdate >=@todate and a.Docdate <=@enddate and g.itemcode=d.itemcode ORDER BY A.DOCNUM
    In the above query Item type service posted document is not coming. 
    Thanks in Advance
    Balaji Sampath

    Hi Balaji........
    In service Document Items do not come and you have made Inner Join your Invoice with OITM so that it is not coming.....
    declare @todate as datetime
    declare @enddate as datetime
    SELECT @todate= /*min(T0.DocDate) FROM OINM T0 WHERE T0.DocDate=*/ '[%0]'
    SELECT @enddate= /*max(T0.DocDate) FROM OINM T0 WHERE T0.DocDate=*/'[%1]'
    select DISTINCT a.Docnum as "Invoice No" ,a.Numatcard AS "Customer Reference" ,a.comments,
    a.cardcode as "Cust.Code", a.cardname as "Customer Name" ,(Select max (T2.TaxId2) from CRD7 T2 where T2.CardCode = a.CardCode) [Tin#],  a.docdate AS "Invoice Date" ,(SELECT SUM(Quantity) FROM INV1 where docentry =a.docentry)as "Quantity" ,
    (select sum(LineTotal) from INV1 where docentry = a.docentry)as "Basic Value" ,
    (Select sum(taxsum) FROM INV4 where docentry = a.docentry and statype=-90) as "BED" ,
    (Select SUM(taxsum) FROM INV4 where docentry = a.docentry and statype=-60) as "Cess" ,
    (Select SUM(taxsum) FROM INV4 where docentry = a.docentry and statype=7) as "HeCess" ,
    (Select SUM(taxsum) FROM INV4 where docentry = a.docentry and statype=1) as "VAT" ,
    (Select SUM(taxsum) FROM INV4 where docentry = a.docentry and statype=4) as "CST" ,
    A.VatSum as "Total Tax" ,(select sum(linetotal) from inv3 where docentry = a.docentry) as 'Freight' ,
    A.DocTotal as "Net Value"
    FROM OINV A left OUTER JOIN INV3 B ON A.DOCENTRY = B.DOCENTRY left OUTER JOIN INV4 C
    ON A.DOCENTRY = C.DOCENTRY left outer join INV3 h on A.DocEntry = h.DocEntry left outer join
    INV1 d on a.docentry = d.docentry left outer join crd7 e on a.cardcode = e.cardcode Left Outer Join
    oitm g On d.ItemCode=g.ItemCode left outer join ochp f on f.absentry= g.chapterid where a.Docdate >=@todate
    and a.Docdate <=@enddate and g.itemcode=d.itemcode ORDER BY A.DOCNUM
    Please try above......
    Regards,
    Rahul

  • Query in AP Invoice and AP Downpayment Invoice

    Hi Expert,
    I'm using the following query to generate report from AP Invoice by due date:
    SELECT T0.[CardCode] as 'Payee Code', T0.[TransId] as 'JE Number',  T0.[CardName] as 'Payee Name', T0.[DocDueDate], T0.[DocTotal] as 'Amount Due', T1.[U_DisBank] as 'BankCode', T2.[Name] as 'Bank Name' FROM OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN  "@HOFFICE" T2 ON T1.U_DisBank = T2.Code WHERE T0.[DocDueDate] >=[%0] and  T0.[DocDueDate]  <=[%1] and  T2.[Name] Like 'BDO%' and T0.[DocStatus] ='O' ORDER BY T2.[Name]
    However, I want also to include in the report the data from AP Downpayment Invoice, are there any possibility to include in the report with same column but different table source?
    Thanks,
    Arlmi2000

    Hi,
    Try this one:
    FROM
      dbo.ODPO T0
      INNER JOIN dbo.DPO1 T1 ON (T0.DocEntry = T1.DocEntry)
      LEFT OUTER JOIN dbo.PCH9 T2 ON (T1.DocEntry = T2.BaseAbs)
      LEFT OUTER JOIN dbo.OPCH T3 ON (T2.DocEntry = T3.DocEntry)
      LEFT OUTER JOIN dbo.PCH1 T4 ON (T3.DocEntry = T4.DocEntry)
    This code is from AP Downpayment then AP Invoice.
    Just reverse code so that the result will be AP Invoice then AP Downpayent.
    Thanks.
    Clint

  • Complex MySQL Query, Grouping By Invoice Number and Adding Multiple Values To Insert Into Database

    I have a table that looks like the above. I need to be able to update values in a database based on an ioID (the invoice number)
    The value I need to add is the hours times the uSalary, however as you will notice above the hours can and well have been added on an ongoing basis. For example:
    smarotti has added 4.5 (0.5 + 4.0) hours for the ioID 14190 (last 2 rows) for a total cost of $143.55
    So what I need is to have the value $143.55 update the record 14190 (ioID) on a new column (userCost)
    So:
    the userID - ddevries did 1 hour worth of work at the rate of $23.20 that needs to be update on the record 8026
    the userID - kmurtha did 20 (.5 + .25 + 6.5 + .25 + 6.5 + 6) hours worth of work $696 (20 * 34.80) that needs to be update on the record 9462
    make sense? anyone have any thoughts on how to go about doing this?
    Thanks
    Vern

    Okay
    assuming you add the column to your table the query would look like the below:
    UPDATE workers
                    INNER JOIN (SELECT
                                                    round(SUM(hours*uSalary),1) AS cost,
                                                    ioID,
                                                    userid
                                            FROM
                                                    workers
                                            GROUP BY ioID, userid ) b
                    ON workers.ioID = b.ioID
            SET workers.userCost=b.cost
    WHERE workers.ioid = b.ioID
    AND     workers.userID = b.userID
    Or if you would just like to query the data:
    SELECT  round(SUM(hours*uSalary),1) AS usercost,ioID,userid
    FROM workers
    GROUP BY ioID, userid

  • Formatted search query for displaying invoice items details

    hi all,
    i need to display all the items in AP invoice.kindly suggest me a query for that.
    in AP invoice
    Ex. row items
    code--descqtyprice--
    total
    I0001--XXXXXXX5--
    100 -
    500
    query should display this row as
    code--desc--
    price
    I0001--XXXXXXX--
    100
    I0001--XXXXXXX--
    100
    I0001--XXXXXXX--
    100
    I0001--XXXXXXX--
    100
    I0001--XXXXXXX--
    100
    =================================
    the query should display as the qty is 5 so it will display the same item 5 times
    kindly suggest me some query for formatted search
    its very urgent
    regards
    sandip

    Hi Sandip,
    DoQuery("Select b.ItemCode from OINV a,INV1 b Where a.DocEntry=b.DocEntry")
    Hope its help for you
    Give me reward points,
    Regards,
    G.Suresh.

  • Need full main query to fetch Invoices for RAXINV.rdf

    Hello All,
    Please send me the complete query which fetches the Invoices for RAXINV.rdf.
    In standard query, it consists of lexical parameters. Need query without any lexical parameters.
    Please do the needful.
    Thanks,
    Abdul

    Hello All,
    Can anyone take up this, and share the Main Query which fetches the Invoices in RAXINV.rdf for SELECTED Option.
    this Query involves lot of lexical parameters. I'm not able to get it.
    Please do the needful.
    Thanks.

  • Query Modification for Invoice Outstanding

    Hi ,
    Can anybody modify this code by DocNum. This query displays the same invoice 2 times when the invoice is having more than 1 item. How to get the report without invoice number repeat.
    SELECT T0.[DocNum], T0.[DocDate], T0.[CardName], T1.[OpenSum] ,T1.[VatSum],
    T0.WTSum AS 'TDS Amount',
    T0.DocTotal,
    (T0.DocTotal-T0.[PaidToDate]) as 'BalanceDue',
    (SELECT CASE
    WHEN T1.TargetType='14' THEN 'A/R CreditMemo'
    Else ' '
    End) as 'Target Type'
    FROM OINV T0  INNER JOIN INV1 T1 ON
    T0.DocEntry = T1.DocEntry 
    WHERE T0.[DocDate] BETWEEN '[%0]' AND '[%1]' 
    Regards
    Srini

    Hi Srini,
    Try this first:
    SELECT T0.DocNum, T0.DocDate, T0.CardName, SUM(T1.OpenSum) 'Open Sum',SUM(T1.VatSum) 'Vat Sum',
    T0.WTSum AS 'TDS Amount',
    T0.DocTotal,
    (T0.DocTotal-T0.PaidToDate) as 'BalanceDue'
    FROM OINV T0 INNER JOIN INV1 T1 ON
    T0.DocEntry = T1.DocEntry
    WHERE T0.DocDate BETWEEN '[%0\]' AND '[%1\]'
    GROUP BY T0.DocNum, T0.DocDate, T0.CardName,
    T0.WTSum,
    T0.DocTotal,T0.PaidToDate
    Thanks,
    Gordon

  • R12 Payables: SQL Query to List Invoices along with their Validation Status

    Hi All,
    I am looking for a SQL query that gives me the list of all AP Invoices and their Validation Status.
    Thanks,
    Anil

    select invoice_id, invoice_num, invoice_amount, invoice_currency_code, approval_status_lookup_code from AP_INVOICES_V ;
    --Prasanna                                                                                                                                                                                                                                                                           

  • Query, dicount on invoice report

    Hello,
    We have some items that are not discountable, so I created on item properties"discountable =yes/no".
    On the invoice report I'd like to have the following:
    Payable until xx.yy.zzzz: EUR XXXXX <sum of amount of discountable items & based upon BP payment terms discount rate and last date>, until xx.yy.zzzz: EUR <total amount and last date without discount>.
    Example:
    Payable until 14.02.2012 EUR 1960,00 (14 days 2%, 30 days Net.), until 28.02.2012 EUR 2000,00.
    I know this is only for the report(paper and screen) and some tables will showup wrong data as the customer pays the discount amount.
    Coresuite installed.
    Thank you
    Marc

    Hi Jitin,
    Thanks for you code sniplet, as you can see I played a bit with the SQL query:
    SELECT
    T0.DocNum AS 'Belegnummer',
    SUM(T1.LineTotal) AS 'Betrag Zeilensumme', T0.DocTotal AS 'Gesamt', T5.Discount AS 'Skontowert',
    (CAST (T0.DocTotal AS money)-(CAST (T0.DocTotal AS money)-(((SUM(CAST (T1.LineTotal AS money)1.1900)/(T5.Discount/100 + 1))+((CAST (T0.DocTotal AS money)/1.1900)-(SUM(CAST (T1.LineTotal AS money))))1.1900)))) AS 'Skontobereinigt'
    FROM
    dbo.OINV T0 FULL OUTER JOIN dbo.INV1 T1
    ON T1.DocEntry = T0.DocEntry
    FULL OUTER JOIN dbo.OITM T2
    ON T2.ItemCode = T1.ItemCode
    FULL OUTER JOIN dbo.OCRD T3
    ON T1.BaseCard = T3.CardCode
    FULL OUTER JOIN dbo.OCTG T4
    ON T3.GroupNum = T4.GroupNum
    FULL OUTER JOIN dbo.CDC1 T5
    ON T4.DiscCode = T5.CdcCode
    WHERE T2.QryGroup1 = (N'Y' )
    GROUP BY T0.DocNum, T5.Discount , T0.DocTotal, T2.QryGroup1
    so how can I get this into my invoice to be Shown like:
    Zahlungskonditionen: 10 Tage abzüglich "T5.Discount/SkontoimGP" EUR "RN Betrag Skontoabzug", 30 Tage Netto
    Thanks Marc

  • Approval Query for AP Invoices Containing Budget Related GL Account

    Hi Experts,
    I would like to create a approval template for all AP invoices that include a GL account that is related to the budget. Can you please help me with the approval query?
    Thank you!
    Jane

    Hello Gordon Du,
    "B1 approval will only apply to document level. If you want to check line level, only the first line can be subjected to."
    I was thinking to trigger the approval process based on a document (AP invoice) containing relevant cost centres on a line by line basis as entered via one of the enabled dim fields.
    Writing a trigger query for each cost centre effected? This does not appear to be a good solution, what is a better direction. Is there another way? (PO are not yet used via SAPB1)
    Currently my invoices add, but do not trigger the approval process based on my attempts thus far.
    Can the originator manually choose an approval pathway?
    If this is against posting etiquette delete and advise.
    I am a relative newbie to SAP B1, so am happy to be pointed to relevant help files. I arrived via  google searching and arrived here.
    Thankyou.

  • Query for Open Invoices

    Hi 2 all
    Anybody know that how to fetch open invoices in 11i and these invoices balances should be match with Supplier Statement of Account Report.
    Thanks,
    Zulqarnain

    Hi,
    I use this one:
    SELECT HEADER.*,
    HEADER.END_BALANCE - HEADER.BEGIN_BALANCE NET_BALANCE,
    HEADER.BEGIN_BALANCE BEGIN_BALANCE_2,
    LINE.*,
    NVL(LINE.DEBE, 0) - NVL(LINE.HABER, 0) NETO_LINEA
    FROM (SELECT TP.THIRD_PARTY_ID,
    TP.THIRD_PARTY_NAME,
    TP.THIRD_PARTY_NUMBER,
    S.SUB_ID,
    S.SUB_NAME,
    AB_START.ACCOUNT_SEGMENT,
    AB_START.PERIOD_NAME BEGIN_BALANCE_PERIOD,
    AB_END.PERIOD_NAME END_BALANCE_PERIOD,
    AB_START.END_BALANCE_DR - AB_START.PERIOD_NET_DR +
    AB_START.PERIOD_NET_CR - AB_START.END_BALANCE_CR BEGIN_BALANCE,
    AB_END.END_BALANCE_DR - AB_END.END_BALANCE_CR END_BALANCE
    FROM AX_THIRD_PARTIES_V TP,
    AX_SUBS_V S,
    AX_BALANCES AB_START,
    GL_PERIOD_STATUSES GPS_START,
    AX_BALANCES AB_END,
    GL_PERIOD_STATUSES GPS_END
    WHERE TP.APPLICATION_ID = 200
    AND TP.APPLICATION_ID = S.APPLICATION_ID
    AND TP.APPLICATION_ID = AB_START.APPLICATION_ID
    AND TP.APPLICATION_ID = GPS_START.APPLICATION_ID
    AND TP.APPLICATION_ID = AB_END.APPLICATION_ID
    AND TP.APPLICATION_ID = GPS_END.APPLICATION_ID
    AND TP.THIRD_PARTY_ID = AB_START.THIRD_PARTY_ID
    AND S.THIRD_PARTY_ID = AB_START.THIRD_PARTY_ID
    AND S.SUB_ID = AB_START.SUB_ID
    AND AB_START.SET_OF_BOOKS_ID = GPS_START.SET_OF_BOOKS_ID
    AND AB_START.PERIOD_NAME = GPS_START.PERIOD_NAME
    AND TP.THIRD_PARTY_ID = AB_END.THIRD_PARTY_ID
    AND S.THIRD_PARTY_ID = AB_END.THIRD_PARTY_ID
    AND S.SUB_ID = AB_END.SUB_ID
    AND AB_END.SET_OF_BOOKS_ID = GPS_END.SET_OF_BOOKS_ID
    AND AB_END.PERIOD_NAME = GPS_END.PERIOD_NAME
    AND AB_START.SET_OF_BOOKS_ID = :P_SOB
    AND TP.THIRD_PARTY_NUMBER =
    NVL(:P_VENDOR_NUMBER, TP.THIRD_PARTY_NUMBER)
    AND TP.THIRD_PARTY_NAME = NVL(:P_PARTY_NAME, TP.THIRD_PARTY_NAME)
    AND S.SUB_NAME = NVL(:P_SUB_NAME, S.SUB_NAME)
    AND AB_END.ACCOUNT_SEGMENT = AB_START.ACCOUNT_SEGMENT
    AND GPS_START.EFFECTIVE_PERIOD_NUM =
    (SELECT MIN(P_BALANCE.EFFECTIVE_PERIOD_NUM)
    FROM AX_BALANCES BALANCE,
    GL_PERIOD_STATUSES P_BALANCE,
    GL_PERIOD_STATUSES P_DATE
    WHERE BALANCE.APPLICATION_ID = AB_START.APPLICATION_ID
    AND BALANCE.APPLICATION_ID = P_BALANCE.APPLICATION_ID
    AND BALANCE.APPLICATION_ID = P_DATE.APPLICATION_ID
    AND BALANCE.THIRD_PARTY_ID = AB_START.THIRD_PARTY_ID
    AND BALANCE.SUB_ID = AB_START.SUB_ID
    AND BALANCE.SET_OF_BOOKS_ID = AB_START.SET_OF_BOOKS_ID
    AND BALANCE.SET_OF_BOOKS_ID = P_BALANCE.SET_OF_BOOKS_ID
    AND BALANCE.SET_OF_BOOKS_ID = P_DATE.SET_OF_BOOKS_ID
    AND P_DATE.PERIOD_NAME = :P_PERIOD_START
    AND P_BALANCE.EFFECTIVE_PERIOD_NUM >=
    P_DATE.EFFECTIVE_PERIOD_NUM
    AND P_BALANCE.PERIOD_NAME = BALANCE.PERIOD_NAME
    AND BALANCE.CODE_COMBINATION_ID =
    AB_START.CODE_COMBINATION_ID)
    AND GPS_END.EFFECTIVE_PERIOD_NUM =
    (SELECT MAX(P_BALANCE.EFFECTIVE_PERIOD_NUM)
    FROM AX_BALANCES BALANCE,
    GL_PERIOD_STATUSES P_BALANCE,
    GL_PERIOD_STATUSES P_DATE
    WHERE BALANCE.APPLICATION_ID = AB_END.APPLICATION_ID
    AND BALANCE.APPLICATION_ID = P_BALANCE.APPLICATION_ID
    AND BALANCE.APPLICATION_ID = P_DATE.APPLICATION_ID
    AND BALANCE.THIRD_PARTY_ID = AB_END.THIRD_PARTY_ID
    AND BALANCE.SUB_ID = AB_END.SUB_ID
    AND BALANCE.SET_OF_BOOKS_ID = AB_END.SET_OF_BOOKS_ID
    AND BALANCE.SET_OF_BOOKS_ID = P_BALANCE.SET_OF_BOOKS_ID
    AND BALANCE.SET_OF_BOOKS_ID = P_DATE.SET_OF_BOOKS_ID
    AND P_DATE.PERIOD_NAME = :P_PERIOD_END
    AND P_BALANCE.EFFECTIVE_PERIOD_NUM <=
    P_DATE.EFFECTIVE_PERIOD_NUM
    AND P_BALANCE.PERIOD_NAME = BALANCE.PERIOD_NAME
    AND BALANCE.CODE_COMBINATION_ID =
    AB_END.CODE_COMBINATION_ID)) HEADER,
    ((SELECT LINE.THIRD_PARTY_ID VENDOR_ID,
    HEAD.EFFECTIVE_DATE FECHA_CONTABLE,
    INV.INVOICE_DATE FECHA_TRANSACCION,
    LOOK.DESCRIPTION TIPO_TRANSACCION,
    LINE.REFERENCE_25 NUM_TRANSACCION,
    INV.DOC_SEQUENCE_VALUE SECUENCIA,
    LINE.ACCOUNTED_DR DEBE,
    LINE.ACCOUNTED_CR HABER,
    CODE.SEGMENT3 CUENTA
    FROM AX_SLE_LINES LINE,
    AX_SLE_HEADERS HEAD,
    GL_CODE_COMBINATIONS CODE,
    AP_INVOICES_ALL INV,
    FND_LOOKUP_VALUES LOOK
    WHERE HEAD.EFFECTIVE_DATE BETWEEN
    (SELECT START_DATE
    FROM GL_PERIOD_STATUSES_V
    WHERE PERIOD_NAME = :P_PERIOD_START
    AND SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND APPLICATION_ID = 101)
    AND (SELECT END_DATE
    FROM GL_PERIOD_STATUSES_V
    WHERE PERIOD_NAME = :P_PERIOD_END
    AND SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND APPLICATION_ID = 101)
    AND HEAD.SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND HEAD.SET_OF_BOOKS_ID = INV.SET_OF_BOOKS_ID
    AND HEAD.JOURNAL_SEQUENCE_ID = LINE.JOURNAL_SEQUENCE_ID
    AND HEAD.SET_OF_BOOKS_ID = :P_SOB
    AND LINE.REFERENCE_7 = INV.INVOICE_ID
    AND CODE.CODE_COMBINATION_ID = LINE.CODE_COMBINATION_ID
    AND LINE.SLE_HEADER_ID = HEAD.SLE_HEADER_ID
    AND LINE.SOURCE_TABLE != 'AP_INVOICE_PAYMENTS'
    AND LOOK.LOOKUP_TYPE = 'INVOICE TYPE'
    AND LOOK.LANGUAGE = 'E'
    AND LOOK.LOOKUP_CODE = INV.INVOICE_TYPE_LOOKUP_CODE
    AND LINE.CODE_COMBINATION_ID IN
    (SELECT CODE_COMBINATION_ID
    FROM GL_CODE_COMBINATIONS
    WHERE SEGMENT3 LIKE '40%' -- Segment3 is our natural account, 40, 04, 41 are the natural accounts for suppliers
    OR SEGMENT3 LIKE '04%'
    OR SEGMENT3 LIKE '41%')) UNION ALL
    (SELECT LINE.THIRD_PARTY_ID VENDOR_ID,
    HEAD.EFFECTIVE_DATE FECHA_CONTABLE,
    INV.CHECK_DATE FECHA_TRANSACCION,
    'Pago' TIPO_TRANSACCION,
    LINE.REFERENCE_25 NUM_TRANSACCION,
    INV.DOC_SEQUENCE_VALUE SECUENCIA,
    LINE.ACCOUNTED_DR DEBE,
    LINE.ACCOUNTED_CR HABER,
    CODE.SEGMENT3 CUENTA
    FROM AX_SLE_LINES LINE,
    AX_SLE_HEADERS HEAD,
    GL_CODE_COMBINATIONS CODE,
    AP_CHECKS_ALL INV
    WHERE HEAD.EFFECTIVE_DATE BETWEEN
    (SELECT START_DATE
    FROM GL_PERIOD_STATUSES_V
    WHERE PERIOD_NAME = :P_PERIOD_START
    AND SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND APPLICATION_ID = 101)
    AND (SELECT END_DATE
    FROM GL_PERIOD_STATUSES_V
    WHERE PERIOD_NAME = :P_PERIOD_END
    AND SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND APPLICATION_ID = 101)
    AND HEAD.SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND HEAD.JOURNAL_SEQUENCE_ID = LINE.JOURNAL_SEQUENCE_ID
    AND HEAD.SET_OF_BOOKS_ID = :P_SOB
    AND LINE.REFERENCE_7 = INV.CHECK_ID
    AND CODE.CODE_COMBINATION_ID = LINE.CODE_COMBINATION_ID
    AND LINE.SLE_HEADER_ID = HEAD.SLE_HEADER_ID
    AND LINE.SOURCE_TABLE = 'AP_INVOICE_PAYMENTS'
    AND LINE.CODE_COMBINATION_ID IN
    (SELECT CODE_COMBINATION_ID
    FROM GL_CODE_COMBINATIONS
    WHERE SEGMENT3 LIKE '40%' --Segment3 is our natural account, 40, 04, 41 are the natural accounts for suppliers
    OR SEGMENT3 LIKE '04%'
    OR SEGMENT3 LIKE '41%'))) LINE
    WHERE HEADER.THIRD_PARTY_ID = LINE.VENDOR_ID(+)
    AND HEADER.ACCOUNT_SEGMENT = LINE.CUENTA(+)
    ORDER BY LINE.FECHA_CONTABLE
    :P_VENDOR_NUMBER -> Supplier Num
    :P_PARTY_NAME -> Supplier Name
    :P_SUB_NAME -> Supplier Address
    :P_SOB -> set_of_books_id
    :P_PERIOD_START -> Period Start
    :P_PERIOD_END -> Period End

  • Query related to Invoice Verification

    Hello everybody,
    I want to post vendor invoice in the system for the month of August. November and December periods are open (MM periods) in the system. Finance periods are open from August to December. System does not allow to post the invoice since postings are possible only in the periods November and December.
    Is there any way to post the vendor invoice in the month of August?
    Thanks,
    Nikhil

    hi
    If ur current period is November and previous period is August then only u can post in Month of august by allowing backposting in MMRV
    And if current period is Dec and previous is NOvember then u can not allow backposting here u need to open period in MMPI but which is not recommended by SAP in live system
    Check SAP notes before going for MMPI
    Vishal...

Maybe you are looking for

  • When reinstalling creative cloud and adobe products i only get the ''try'' button.

    Hi i have a problem in my creative cloud. About 3 months ago i purchased the creative cloud collection and 4 days ago i reinstalled windows so my pc would be faster again but when i wanted to reinstall my creative cloud products it gives me only the

  • Creation of SCA Package from EAR and SDA

    Hi All, As we know that when a CAF project is created then another 4 projects( dictionary, ejbmodule, permission and webdynpro) are created with the main CAF project and at deployment time five files are deployed at J2EE engine. Among them four are E

  • Diagram from multiple tables

    Hi community, I'd like to create a diagram from data that is organised in multiple tables (and sheets). Is that possible? Please don't post any workarounds, because I'd rather change the organisation of the data than build in a workaround like additi

  • Flash, OpenType and Contextual Alternatives

    Newbie to the forums. Hope someone can help. We recently procured an OpenType font. This font has some radical differences between the Standard Ligature Set and the Contextual Alternatives. Accessing these various versions is done thru the OpenType m

  • Back to My Mac suddenly stopped working

    Hello I have a new iMac and a Macbook about 12 months old, both with Leopard 10.5.3. They are both connected wirelessly via Airport Extreme Base Station acting as a bridge with a 4 port ADSL modem router managing the network. I have been using Back t