cancel
Showing results for 
Search instead for 
Did you mean: 

Detail and batch invoice error

eurbina002
Discoverer
0 Kudos

Hello, I am having problems when trying to see the detail invoice and batches, since I created a stored procedure, but it gives me an error when the movement of more than one batch was made in the invoices


my procedure:

Select F.DocEntry,F.DocDate,F.DocNum,

(Select top 1 (D1.Street + ', '+D1.Block+', '+D1.City)Address

From OCRD C1

Inner Join CRD1 D1 on C1.CardCode = D1.CardCode and D1.AdresType = 'B'

Where C1.CardCode = F.CardCode

) Address,

F.CardCode,F.CardName,C.AddID NRC,F.DocTotal[Total Factura], V.SlpName, CP.PymntGroup,C.VatIdUnCmp,[dbo].[CantidadConLetra] (F.docTotal) Letras,F.DiscSum DescTotal,

F1.ItemCode,F1.CodeBars,F1.Dscription,F1.Quantity,F1.Price,F1.GPBefDisc PrecioBruto,F1.TaxCode,F1.LineTotal,F1.LineTotal *1.13 GTotal,F1.VatSum,F1.PriceBefDi,F1.DiscPrcnt,

(Case When F1.TaxCode = 'EXE' then F1.LineTotal end) VExento,

(Case when F1.TaxCode ='IVA' then F1.LineTotal end) VGrabado,

(Case when F1.TaxCode ='IVA' then F1.LineTotal *1.13 end) VGrabadoCF,

(Case when F1.TaxCode ='NS' then F1.LineTotal end) VNOSujeto,

(select Name from [@SOCIOSGIRO] where Code = C.U_TypeGiroSN)Giro,

C.CardFName Establecimiento,f1.baseentry,

(Select top 1 DocNum From ODLN where DocEntry =F1.BaseEntry ),

(select T1.DistNumber

FROM IBT1 AS T0

left join OBTN AS t1 ON t0.BatchNum=t1.DistNumber

where t0.BaseType=15 and t0.Quantity>0 and BaseEntry = f1.BaseEntry and BaseType=15 and T1.ItemCode = f1.ItemCode) Lote,

(select top 1 T1.ExpDate

FROM IBT1 AS T0

left join OBTN AS t1 ON t0.BatchNum=t1.DistNumber

where t0.BaseType=15 and t0.Quantity>0 and BaseEntry = f1.BaseEntry and BaseType=15 and T1.ItemCode = f1.ItemCode) ExpDate

From OINV F

Inner join INV1 F1 on F.DocEntry = F1.DocEntry

Inner Join OCRD C on F.CardCode = C.CardCode

Inner Join NNM1 N on F.Series = N.Series

Inner Join OITM A on F1.ItemCode = A.ItemCode

Inner Join OSLP V on F.SlpCode = V.SlpCode

Inner Join OCTG CP on F.GroupNum = CP.GroupNum

Where F.DocEntry =51

anne-petteroe
Community Manager
Community Manager
0 Kudos

Hello Emin,

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.

Feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will also help you when preparing questions for the community.

Should you wish, you can revise your question by selecting Actions, then Edit.

Kind regards,
Anne


Accepted Solutions (0)

Answers (0)