(259) Multi Page Invoice Tutorial - YouTube
IF exists (select * from INFORMATION_SCHEMA.ROUTINES where ROUTINE_NAME = 'dd_Invoice') begin
DROP proc dd_Invoice
end
GO
CREATE proc dd_Invoice
-- dd_Invoice 'SOP INVOICES'
@bachnumb varchar(15)
AS
set transaction isolation level read uncommitted
select
h.sopnumbe,
h.soptype,
h.BACHNUMB,
h.docid,
h.CUSTNMBR,
h.CUSTNAME,
h.CSTPONBR,
rtrim(h.CUSTNAME) + char(13) + char(10) + rtrim(shipto.ADDRESS1) + char(13) + char(10) + rtrim(shipto.ADDRESS2) + char(13) + char(10) + rtrim(shipto.CITY) + ' ' + rtrim(shipto.state) + ', ' + rtrim(shipto.ZIP) as ShipTo,
rtrim(h.CUSTNAME) + char(13) + char(10) + rtrim(billto.ADDRESS1) + char(13) + char(10) + rtrim(billto.ADDRESS2) + char(13) + char(10) + rtrim(billto.CITY) + ' ' + rtrim(billto.state) + ', ' + rtrim(billto.ZIP) as BillTo,
l.itemnmbr,
l.CMPNTSEQ,
l.quantity,
l.uofm,
l.UNITPRCE,
l.XTNDPRCE,
h.SUBTOTAL,
h.FRTAMNT,
h.MISCAMNT,
h.DOCAMNT
from sop10100 h
join sop10200 l on l.sopnumbe = h.sopnumbe and l.soptype = h.soptype
join rm00102 billto on billto.CUSTNMBR = h.CUSTNMBR and billto.ADRSCODE = h.PRBTADCD
join rm00102 shipto on shipto.CUSTNMBR = h.CUSTNMBR and shipto.ADRSCODE = h.PRSTADCD
where
h.BACHNUMB = @bachnumb
and h.soptype = 3
order by h.SOPNUMBE
GO
GRANT EXEC ON dd_Invoice TO PUBLIC