on 10-14-2014 2:21 PM
Bom dia,
Fiz um relatório em Crystal Reports, porém os produtos estão sendo replicados, gostaria que ficasse apenas os produtos do pedido de venda. Segue o Código gerado pelo Crystal abaixo.
SELECT "OCRD"."CardName", "CRD7"."TaxId0", "CRD7"."TaxId4", "CRD7"."TaxId1", "OCRD"."Phone1", "CRD1"."State", "CRD1"."City", "CRD1"."ZipCode", "CRD1"."Block", "CRD1"."StreetNo", "CRD1"."Street", "ORDR"."TaxDate", "OCTG"."PymntGroup", "RDR1"."ItemCode", "RDR1"."Dscription", "RDR1"."unitMsr", "RDR1"."Quantity", "RDR1"."Price", "ORDR"."DocTotal"
FROM (((("SAP"."dbo"."CRD1" "CRD1" INNER JOIN "SAP"."dbo"."OCRD" "OCRD" ON "CRD1"."CardCode"="OCRD"."CardCode") INNER JOIN "SAP"."dbo"."CRD7" "CRD7" ON "CRD1"."CardCode"="CRD7"."CardCode") INNER JOIN "SAP"."dbo"."OCTG" "OCTG" ON "OCRD"."CardCode"="OCTG"."CardCode") INNER JOIN "SAP"."dbo"."ORDR" "ORDR" ON "OCTG"."CardCode"="ORDR"."CardCode") INNER JOIN "SAP"."dbo"."RDR1" "RDR1" ON "ORDR"."CardCode"="RDR1"."CardCode"
SELECT "OADM"."CompnyName", "OADM"."PrintHeadr", "OADM"."TaxIdNum", "OADM"."CompnyAddr"
FROM "SAP"."dbo"."OADM" "OADM"
Abaixo em anexo a print do relátorio dentro do SAP
Bom dia Cristiano!
Analisando a sua consulta, o problema está na ligação da CRD1, pois como ela possui o cadastro de endereços do PN, se possuir mais de um endereço cadastrado as linhas vão ficar duplicadas. Verifique se a consulta abaixo atende á suas necessidades.
select t0.CardCode,
t4.TaxId0,
t4.TaxId4,
t4.TaxId1,
t2.Phone1,
t3.State,
t3.City,
t3.ZipCode,
t3.Block,
t3.StreetNo,
t3.Street,
t0.TaxDate,
t5.PymntGroup,
t1.ItemCode,
t1.Dscription,
t1.unitMsr,
t1.Quantity,
t1.Price,
t0.DocTotal
from ORDR T0 inner join RDR1 T1 on t0.DocEntry = t1.DocEntry
inner join OCRD T2 on t2.CardCode = t0.CardCode
inner join CRD1 T3 on t3.CardCode = t2.CardCode
and t2.ShipToDef = t3.Address
inner join CRD7 T4 on t4.CardCode = t2.CardCode
inner join OCTG T5 on T5.GroupNum = t0.GroupNum
Att.
Mayara
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ops.. me desculpe!
Além da CRD1 ter mais de uma linha para cada PN a CRD7 também! Segue Consulta:
select t0.CardCode,
t4.TaxId0,
t4.TaxId4,
t4.TaxId1,
t2.Phone1,
t3.State,
t3.City,
t3.ZipCode,
t3.Block,
t3.StreetNo,
t3.Street,
t0.TaxDate,
t5.PymntGroup,
t1.ItemCode,
t1.Dscription,
t1.unitMsr,
t1.Quantity,
t1.Price,
t0.DocTotal
from ORDR T0 inner join RDR1 T1 on t0.DocEntry = t1.DocEntry
inner join OCRD T2 on t2.CardCode = t0.CardCode
inner join CRD1 T3 on t3.CardCode = t2.CardCode
and t2.ShipToDef = t3.Address
inner join CRD7 T4 on t4.CardCode = t2.CardCode
and t2.ShipToDef = t4.Address
inner join OCTG T5 on T5.GroupNum = t0.GroupNum
Veja se agora continua duplicando ...
Att.
Mayara
Veja se este funciona Cristiano!
select t0.CardCode,
t4.TaxId0,
t4.TaxId4,
t4.TaxId1,
t2.Phone1,
t3.State,
t3.City,
t3.ZipCode,
t3.Block,
t3.StreetNo,
t3.Street,
t0.TaxDate,
t5.PymntGroup,
t1.ItemCode,
t1.Dscription,
t1.unitMsr,
t1.Quantity,
t1.Price,
t0.DocTotal
from ORDR T0 inner join RDR1 T1 on t0.DocEntry = t1.DocEntry
inner join OCRD T2 on t2.CardCode = t0.CardCode
inner join CRD1 T3 on t3.CardCode = t2.CardCode
and t2.ShipToDef = t3.Address
and t3.AdresType= 'S'
inner join CRD7 T4 on t4.CardCode = t2.CardCode
and t2.ShipToDef = t4.Address
and t4.AddrType = 'S'
inner join OCTG T5 on T5.GroupNum = t0.GroupNum
Oi Cristiano,
Magina!
para pegar de um pedido especifico, depois do comando que te passei ponha where t0.docentry = [Número do pedido que você quer]
Att.
Mayara
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ola,
de uma olhada no meu post, tem dois links para PDFs que explica bem a utilização do Crystal Reports.
Abraço
Fabio.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cristiano,
Reveja o agrupamento que voce esta definindo no relatorio.
A sugestão do Fabio, de executar via comando dentro do Crystal, costuma oferecer melhores resultados para layouts do tipo que voce esta tentando executar.
Boa sorte.
Wagner...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cristiano, bom dia,
faça o seguinte teste.
1) pegue o SQL que postei de pedido de compra no link
2) troque todas as tabelas OPOR para ORDR, e todas começando com POR para RDR (exemplo, POR1 para RDR1, POR2 para RDR2.
Teste executar o SQL, talvez ajude vc.
Outro detalhe, eu crio o SQL da empresa em um 2o comando no Crystal Reports.
No meu "comando" está o SQL principal do relatório, já no "DadosEmpresa", está aquele seu último SQL
E não faço ligações entre eles, o Crystal Reports reclama mas é só seguir em frente.
Abraço
Fabio.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
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.