on 08-24-2018 12:38 PM
Dear Experts,
I need an SAP Business one query that will show in the below format;
The query should have a join where a sales order is made and joined to it's delivery and from delivery to Sales invoice. The query should also take into consideration where sales order is done and no delivery is done but an invoice is done on the sales order.
Please treat this as urgent. I do not want duplication but a one row output as shown above.
Regards
Justice
Hi,
Try and change query from below thread,
https://archive.sap.com/discussions/thread/3583628
Regards,
Nagarajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Justice,
You need to check the lines (RDR1) where you can find the TargetType
15 = Delivery / 13 = Sales-Invoice / ...
you can try for the first steps:
select TOP 100 T0.DocNum, T0.cardCode, T1.ItemCode, T1.TargetType
,Case
when T1.TargetType = '15' THEN (Select MIN(DocEntry) from DLN1 Where BaseRef = T0.Docnum)
when T1.TargetType = '13' THEN (Select MIN(DocEntry) from INV1 Where BaseRef = T0.Docnum)
ELSE '' END
FROM ORDR T0
INNER JOIN RDR1 T1 on T0.DocEntry = T1.DocEntry
Where T1.TargetType <> '-1'
Order by T0.Docnum desc
Targettype '-1' = closed or not delivered
The subquery in CASE ... only collect the first Entry of the Target Document.
Maybe you can try the way back from Invoice --> Delivery --> sales order...
you need these fields: INV1.Basetype, DLN1.BaseType
BaseType '17' = SalesOrder
BaseRef = DocEntry
hope that helps
Best regards
Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
9 | |
8 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.