Check this,
Declare @Docnum int
Set @Docnum =/* SELECT Max(T0.Docnum) FROM opdn T0 WHERE T0.Docnum > */ '[%0]'
select n.DocNum ,n.DocDate ,n.CardCode ,n.CardName , r.ItemCode ,r.ItemName ,r1.IntrSerial 'Serial No',n1.Price from sri1 r
inner join osri r1 on r.SysSerial =r1.SysSerial and r1.ItemCode=r.ItemCode
inner join pdn1 n1 on n1.DocEntry =r.BaseEntry and n1.ItemCode=r.ItemCode and n1.LineNum=r.BaseLinNum
inner join opdn n on n.DocEntry =n1.DocEntry
where r.BaseType=20 and n.docnum = @Docnum