Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

OCRD, OINV

Hello,

please, could you advice me what to do?

My boss wants to check new customers and their activities in asked period.  The problem is when a new client has been already created, but he has not any invoices yet,  I have to use 2 queries instead of one. In the 1st one I see all "incoming" customers and in the 2nd one I see only customers who have already some invoices.

Could you help me with this?

1//SELECT T2.CardCode AS 'OP', T0.CardName, t4.gROUPNAME, T3.[SlpName], T2.[Balance], T2.[DNotesBal], T2.[OrdersBal], T2.[CreditLine], T2.[DNoteBalFC], T2.[OrderBalFC], T2.[DNoteBalSy], T2.[OrderBalSy] FROM ACRD T0

INNER JOIN OUSR T1 ON T1.USERID = T0.UserSign

INNER JOIN OCRD T2 ON T2.CardCode = T0.CardCode INNER JOIN OSLP T3 ON T2.SlpCode = T3.SlpCode INNER JOIN OCRG T4 ON T2.GroupCode = T4.GroupCode

WHERE T0.LogInstanc = 1 AND T0.createdate >=[%0] and T0.createdate <=[%1]

2//

SELECT T2.CardCode AS 'OP', T0.CardName,T5.[GroupName],T4.[SlpName], t3.GrosProfit, T2.[Balance], T2.[DNotesBal], T2.[OrdersBal], T2.[CreditLine] FROM ACRD T0

INNER JOIN OUSR T1 ON T1.USERID = T0.UserSign

INNER JOIN OCRD T2 ON T2.CardCode = T0.CardCode Inner join OINV T3 ON T3.CardCode = T2.CardCode INNER JOIN OSLP T4 ON T2.SlpCode = T4.SlpCode INNER JOIN OCRG T5 ON T0.GroupCode = T5.GroupCode

WHERE T0.LogInstanc = 1 AND T0.createdate >=[%0] and T0.createdate <=[%1]

Thank you,

regards

Martina

Former Member
replied

Hi,

Check This

SELECT Distinct T0.CardCode AS 'OP',

T0.CardName, t4.gROUPNAME, T3.[SlpName],

T0.[Balance], T0.[DNotesBal], T0.[OrdersBal],

T0.[CreditLine], T0.[DNoteBalFC], T0.[OrderBalFC],

T0.[DNoteBalSy], T0.[OrderBalSy] ,T5.GrosProfit

FROM OCRD T0

INNER JOIN OUSR T1 ON T1.USERID = T0.UserSign

INNER JOIN OSLP T3 ON T0.SlpCode = T3.SlpCode

INNER JOIN OCRG T4 ON T0.GroupCode = T4.GroupCode

LEFT OUTER JOIN OINV T5 ON T0.CardCode=T5.CardCode

WHERE T0.createdate >=[%0] and T0.createdate <=[%1]

Order By T0.CardCode

Thanks,

Nithi

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question