Query for Daily Payment Records against Multiple Payment Means
Hi Experts,
I've got this query to show daily payment details which related today's invoice only, however, if there are multiple payment means which linked to one invoice then it just shows last payment record only. Let say, Invoice no. 1 paid by three cheques and query shows last row of cheque amount only. Is it possible to shows multiple payment means against one invoice as well?
Thanks in advance for any help.
SELECT DISTINCT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T1.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T0.DocTotal
WHEN T1.TrsfrSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CashSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CreditSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CheckSum > 0 THEN T0.DocTotal - T0.PaidToDate
ELSE T0.DocTotal
END AS 'AR Sum',
CASE
WHEN T0.ObjType = 13 THEN 'ARIV'
WHEN T0.ObjType = 14 THEN 'ARCR'
ELSE 'N/A'
END AS 'Doc Type',
CASE
WHEN T1.Series = 12 THEN 'IPAY'
WHEN T1.Series = 15 THEN 'OPAY'
ELSE 'N/A'
END AS 'Doc Series',
T0.ObjType,
T1.Series,
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.TrsfrSum - T1.TrsfrSum
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.TrsfrSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'TrsfrSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CashSum - T1.CashSum
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.CashSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CashSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CheckSum - T1.CheckSum
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.CheckSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CheckSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CreditSum - T1.CreditSum
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.CreditSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CreditSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.TrsfrSum - T1.TrsfrSum
WHEN T1.TrsfrSum > T0.DocTotal THEN T0.PaidToDate
ELSE T1.TrsfrSum
END 'Paid To Date',
T1.JrnlMemo
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT2 T2 ON T1.DocNum = T2.DocNum AND T0.DocEntry = T2.DocEntry
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE DateDiff(D,T0.DocDate,GetDate())=0
ORDER BY T0.DocDate, T1.DocDate, 'CreditSum', 'CheckSum', 'CashSum', 'TrsfrSum', 'AR Sum'
Edited by: Won Gyu (Gerald) Lee on Feb 22, 2012 7:15 AM
Edited by: Won Gyu (Gerald) Lee on Feb 22, 2012 7:15 AM
Edited by: Won Gyu (Gerald) Lee on Feb 22, 2012 7:17 AM
Hi Gordon,
Thanks for reply and I've got your book which is being very helpful.
I tried and it seems to shows multiple payment list, however, there are all same value in 'CashSum', 'CheckSum', 'CreditSum', 'TrsfrSum' columns.
For example, if invoice link with one payment mean (cash:$10.00) then it shows like this.
'CashSum', 'CheckSum', 'CreditSum', 'TrsfrSum'
10.00 10.00 10.00 10.00
SELECT DISTINCT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T1.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T0.DocTotal
WHEN T1.TrsfrSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CashSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CreditSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CheckSum > 0 THEN T0.DocTotal - T0.PaidToDate
ELSE T0.DocTotal
END AS 'AR Sum',
CASE
WHEN T0.ObjType = 13 THEN 'ARIV'
WHEN T0.ObjType = 14 THEN 'ARCR'
ELSE 'N/A'
END AS 'Doc Type',
CASE
WHEN T1.Series = 12 THEN 'IPAY'
WHEN T1.Series = 15 THEN 'OPAY'
ELSE 'N/A'
END AS 'Doc Series',
T0.ObjType,
T1.Series,
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.TrsfrSum - T1.TrsfrSum
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.TrsfrSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'TrsfrSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CashSum - T1.CashSum
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.CashSum > T0.DocTotal THEN T2.SumApplied
ELSE T2.SumApplied
END AS 'CashSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CheckSum - T1.CheckSum
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.CheckSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CheckSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CreditSum - T1.CreditSum
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.CreditSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CreditSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.TrsfrSum - T1.TrsfrSum
WHEN T1.TrsfrSum > T0.DocTotal THEN T0.PaidToDate
ELSE T1.TrsfrSum
END 'Paid To Date',
T1.JrnlMemo
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.DocNum = T1.DocNum
LEFT JOIN RCT2 T2 ON T0.DocEntry = T2.DocEntry
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE T0.DocDate = [%0]
ORDER BY T0.DocDate, T1.DocDate, 'CreditSum', 'CheckSum', 'CashSum', 'TrsfrSum', 'AR Sum'
Similar Messages
-
Hi Guys,
I written a query for incoming payments for some particular account heads and i have tried this.
But did not achieved the desired result.
Anybody please modify the query.
SELECT T1.[DocNum], T0.DocNum, T0.AcctCode, T0.SumApplied, T0.AcctName ,
(Select sum(SumApplied) from rct4 where T0.docnum = t1.docentry and T0.acctcode='355102'),
(Select sum(SumApplied) from rct4 where T0.docnum = t1.docentry and T0.acctcode='211417'),
(Select sum(SumApplied) from rct4 where T0.docnum = t1.docentry and T0.acctcode='355103'),
(Select sum(SumApplied) from rct4 where T0.docnum = t1.docentry and T0.acctcode='211436')
FROM RCT4 T0
Left outer JOIN ORCT T1 ON T0.DocNum = T1.DocEntry INNER JOIN NNM1 T2 ON T1.Series = T2.Series
WHERE T2.[SeriesName] ='Spares' and t1.docdate between [%0] and [%1]
Regards,
VamsiHi Vamsi,
Try this:
SELECT T1.DocNum, T0.DocNum,
(Select SumApplied from rct4 where docnum = t1.docentry and T0.acctcode='355102') AS '355102',
(Select SumApplied from rct4 where docnum = t1.docentry and T0.acctcode='211417') AS '211417',
(Select SumApplied from rct4 where docnum = t1.docentry and T0.acctcode='355103') AS '355103',
(Select SumApplied from rct4 where docnum = t1.docentry and T0.acctcode='211436') AS '211436'
FROM RCT4 T0
INNER JOIN ORCT T1 ON T0.docnum = T1.DocEntry
INNER JOIN NNM1 T2 ON T1.Series = T2.Series
WHERE T2.SeriesName ='Spares' and t1.docdate between [%0\] and [%1\]
Thanks,
Gordon -
Approval Query for Outgoing Payment
Hi All Experts,
I have to Create Approval for Outgoing Payment where payment means is Cash,Cheque or Bank Transfer but not Credit Card.
In other words approval should be raised for all payment means other than Credit card payment means.
For which I have Created Query as follows
select Distinct 'true' FROM dbo.OVPM T0
Left join dbo.VPM3 T1 on T0.DocEntry=T1.Docnum
WHERE T0.CreditSum=0 And T1.CreditAcct is null
payments goes for approval but Credit Card payment also goes for Approval which is not required.
Please Help me to Correct the Query.
Regards,
Gayatri Shukla.Hi,
Little modification to your query. Try this.
select Distinct 'true' FROM dbo.OVPM T0
Left join dbo.VPM3 T1 on T0.DocEntry=T1.Docnum
WHERE T0.CreditSum = 0
Regards,
Amrut Sabnis. -
Query for daily sales by warehouse
Hi
I need a query for Daily sales by warehouse. I am only new to this and struggling with generating.
ideally it will look like the below. With no selection criteria as I would like to schedule the report to email out at the end of each day.
Warehouse Revenue GP GP%
NSW $xxxx $xxx 35%
Would someone mind helping
thanksthankyou , But i have multiple warehouse and i dont want to use a selection criteria.
to expand on the original example
Warehouse Revenue GP GP%
NSW $xxxx $xxx 35%
QLD $xxx $xx 32%
VIC $xxx $xx 32%
Also the results should only show figures for the day the query is executed
Any help is appreciated.
Similar layout to this,except using query and whs code. the below is generated using sales analysis and customer group. -
Query for Vendor Payment in SAP
Hello All,
I am a sap abap developer with little knowledge in SAP MM and SAP FI modules.
As per some requirement of my company ,i have created a PO then its GR and finally IR.
Now when i checked EKBE table (History per Purchasing Document) , i found two record in this table out of which one with
VGABE = 1 (Good Receipt) & another with VGABE = 2 (Invoice Receipt) .
Now my requirement is ,i want a entry in this table with VGABE = 5 (Payment) but i don't know how to do payment of vendor in sap so that this table will populate with a entry for payment type.
Please help me and let me know what will be the flow with tcodes to do the vendor payment in sap.
Please reply ASAP.
Thanks in advance.
Regards.
Abhinav Goel.Hello Mr.Raman,
Thanks for your response to my query.
As per my company requirement i have to track duplicate payment made to the vendor against same PO.
So for that after completing the cycle PR-PO-GR-IR-F-53 finally i found two records in BSAK table out of which :
One record was with my accounting document no from my invoice receipt of type RE.
Another record was with the vendor payment clearance document with type KZ.
Now again i have done payment to the vendor using F-53 tcode and now i found one more record with belnr = last payment document no and augbl = new payment document no. with type KZ.
So if i use below mentioned logic to track for duplicate payments made to the vendor ,then it will be fine or if not can you suggests me the needful changes in the logic.
1.) Check If record exists for my belnr no from invoice recipt in bsak.
2.) Take AUGBL No for this BELNR No and check if record exists for this AUGBL with type KZ.
Note:Means payment is done to the vendor upto this logic.
3.) Now if with the found record with type KZ any other record found with type KZ it can be taken of as duplicate payment made to the vendor.
Please suggest me if above mentioned logic is fine.
Regards.
Abhinav Goel. -
Query for allowed payment methods of BP
Hi there,
i would like to make a query where i get all allowed paymentmethods of a BP. Unfortunatly i do not know in which table i can find this information. The query for checking the standard paymentmethod is quite easy but i do not know in which table i get the information of the allowed (checked) paymentmethods.
thx for your help.
best regards
ManuelAnother question: is there an easy way to update all BP (so that it is allowed) with a paymentmethod without using DTW?
If I try it with an update query i think it is not the right way because it is not really an update of an existing record it's adding a new allowed paymentmethod.
br
Manuel -
How to find out query for the deleted record.
Hi Guys,
We are using Oracle9i release 1. We are about 5 employees who are working on the same application. All Employee are connected to the same Schema (User)
User: Employee/web
Now one of the user have deleted like 200,000 records from a table. We just want to trace out the query by which these records were deleted.
From which file i can get the log of executed queries so that i can recover the data.
Just want to know the query executed for this deletion of records?
we are using windows server.
Regards,
Imran BaigIf you do not need an exact query, but only the way you can reconstruct the data, LogMiner can be solution for you. Below I have put a simple example you can review it if you want.
[email protected]> create table t201 as select object_id , object_name from all_objects where rownum < 10;
Table created.
[email protected]> select * from t201;
OBJECT_ID OBJECT_NAME
17918 /1005bd30_LnkdConstant
7540 /10076b23_OraCustomDatumClosur
23355 /10297c91_SAXAttrList
14204 /103a2e73_DefaultEditorKitEndP
22920 /1048734f_DefaultFolder
10154 /10501902_BasicFileChooserUINe
23566 /105072e7_HttpSessionBindingEv
23621 /106ba0a5_ArrayEnumeration
9830 /106faabc_BasicTreeUIKeyHandle
9 rows selected.
[email protected]> delete t201 where object_id < 10000;
2 rows deleted.
[email protected]> commit;
Commit complete.
[email protected]> alter system switch logfile;
System altered.
[email protected]> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
1 1 41 10485760 2 YES ACTIVE 58320830 25-MAR-06
2 1 42 10485760 1 NO CURRENT 58348006 25-MAR-06
3 1 40 10485760 1 YES INACTIVE 58293190 25-MAR-06
[email protected]> select * from v$archived_log where sequence# = 41;
RECID STAMP
NAME
DEST_ID THREAD# SEQUENCE# RESETLOGS_CHANGE# RESETLOGS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME BLOCKS
ARC APP
DEL S COMPLETIO DIC DIC END BACKUP_COUNT ARCHIVAL_THREAD# ACTIVATION#
86 585998848
C:\ORACLE\ORADATA\MOB92\ARCH\ARC00041.001
1 1 41 57407039 20-MAR-06 58320830 25-MAR-06 58348006 25-MAR-06 20282
YES NO
NO A 25-MAR-06 NO NO NO 0 1 2555135919
[email protected]> exec dbms_logmnr.add_logfile('C:\ORACLE\ORADATA\MOB92\ARCH\ARC00041.001',dbms_logmnr.new)
PL/SQL procedure successfully completed.
[email protected]> exec dbms_logmnr.start_logmnr(options => dbms_logmnr.dict_from_online_catalog)
PL/SQL procedure successfully completed.
[email protected]> l
1 select sql_undo, sql_redo
2 from v$logmnr_contents
3 where username = 'MOB' and timestamp > sysdate - 1
4* order by timestamp
insert into "MOB"."T201"("OBJECT_ID","OBJECT_NAME") values ('7540','/10076b23_OraCustomDatumClosur');
delete from "MOB"."T201" where "OBJECT_ID" = '7540' and "OBJECT_NAME" = '/10076b23_OraCustomDatumClosur' and ROWID = 'AAAIE2AAXAAAFVaAAB';
insert into "MOB"."T201"("OBJECT_ID","OBJECT_NAME") values ('9830','/106faabc_BasicTreeUIKeyHandle');
delete from "MOB"."T201" where "OBJECT_ID" = '9830' and "OBJECT_NAME" = '/106faabc_BasicTreeUIKeyHandle' and ROWID = 'AAAIE2AAXAAAFVaAAI';
Best Regards
Krystian Zieja / mob -
Select query for every 1000 records
Hi all ,
Please help me in the issue . I am using select query Select * from table up to 1000 rows for acheving the records but i want this process to retrigger once the process of 1000 records is compleded again it needs to fetch the next 1000 records and process the same . I am changing the status of the processed records once it is processed . Can can one tell me how to retrigger the select query once the 1000 records are processes.
Thanks in advance,Hi Eric,
After selecting the 1000 records, find the key value of the last record. Build up the range as GT. Again use the select query.
For example,
Select * into table lt_data from ztab
where key in r_key
up to 1000 rows.
regards,
Niyaz -
How to use execute query For a single record
Hi All,
I am working with oracle forms 10g, I have developed a custom form.
I the form user enter some data and click save in the menu and data get inserted into my table. Inside the insert statement i have hardcoded some values, Once data get inserted i cant able to see that values immediately in my text fields in my form.After requerying i can able to see the changes.
For example I have a text field called Status, and the field is display only field. At that time of insert i have hardcoded as "INCOMPLETE". Once the user enter the data in the form and click save the data get inserted in to my table but i cant able to see the status, after i requery my form i can able to see the status.
Here i do multi insert also.
This is my insert statement
BEGIN
First_Record;
LOOP
IF :BANK_GUARANTEE_BLK.CHECK_IN_OUT = 'Y'
THEN
XXBANK_GUARANTEE_HEADERS.XXBANK_GUARANTEE_INSERT;(this is my package, here i have written my insert statement)
--Execute_query;
END IF;
Exit when :System.Last_Record = 'TRUE';
Next_Record;
END LOOP;
END;
If user insert only one row and i gave Execute_query to refresh and bring the current data, but when i use execute_query Its brings up all the datas in the table.
Can any one tell me how to avoid this and how to use execute_query for a single record.
Thanks ®ards
SrikkanthSolved,
The solution is
set_block_property('LC_REQ_BLK',ONETIME_WHERE,'LC_PO_NUMBER='||:LC_REQ_BLK.LC_PO_NUMBER);
go_block('LC_REQ_BLK');
execute_query;
Works fine.
Regards
Sri -
Query for fully payment made against invoice
Dear,
We have requirement to find out those invoices which payment has not been fully made. Here I mentioned query, please verify either is correct or need to add any other criteria.
Select * from ap_invoices_all where invoice_amount <> amount_paid
--thanksHello.
You can achieve the same result by running the Accounts Payable Trial Balance.
Octavio -
Hi All,
i need a report for the outgoing payment where i could display the account details, the doc remarks, row total and also the payment mode, whther by cash or by cheque. I have a query but i dont know how to get the mode of payment and also how to get the row total??
SELECT T0.[DocNum], T0.[DocDate], T1.[AcctName], T1.[Descrip], T0.[CashAcct], T0.[CheckAcct] FROM OVPM T0 INNER JOIN VPM4 T1 ON T0.DocEntry = T1.DocNum WHERE T0.[DocDate] = [%0]
How do i get the row total and the mode of payment incorporated in the query? apart from the doc date, can i also get a selection criteria for the mode of payment as well?? Can anyone please suggest a better query??
Thanks in advance,
JosephTry this one to start:
SELECT T0.DocNum, T0.DocDate, T1.AcctName, T1.Descrip, T0.CashAcct, T0.CheckAcct, T0.DocTotal, CASE WHEN T0.CashSum > 0 THEN 'Cash' WHEN T0.CreditSum > 0 THEN 'CC' WHEN T0.TrsfrSum > 0 THEN 'WIRE' ELSE 'Check' END AS 'Mode'
FROM dbo.OVPM T0
LEFT JOIN dbo.VPM4 T1 ON T0.DocEntry = T1.DocNum
WHERE T0.DocDate = [%0\] AND T0.JrnlMemo != 'Cancelled'
Thanks,
Gordon -
Outgoing Payment Query with GL Name for all payment means
Hi all
Thanks a lot for the earlier help of Nagarajan!
I managed to improve this Query now the only problem is the Bank Transfer Bank account name does not appear on the same line as the Bank transfer amount.
Please help to test execute on your Demo Database and let me know the correction.
DECLARE @REPORTBY AS NVARCHAR(1)
/* SELECT FROM [dbo].[OFPR] T0 */
/* WHERE */ DECLARE @DATEFROM datetime
SET @DATEFROM =/* T0.F_RefDate */'[%0]'
/* SELECT FROM [dbo].[OFPR] T1 */
/* WHERE */ DECLARE @DATETO datetime
SET @DATETO=/* T1.T_RefDate */'[%1]'
SET @DATEFROM = '20140101'
SET @DATETO = '20140131'
SELECT ISNULL(T01.BeginStr,'') + ' ' + CONVERT(NVARCHAR(20), T0.DOCNUM) [DOCUMENT NO.]
, T0.DocDate [DATE]
, T0.CardCode [CARDCODE]
, T0.CardName [NAME]
, T0.DocCurr
, T0.DocTotal [TOTAL incl. GST]
, T0.DocTotalFC [TOTAL (FC) incl. GST]
, T0.Comments [Remarks]
, T0.JrnlMemo
, T0.CounterRef [Ref 2]
/*BANK CHARGES*/
, T0.BcgSum [Bank Charges], T0.BcgSumFC [Bank Charges (FC)]
/*CHECK PAYMENT*/
, T2.CheckAct, T4.AcctName, T2.Currency [Check Curr.]
, T2.CheckSum, T0.CheckSumFC
, T2.AcctNum, T2.BankCode
/*BANK TRANSFER*/
, T0.TrsfrAcct, T4.AcctName, T0.TrsfrSum, T0.TrsfrSumFC
, T0.CashAcct, T6.AcctName, T0.CashSum, T0.CashSumFC
/*CREDIT CARD/ADJUSTMENT PAYMENT*/
, T03.CardName [ADJ. TYPE], T3.CreditAcct [ADJ. ACC.], T5.AcctName, T0.CreditSum, T0.CredSumFC
/*PAYMENT ON ACCOUNT*/
, T0.PayNoDoc, T0.NoDocSum, T0.NoDocSumFC
, T0.DocRate
, T0.DiffCurr
FROM OVPM T0
LEFT OUTER JOIN NNM1 T01 ON T0.ObjType = T01.ObjectCode AND T0.Series = T01.Series
LEFT OUTER JOIN VPM1 T2 ON T0.DocNum = T2.DocNum
LEFT OUTER JOIN (VPM3 T3 LEFT OUTER JOIN OCRC T03 ON T3.CreditCard = T03.CreditCard)
ON T0.DocNum = T3.DocNum left join OACT t4 on T2.CheckAct = T4.AcctCode left join OACT t5 on T5.AcctCode = t3.creditacct left join OACT T6 on t0.CashAcct = t6.AcctCode
WHERE T0.DocType = 'C'
AND T0.DOCDATE BETWEEN @DATEFROM AND @DATETO
UNION ALL
SELECT ISNULL(T01.BeginStr,'') + ' ' + CONVERT(NVARCHAR(20), T0.DOCNUM) [DOCUMENT NO.]
, T0.DocDate [DATE]
, T0.CardCode [CARDCODE]
, T0.CardName [PAY-TO NAME]
, T0.DocCurr
, T0.DocTotal [TOTAL incl. GST]
, T0.DocTotalFC [TOTAL (FC) incl. GST]
, T0.Comments [Remarks]
, T0.JrnlMemo
, T0.CounterRef [Ref 2]
/*BANK CHARGES*/
, T0.BcgSum [Bank Charges], T0.BcgSumFC [Bank Charges (FC)]
/*CHECK PAYMENT*/
, T2.CheckAct, T4.AcctName, T2.Currency [Check Curr.]
, T2.CheckSum, T0.CheckSumFC
, T2.AcctNum, T2.BankCode
/*BANK TRANSFER*/
, T0.TrsfrAcct, T4.AcctName, T0.TrsfrSum, T0.TrsfrSumFC
, T0.CashAcct, T6.AcctName, T0.CashSum, T0.CashSumFC
/*CREDIT CARD/ADJUSTMENT PAYMENT*/
, T03.CardName [ADJ. TYPE], T3.CreditAcct [ADJ. ACC.], T5.AcctName, T0.CreditSum, T0.CredSumFC
/*PAYMENT ON ACCOUNT*/
, T0.PayNoDoc, T0.NoDocSum, T0.NoDocSumFC
, T0.DocRate
, T0.DiffCurr
FROM OVPM T0
LEFT OUTER JOIN NNM1 T01 ON T0.ObjType = T01.ObjectCode AND T0.Series = T01.Series
LEFT OUTER JOIN VPM1 T2 ON T0.DocNum = T2.DocNum
LEFT OUTER JOIN (VPM3 T3 LEFT OUTER JOIN OCRC T03 ON T3.CreditCard = T03.CreditCard)
ON T0.DocNum = T3.DocNum left join OACT t4 on T2.CheckAct = T4.AcctCode left join OACT t5 on T5.AcctCode = t3.creditacct left join OACT T6 on t0.CashAcct = t6.AcctCode
WHERE T0.DocType = 'S'
AND T0.DOCDATE BETWEEN @DATEFROM AND @DATETO
UNION ALL
SELECT ISNULL(T01.BeginStr,'') + ' ' + CONVERT(NVARCHAR(20), T0.DOCNUM) [DOCUMENT NO.]
, T0.DocDate [DATE]
, T0.CardCode [CARDCODE]
, T0.CardName [NAME]
, T0.DocCurr
, T0.DocTotal [TOTAL incl. GST]
, T0.DocTotalFC [TOTAL (FC) incl. GST]
, T0.Comments [Remarks]
, T0.JrnlMemo
, T0.CounterRef [Ref 2]
/*BANK CHARGES*/
, T0.BcgSum [Bank Charges], T0.BcgSumFC [Bank Charges (FC)]
/*CHECK PAYMENT*/
, T2.CheckAct, T4.AcctName, T2.Currency
, T2.CheckSum, T0.CheckSumFC
, T2.AcctNum, T2.BankCode
/*BANK TRANSFER*/
, T0.TrsfrAcct, T4.AcctName, T0.TrsfrSum, T0.TrsfrSumFC
, T0.CashAcct, T6.AcctName, T0.CashSum, T0.CashSumFC
/*CREDIT CARD/ADJUSTMENT PAYMENT*/
, T03.CardName [ADJ. TYPE], T3.CreditAcct [ADJ. ACC.], T5.AcctName, T0.CreditSum, T0.CredSumFC
/*PAYMENT ON ACCOUNT*/
, T0.PayNoDoc
, CASE T0.DOCTYPE WHEN 'A' THEN 0 ELSE T0.NoDocSum END [PMNT ON ACC.]
, CASE T0.DOCTYPE WHEN 'A' THEN 0 ELSE T0.NoDocSumFC END [PMNT ON ACC. (FC)]
, T0.DocRate [Payment Rate]
, T0.DiffCurr
FROM OVPM T0
LEFT OUTER JOIN NNM1 T01 ON T0.ObjType = T01.ObjectCode AND T0.Series = T01.Series
LEFT OUTER JOIN VPM1 T2 ON T0.DocNum = T2.DocNum
LEFT OUTER JOIN (VPM3 T3 LEFT OUTER JOIN OCRC T03 ON T3.CreditCard = T03.CreditCard)
ON T0.DocNum = T3.DocNum left join OACT t4 on T2.CheckAct = T4.AcctCode left join OACT t5 on T5.AcctCode = t3.creditacct left join OACT T6 on t0.CashAcct = t6.AcctCode
WHERE T0.DocType = 'A'
AND T0.DOCDATE BETWEEN @DATEFROM AND @DATETOHi,
Please post your discussion without mentioning member name.
Try this:
DECLARE @REPORTBY AS NVARCHAR(1)
/* SELECT FROM [dbo].[OFPR] T0 */
/* WHERE */ DECLARE @DATEFROM datetime
SET @DATEFROM =/* T0.F_RefDate */'[%0]'
/* SELECT FROM [dbo].[OFPR] T1 */
/* WHERE */ DECLARE @DATETO datetime
SET @DATETO=/* T1.T_RefDate */'[%1]'
SET @DATEFROM = '20140101'
SET @DATETO = '20140131'
SELECT ISNULL(T01.BeginStr,'') + ' ' + CONVERT(NVARCHAR(20), T0.DOCNUM) [DOCUMENT NO.]
, T0.DocDate [DATE]
, T0.CardCode [CARDCODE]
, T0.CardName [NAME]
, T0.DocCurr
, T0.DocTotal [TOTAL incl. GST]
, T0.DocTotalFC [TOTAL (FC) incl. GST]
, T0.Comments [Remarks]
, T0.JrnlMemo
, T0.CounterRef [Ref 2]
/*BANK CHARGES*/
, T0.BcgSum [Bank Charges], T0.BcgSumFC [Bank Charges (FC)]
/*CHECK PAYMENT*/
, T2.CheckAct, T4.[AcctName], T2.Currency [Check Curr.]
, T2.CheckSum, T0.CheckSumFC
, T2.AcctNum, T2.BankCode
/*BANK TRANSFER*/
, T0.TrsfrAcct,T6.[AcctName],T0.TrsfrSum, T0.TrsfrSumFC
, T0.CashAcct,T4.[AcctName], T0.CashSum, T0.CashSumFC
/*CREDIT CARD/ADJUSTMENT PAYMENT*/
, T03.CardName [ADJ. TYPE], T3.CreditAcct [ADJ. ACC.], T5.[AcctName],T0.CreditSum, T0.CredSumFC
/*PAYMENT ON ACCOUNT*/
, T0.PayNoDoc, T0.NoDocSum, T0.NoDocSumFC
, T0.DocRate
, T0.DiffCurr
FROM OVPM T0
LEFT OUTER JOIN NNM1 T01 ON T0.ObjType = T01.ObjectCode AND T0.Series = T01.Series
LEFT OUTER JOIN VPM1 T2 ON T0.DocNum = T2.DocNum
LEFT OUTER JOIN (VPM3 T3 LEFT OUTER JOIN OCRC T03 ON T3.CreditCard = T03.CreditCard)
ON T0.DocNum = T3.DocNum left join OACT t4 on T2.CheckAct = T4.AcctCode left join OACT t5 on T5.AcctCode = t3.creditacct left join OACT T6 on t0.CashAcct = t6.AcctCode
WHERE T0.DocType = 'C'
AND T0.DOCDATE BETWEEN @DATEFROM AND @DATETO
union all
SELECT ISNULL(T01.BeginStr,'') + ' ' + CONVERT(NVARCHAR(20), T0.DOCNUM) [DOCUMENT NO.]
, T0.DocDate [DATE]
, T0.CardCode [CARDCODE]
, T0.CardName [NAME]
, T0.DocCurr
, T0.DocTotal [TOTAL incl. GST]
, T0.DocTotalFC [TOTAL (FC) incl. GST]
, T0.Comments [Remarks]
, T0.JrnlMemo
, T0.CounterRef [Ref 2]
/*BANK CHARGES*/
, T0.BcgSum [Bank Charges], T0.BcgSumFC [Bank Charges (FC)]
/*CHECK PAYMENT*/
, T2.CheckAct, T4.[AcctName], T2.Currency [Check Curr.]
, T2.CheckSum, T0.CheckSumFC
, T2.AcctNum, T2.BankCode
/*BANK TRANSFER*/
, T0.TrsfrAcct,T6.[AcctName], T0.TrsfrSum, T0.TrsfrSumFC
, T0.CashAcct,T4.[AcctName], T0.CashSum, T0.CashSumFC
/*CREDIT CARD/ADJUSTMENT PAYMENT*/
, T03.CardName [ADJ. TYPE], T3.CreditAcct [ADJ. ACC.], T5.[AcctName],T0.CreditSum, T0.CredSumFC
/*PAYMENT ON ACCOUNT*/
, T0.PayNoDoc, T0.NoDocSum, T0.NoDocSumFC
, T0.DocRate
, T0.DiffCurr
FROM OVPM T0
LEFT OUTER JOIN NNM1 T01 ON T0.ObjType = T01.ObjectCode AND T0.Series = T01.Series
LEFT OUTER JOIN VPM1 T2 ON T0.DocNum = T2.DocNum
LEFT OUTER JOIN (VPM3 T3 LEFT OUTER JOIN OCRC T03 ON T3.CreditCard = T03.CreditCard)
ON T0.DocNum = T3.DocNum left join OACT t4 on T2.CheckAct = T4.AcctCode left join OACT t5 on T5.AcctCode = t3.creditacct left join OACT T6 on t0.CashAcct = t6.AcctCode
WHERE T0.DocType = 'S'
AND T0.DOCDATE BETWEEN @DATEFROM AND @DATETO
union all
SELECT ISNULL(T01.BeginStr,'') + ' ' + CONVERT(NVARCHAR(20), T0.DOCNUM) [DOCUMENT NO.]
, T0.DocDate [DATE]
, T0.CardCode [CARDCODE]
, T0.CardName [NAME]
, T0.DocCurr
, T0.DocTotal [TOTAL incl. GST]
, T0.DocTotalFC [TOTAL (FC) incl. GST]
, T0.Comments [Remarks]
, T0.JrnlMemo
, T0.CounterRef [Ref 2]
/*BANK CHARGES*/
, T0.BcgSum [Bank Charges], T0.BcgSumFC [Bank Charges (FC)]
/*CHECK PAYMENT*/
, T2.CheckAct, T4.[AcctName], T2.Currency [Check Curr.]
, T2.CheckSum, T0.CheckSumFC
, T2.AcctNum, T2.BankCode
/*BANK TRANSFER*/
, T0.TrsfrAcct, T6.[AcctName], T0.TrsfrSum, T0.TrsfrSumFC
, T0.CashAcct,T4.[AcctName], T0.CashSum, T0.CashSumFC
/*CREDIT CARD/ADJUSTMENT PAYMENT*/
, T03.CardName [ADJ. TYPE], T3.CreditAcct [ADJ. ACC.], T5.[AcctName],T0.CreditSum, T0.CredSumFC
/*PAYMENT ON ACCOUNT*/
, T0.PayNoDoc, T0.NoDocSum, T0.NoDocSumFC
, T0.DocRate
, T0.DiffCurr
FROM OVPM T0
LEFT OUTER JOIN NNM1 T01 ON T0.ObjType = T01.ObjectCode AND T0.Series = T01.Series
LEFT OUTER JOIN VPM1 T2 ON T0.DocNum = T2.DocNum
LEFT OUTER JOIN (VPM3 T3 LEFT OUTER JOIN OCRC T03 ON T3.CreditCard = T03.CreditCard)
ON T0.DocNum = T3.DocNum left join OACT t4 on T2.CheckAct = T4.AcctCode left join OACT t5 on T5.AcctCode = t3.creditacct left join OACT T6 on t0.CashAcct = t6.AcctCode
WHERE T0.DocType = 'A'
AND T0.DOCDATE BETWEEN @DATEFROM AND @DATETO
Thanks & Regards,
Nagarajan -
[Q] Query for outstanding payment per month
I have data like this:
Bill: $100
In January, I paid $50
In Febuary, I paid $30
In March, I paid $20
I used 2 tables (table A and table B)
Table A used to save total amount of the bill. Table B used to save how much I paid the bills. Table A Primary Key is the Foreign Key for Table B.
I need to make a report like this:
In January the report will be:
Bill: $100
Payment1: $50
In Febuary:
Bill: $100
Payment1: $50
Payment2: $30
In March:
Bill: $100
Payment1: $50
Payment2: $30
Payment3: $20
In May it won't appear because it already paid in March.
This is my Query:
SELECT A.BILL, A.BILL_DATE, B.PAYMENT, B.PAYMENT_DATE
FROM TABLE_A AS A
LEFT JOIN TABLE_B AS B ON A.BILL_NO = B.BILL_NO
WHERE MONTH(A.BILL_DATE) <= @PERIOD_MONTH AND YEAR(A.BILL_DATE) = @PERIOD_YEARThanks for answering, but I just tried and I don't think its the result.
This is my table structure:
CREATE TABLE BILL
BILL_ID INT INDENTITY NOTNULL
BILL_DATE DATETIME
BILL_AMOUNT NUMERIC(10,2)
BILL_BALANCE NUMERIC(10,2)
CREATE TABLE PAYMENT
PAYMENT_ID INT IDENTITY NOTNULL
BILL_ID INT
PAYMENT_DATE DATETIME
PAYMENT_AMOUNT NUMERIC(10,2)
)INSERT INTO @BILL VALUES(1,'2014-01-01',100,0)PAYMENT 1INSERT INTO @PAYMENT VALUES(1,1,'2014-01-02',50)
UPDATE BILL SET BILL_BALANCE = BILL_BALANCE + 50 WHERE BILL_ID = 1PAYMENT 2INSERT INTO @PAYMENT VALUES(1,1,'2014-02-01',30)
UPDATE BILL SET BILL_BALANCE = BILL_BALANCE + 30 WHERE BILL_ID = 1
Everytime I paid, BILL_BALANCE = BILL_BALANCE + PAYMENT_AMOUNT
In january:
BILL_AMOUNT = $100
BILL_BALANCE = $50
In Feb:
BILL_BALANCE = $80 etc.
at first I have 11 Payment data, after I'm using cross join, it become 780 data. -
Query for updating the records
I have the two tables....
CREATE TABLE temp_1
( ST_NM VARCHAR2(30),STATUS_ID VARCHAR2(1) NOT NULL ENABLE,ST_ID VARCHAR2(20) primary key,REJ_USER_NM varchar2(10))
sample Data :
insert into temp_1 values('S010054','R','ST9749109','TEST_1');
insert into temp_1 values('S010179','R','ST9749147','');
insert into temp_1 values('S010582','N','ST9749258','');
CREATE TABLE temp_2
( REJ_USER_NM VARCHAR2(20),ST_NM VARCHAR2(30),
STATUS_ID VARCHAR2(1) NOT NULL ENABLE,ST_ID VARCHAR2(20))
sample data:
insert into temp_2 values('','S010054','N','ST9749109');
insert into temp_2 values('','S010054','N','ST9749109');
insert into temp_2 values('TEST_1','S010054','N','ST9749109'');
insert into temp_2 values('','S010054','I','ST9749109');
insert into temp_2 values('','S010179','N','ST9749147');
insert into temp_2 values('TEST_2','S010179','N','ST9749147');
insert into temp_2 values('','S010179','N','ST9749147');
insert into temp_2 values('','S010179','N','ST9749147')
insert into temp_2 values('TEST_5','S010582','R','ST9749258');
insert into temp_2 values('TEST_5','S010582','N','ST9749258');
insert into temp_2 values('','S010582','N','ST9749258');
insert into temp_2 values('','S010582','N','ST9749258')
I want the UPDATE query based on below conditions to update the REJ_USER_NM in temp_1 table.
From temp_1 table ,STATUS_ID is 'R' and REJ_USER_NM is null and compare the set_id column value
with the temp_2 table,where REJ_USER_NM is not null and status id is 'N'. REJ_USER_NM column from
temp_2 table need to be update in the REJ_USER_NM column of temp_1 table.
After completion of updation,output is in below format; if i run below qry
====================================
select * from temp_1;
{S010054},{R},{ST9749109},{TEST_1}
{S010179},{R},{ST9749147},{TEST_2}
{S010582},{N},{ST9749258},{}
======================
Edited by: 849971 on May 2, 2011 8:25 PMWhy is that the row
{S010582},{N},{ST9749258},{}
is not updated to TEST_5 ?? Based on your rules and data. it must be updated to test_5. Are you missng any rules?
Try some thing like,
UPDATE temp_1
SET REJ_USER_NM =
(SELECT REJ_USER_NM
FROM temp_2
WHERE status_id = 'N'
AND temp_1.st_id = temp_2.st_id
AND temp_2.REJ_USER_NM IS NOT NULL) -
Update query for 2 lakhs records
I have 2 tables with 3 common columns (Col1, col2,Primary). One common column name is primary (oracle key word). No indexes are used on these tables. I need to write an update query as shown below.
Emp table
Col1 col2 primay
100 101 y
103 104 n
201 105 y
100 101 y
Dept table
Col1 col2 primay
100 101 null
103 104 null
000 656 null
Update query Result
Col1 col2 primary
100 101 y
103 104 n
Please help me.
ThanksUpdate dept d
set d.primay = (select distinct e.primay from emp e where e.col1 = d.col1 and e.col2 = d.col2);
In emp table there are 100 and 101 with two entries but with same primay value. so to handle such scenarios I have taken distinct iniside select statement.
if you have a case like where in emp table col1 and col2 are same and having different primay table, then obviously you should tell which value should go and update the dept table and based on what logic.
Maybe you are looking for
-
HP Expert Day - Sept. 20, '12: Your Chance to ASK THE EXPERTS!
Thank you for coming to Expert Day – the event has now concluded. **To find out about future HP Expert Day events, check out this page** On behalf of the Experts, I would like to thank you for coming to the Forum to connect with us. We hope you will
-
I just noticed today that any Graph or PDF report I try to view I get the following error - Error from reports from ZAM - File does not begin with '%PDF-'. I tried to just save the file and then open it, but get the same error. I can open other pdf f
-
How do I revert back to my itouch iTunes account?
I purchased an iPhone this weekend and when I plugged it in iTunes gave me the option of using existing account or setting up a new account. I set up a new account using the same username and password as my old account thinking my apps from iTouch wo
-
Apple Remote Desktop Admin 3.7.2 Yosemite wake issue
Another serious problems is.... Apple Remote Desktop Admin 3.7.2 in Yosemite cannot wake up clients Mac remotely. Control has no problem after waking up. On 10.9.x I can wake up remote Mac clients if sleeping. Now I have to do it on the other Mac run
-
I need to setup our time capsule with an arris cable router
We have an existing 1st Gen Time Capsule but have moved. We went from Verizon Fios to CableVision Optimum Online. The cable modem is an Arris TM822G plugged into the the WAN port of the TC. I can connect to the cable modem via ethernet and that works