Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
fbio_bilicki
Active Contributor
2,801


Boa tarde a todos,

segue abaixo uma SQL que desenvolvi para impressão de pedido de compra, a mesma pode ser adaptada para impressão de pedido de venda, é só trocar as tabelas.

Este comando usa o parâmetro DocKey, é para ser usado como layout.

select
T0.DocEntry,
T0.DocDate,
T0.CardCode,
T0.CardName,
T3.CardFName,
T0.TotalExpSC,
T0.DiscSum,
ROW_NUMBER() OVER (ORDER BY T1.LineNum) as Num,
T1.ItemCode,
T8.FrgnName,
T8.ItemName,
T1.Dscription,
T1.Freetxt,
T9.NcmCode,
T1.Quantity,
T1.unitMsr,
T1.Price,
T1.LineTotal,
T1.ShipDate,
T8.InvntItem,
T2.TaxId0,
T2.TaxId1,
T2.AddrTypeB,
T2.StreetB,
T2.StreetNoB,
T2.BlockB,
T2.CityB,
T2.StateB,
T2.ZipCodeB,
T3.[CntctPrsn], T4.[TrnspName],
('('+T3.[Phone2]+') '+T3.Phone1) as Tel,
('('+T3.[Phone2]+') '+T3.Fax) as Fax,
T3.[E_Mail],
T5.[SlpName],
T6.PymntGroup,
(select sum(T7.TaxSum) FROM POR4 T7 where T7.DocEntry = T0.DocEntry and T7.LineNum = T1.LineNum and T7.StaCode like 'IPI%') AS ValorIPI,
(select max(T7.TaxRate) FROM POR4 T7 where T7.DocEntry = T0.DocEntry and T7.LineNum = T1.LineNum and T7.StaCode like 'IPI%') AS AliIPI,
(select sum(T7.TaxSum) FROM POR4 T7 where T7.DocEntry = T0.DocEntry and T7.LineNum = T1.LineNum and T7.StaCode like 'ICM%') AS ValorICM,
(select max(T7.TaxRate) FROM POR4 T7 where T7.DocEntry = T0.DocEntry and T7.LineNum = T1.LineNum and T7.StaCode like 'ICM%') AS AliICM,
T0.Comments,
T2.Carrier as Transp,
T10.CardName as NomeTransp,
ISNULL(T11.[Descr],T11.[Usage]) as Utilizacao
FROM OPOR T0
INNER JOIN POR1 T1 ON T1.DocEntry = T0.DocEntry
INNER JOIN POR12 T2 ON T2.DocEntry = T0.DocEntry
INNER JOIN OCRD T3 ON T3.CardCode = T0.CardCode
LEFT JOIN OSHP T4 ON T4.TrnspCode = T0.TrnspCode
LEFT JOIN OSLP T5 ON T5.SlpCode = T0.SlpCode
LEFT JOIN OCTG T6 ON T6.GroupNum = T0.GroupNum
LEFT JOIN OITM T8 ON T8.ItemCode = T1.ItemCode
LEFT JOIN ONCM T9 ON T9.AbsEntry = T8.NCMCode
LEFT JOIN OCRD T10 ON T10.CardCode = T2.Carrier
LEFT JOIN OUSG T11 ON T11.ID = T1.Usage
WHERE T0.DocEntry = {?DocKey@}

Minha impressão (parcial)



Eu fiz uma quebra por descrição da utilização para poder saber qual a utilização do pedido.

Espero ter ajudado a todos,

Um grande abraço

Fabio

SAP 8.82 PL16 / SAP 9.0 PL13

5 Comments
Labels in this area