Exemplo de campo a ser seguido para aplicação dos filtros: WHERE PEDNUMPED = 100 (PEDNUMPED = E120PED.NumPed)
A lista identifica o nome do campo que deve ser utilizado no filtro, bem como a Tabela/Campo que cada nome de campo representa.
PEDCODEMP representa a tabela/campo E120PED.CODEMP
PEDCODFIL representa a tabela/campo E120PED.CODFIL
PEDNUMPED representa a tabela/campo E120PED.NUMPED
PEDTIPPED representa a tabela/campo E120PED.TIPPED
PEDPRCPED representa a tabela/campo E120PED.PRCPED
PEDTNSPRO representa a tabela/campo E120PED.TNSPRO
PEDTNSSER representa a tabela/campo E120PED.TNSSER
PEDDATEMI representa a tabela/campo E120PED.DATEMI
PEDHOREMI representa a tabela/campo E120PED.HOREMI
PEDDATPRV representa a tabela/campo E120PED.DATPRV
PEDHORPRV representa a tabela/campo E120PED.HORPRV
PEDOBSPED representa a tabela/campo E120PED.OBSPED
PEDCODCLI representa a tabela/campo E120PED.CODCLI
PEDCATCLI representa a tabela/campo E120PED.CATCLI
PEDQTDVPF representa a tabela/campo E120PED.QTDVPF
PEDQTDMFP representa a tabela/campo E120PED.QTDMFP
PEDINDAGR representa a tabela/campo E120PED.INDAGR
PEDSEQENT representa a tabela/campo E120PED.SEQENT
PEDSEQCOB representa a tabela/campo E120PED.SEQCOB
PEDSEQCTO representa a tabela/campo E120PED.SEQCTO
PEDPEDCLI representa a tabela/campo E120PED.PEDCLI
PEDCODROE representa a tabela/campo E120PED.CODROE
PEDSEQROE representa a tabela/campo E120PED.SEQROE
PEDCODREP representa a tabela/campo E120PED.CODREP
PEDCODMOE representa a tabela/campo E120PED.CODMOE
PEDCODMCP representa a tabela/campo E120PED.CODMCP
PEDDATMFP representa a tabela/campo E120PED.DATMFP
PEDCOTMFP representa a tabela/campo E120PED.COTMFP
PEDDATMOE representa a tabela/campo E120PED.DATMOE
PEDCOTMOE representa a tabela/campo E120PED.COTMOE
PEDFECMOE representa a tabela/campo E120PED.FECMOE
PEDCODFCR representa a tabela/campo E120PED.CODFCR
PEDDATFCR representa a tabela/campo E120PED.DATFCR
PEDCODCPG representa a tabela/campo E120PED.CODCPG
PEDPGTANT representa a tabela/campo E120PED.PGTANT
PEDCODFPG representa a tabela/campo E120PED.CODFPG
PEDQTDABE representa a tabela/campo E120PED.QTDABE
PEDQTDAEN representa a tabela/campo E120PED.QTDAEN
PEDCODTRA representa a tabela/campo E120PED.CODTRA
PEDCODRED representa a tabela/campo E120PED.CODRED
PEDCODVIA representa a tabela/campo E120PED.CODVIA
PEDPLAVEI representa a tabela/campo E120PED.PLAVEI
PEDVLRFUM representa a tabela/campo E120PED.VLRFUM
PEDQTDFRE representa a tabela/campo E120PED.QTDFRE
PEDFORFRE representa a tabela/campo E120PED.FORFRE
PEDVLRFRE representa a tabela/campo E120PED.VLRFRE
PEDCIFFOB representa a tabela/campo E120PED.CIFFOB
PEDVLRSEG representa a tabela/campo E120PED.VLRSEG
PEDVLREMB representa a tabela/campo E120PED.VLREMB
PEDVLRENC representa a tabela/campo E120PED.VLRENC
PEDVLROUT representa a tabela/campo E120PED.VLROUT
PEDVLRDAR representa a tabela/campo E120PED.VLRDAR
PEDVLRFRD representa a tabela/campo E120PED.VLRFRD
PEDVLROUD representa a tabela/campo E120PED.VLROUD
PEDPERDS1 representa a tabela/campo E120PED.PERDS1
PEDPERDS2 representa a tabela/campo E120PED.PERDS2
PEDPERDS3 representa a tabela/campo E120PED.PERDS3
PEDPERDS4 representa a tabela/campo E120PED.PERDS4
PEDVLRBPR representa a tabela/campo E120PED.VLRBPR
PEDVLRDPR representa a tabela/campo E120PED.VLRDPR
PEDVLRBSE representa a tabela/campo E120PED.VLRBSE
PEDVLRDSE representa a tabela/campo E120PED.VLRDSE
PEDVLRDS1 representa a tabela/campo E120PED.VLRDS1
PEDVLRDS2 representa a tabela/campo E120PED.VLRDS2
PEDVLRDS3 representa a tabela/campo E120PED.VLRDS3
PEDVLRDS4 representa a tabela/campo E120PED.VLRDS4
PEDVLROFE representa a tabela/campo E120PED.VLROFE
PEDVLRDZF representa a tabela/campo E120PED.VLRDZF
PEDVLRBIP representa a tabela/campo E120PED.VLRBIP
PEDVLRIPI representa a tabela/campo E120PED.VLRIPI
PEDVLRBIC representa a tabela/campo E120PED.VLRBIC
PEDVLRICM representa a tabela/campo E120PED.VLRICM
PEDVLRBSI representa a tabela/campo E120PED.VLRBSI
PEDVLRSIC representa a tabela/campo E120PED.VLRSIC
PEDVLRBSP representa a tabela/campo E120PED.VLRBSP
PEDVLRSTP representa a tabela/campo E120PED.VLRSTP
PEDVLRBSC representa a tabela/campo E120PED.VLRBSC
PEDVLRSTC representa a tabela/campo E120PED.VLRSTC
PEDVLRBIS representa a tabela/campo E120PED.VLRBIS
PEDVLRISS representa a tabela/campo E120PED.VLRISS
PEDVLRBIR representa a tabela/campo E120PED.VLRBIR
PEDVLRIRF representa a tabela/campo E120PED.VLRIRF
PEDVLRBIN representa a tabela/campo E120PED.VLRBIN
PEDVLRINS representa a tabela/campo E120PED.VLRINS
PEDVLRBCO representa a tabela/campo E120PED.VLRBCO
PEDVLRCOM representa a tabela/campo E120PED.VLRCOM
PEDVLRLPR representa a tabela/campo E120PED.VLRLPR
PEDVLRLSE representa a tabela/campo E120PED.VLRLSE
PEDVLRLOU representa a tabela/campo E120PED.VLRLOU
PEDVLRLIQ representa a tabela/campo E120PED.VLRLIQ
PEDVLRFIN representa a tabela/campo E120PED.VLRFIN
PEDVLRADT representa a tabela/campo E120PED.VLRADT
PEDQTDORI representa a tabela/campo E120PED.QTDORI
PEDVLRORI representa a tabela/campo E120PED.VLRORI
PEDTEMPAR representa a tabela/campo E120PED.TEMPAR
PEDCODPOR representa a tabela/campo E120PED.CODPOR
PEDCODCRT representa a tabela/campo E120PED.CODCRT
PEDSITPED representa a tabela/campo E120PED.SITPED
PEDCODMOT representa a tabela/campo E120PED.CODMOT
PEDOBSMOT representa a tabela/campo E120PED.OBSMOT
PEDPEDBLO representa a tabela/campo E120PED.PEDBLO
PEDUSUBLO representa a tabela/campo E120PED.USUBLO
PEDDATBLO representa a tabela/campo E120PED.DATBLO
PEDHORBLO representa a tabela/campo E120PED.HORBLO
PEDINDSIG representa a tabela/campo E120PED.INDSIG
PEDVERCAL representa a tabela/campo E120PED.VERCAL
PEDHORINI representa a tabela/campo E120PED.HORINI
PEDHORFIM representa a tabela/campo E120PED.HORFIM
PEDUSUGER representa a tabela/campo E120PED.USUGER
PEDDATGER representa a tabela/campo E120PED.DATGER
PEDHORGER representa a tabela/campo E120PED.HORGER
PEDPERFRE representa a tabela/campo E120PED.PERFRE
PEDPERSEG representa a tabela/campo E120PED.PERSEG
PEDPEREMB representa a tabela/campo E120PED.PEREMB
PEDPERENC representa a tabela/campo E120PED.PERENC
PEDPEROUT representa a tabela/campo E120PED.PEROUT
PEDCODSAC representa a tabela/campo E120PED.CODSAC
PEDCODOPE representa a tabela/campo E120PED.CODOPE
PEDCODVEN representa a tabela/campo E120PED.CODVEN
PEDPEDPAL representa a tabela/campo E120PED.PEDPAL
PEDACEPAR representa a tabela/campo E120PED.ACEPAR
PEDPEROF1 representa a tabela/campo E120PED.PEROF1
PEDPEROF2 representa a tabela/campo E120PED.PEROF2
PEDUSUFEC representa a tabela/campo E120PED.USUFEC
PEDDATFEC representa a tabela/campo E120PED.DATFEC
PEDHORFEC representa a tabela/campo E120PED.HORFEC
PEDCLIREL representa a tabela/campo E120PED.CLIREL
PEDVLRBCL representa a tabela/campo E120PED.VLRBCL
PEDVLRCSL representa a tabela/campo E120PED.VLRCSL
PEDVLRBPT representa a tabela/campo E120PED.VLRBPT
PEDVLRPIT representa a tabela/campo E120PED.VLRPIT
PEDVLRBCT representa a tabela/campo E120PED.VLRBCT
PEDVLRCRT representa a tabela/campo E120PED.VLRCRT
PEDVLRBOR representa a tabela/campo E120PED.VLRBOR
PEDVLROUR representa a tabela/campo E120PED.VLROUR
PEDCODMAR representa a tabela/campo E120PED.CODMAR
PEDCODSRO representa a tabela/campo E120PED.CODSRO
PEDFILFAT representa a tabela/campo E120PED.FILFAT
PEDCODCDI representa a tabela/campo E120PED.CODCDI
PEDCODLIP representa a tabela/campo E120PED.CODLIP
PEDCEPFRE representa a tabela/campo E120PED.CEPFRE
PEDVLRRIS representa a tabela/campo E120PED.VLRRIS
PEDANAEMB representa a tabela/campo E120PED.ANAEMB
PEDNUMEMP representa a tabela/campo E120PED.NUMEMP
PEDQTDANE representa a tabela/campo E120PED.QTDANE
PEDDATAGE representa a tabela/campo E120PED.DATAGE
PEDFILNCO representa a tabela/campo E120PED.FILNCO
PEDSNFNCO representa a tabela/campo E120PED.SNFNCO
PEDNUMNCO representa a tabela/campo E120PED.NUMNCO
PEDEXPWMS representa a tabela/campo E120PED.EXPWMS
PEDVLRBPF representa a tabela/campo E120PED.VLRBPF
PEDVLRPIF representa a tabela/campo E120PED.VLRPIF
PEDVLRBCF representa a tabela/campo E120PED.VLRBCF
PEDVLRCFF representa a tabela/campo E120PED.VLRCFF
PEDCODAPC representa a tabela/campo E120PED.CODAPC
PEDSOMFRE representa a tabela/campo E120PED.SOMFRE
PEDQTDITP representa a tabela/campo E120PED.QTDITP
PEDQTDITS representa a tabela/campo E120PED.QTDITS
PEDPERDS5 representa a tabela/campo E120PED.PERDS5
PEDVLRDS5 representa a tabela/campo E120PED.VLRDS5
PEDROTANX representa a tabela/campo E120PED.ROTANX
PEDNUMANX representa a tabela/campo E120PED.NUMANX
PEDNUMNSU representa a tabela/campo E120PED.NUMNSU
PEDDATNSU representa a tabela/campo E120PED.DATNSU
PEDHORNSU representa a tabela/campo E120PED.HORNSU
PEDINDEXP representa a tabela/campo E120PED.INDEXP
PEDFATPED representa a tabela/campo E120PED.FATPED
PEDQTDBPF representa a tabela/campo E120PED.QTDBPF
PEDQTDBCF representa a tabela/campo E120PED.QTDBCF
PEDQTDBIP representa a tabela/campo E120PED.QTDBIP
PEDNUMCES representa a tabela/campo E120PED.NUMCES
PEDVENCAL representa a tabela/campo E120PED.VENCAL
PEDDESDEF representa a tabela/campo E120PED.DESDEF
PEDANOVEI representa a tabela/campo E120PED.ANOVEI
PEDNUMREN representa a tabela/campo E120PED.NUMREN
PEDDESMOD representa a tabela/campo E120PED.DESMOD
PEDTIPDAV representa a tabela/campo E120PED.TIPDAV
PEDVLRECF representa a tabela/campo E120PED.VLRECF
PEDPERECF representa a tabela/campo E120PED.PERECF
PEDTEMAVA representa a tabela/campo E120PED.TEMAVA
PEDCODTAB representa a tabela/campo E120PED.CODTAB
PEDSENAPR representa a tabela/campo E120PED.SENAPR
PEDUSUAPR representa a tabela/campo E120PED.USUAPR
PEDDATAPR representa a tabela/campo E120PED.DATAPR
PEDHORAPR representa a tabela/campo E120PED.HORAPR
PEDSITPAC representa a tabela/campo E120PED.SITPAC
PEDUSUPAC representa a tabela/campo E120PED.USUPAC
PEDQTDPAC representa a tabela/campo E120PED.QTDPAC
PEDCODSAF representa a tabela/campo E120PED.CODSAF
PEDDATPRE representa a tabela/campo E120PED.DATPRE
PEDINDPRE representa a tabela/campo E120PED.INDPRE
PEDCURMIL representa a tabela/campo E120PED.CURMIL
PEDBASIDF representa a tabela/campo E120PED.BASIDF
PEDVLRIDF representa a tabela/campo E120PED.VLRIDF
PEDSITMES representa a tabela/campo E120PED.SITMES
PEDVLRICD representa a tabela/campo E120PED.VLRICD
PEDMOTWMS representa a tabela/campo E120PED.MOTWMS
PEDTIPENT representa a tabela/campo E120PED.TIPENT
PEDFORENT representa a tabela/campo E120PED.FORENT
PEDSEQHAS representa a tabela/campo E120PED.SEQHAS
PEDEQFIMP representa a tabela/campo E120PED.EQFIMP
PEDCOOIMP representa a tabela/campo E120PED.COOIMP
PEDCROECF representa a tabela/campo E120PED.CROECF
PEDVLRTOT representa a tabela/campo E120PED.VLRTOT
PEDNUMINT representa a tabela/campo E120PED.NUMINT
PEDIDEEVT representa a tabela/campo E120PED.IDEEVT
PEDVLRIOR representa a tabela/campo E120PED.VLRIOR
PEDVLRBDE representa a tabela/campo E120PED.VLRBDE
PEDVLRIDE representa a tabela/campo E120PED.VLRIDE
PEDBASFCP representa a tabela/campo E120PED.BASFCP
PEDVLRFCP representa a tabela/campo E120PED.VLRFCP
PEDBSTFCP representa a tabela/campo E120PED.BSTFCP
PEDVSTFCP representa a tabela/campo E120PED.VSTFCP
PEDICMBFC representa a tabela/campo E120PED.ICMBFC
PEDICMVFC representa a tabela/campo E120PED.ICMVFC
PEDCEPINI representa a tabela/campo E120PED.CEPINI
PEDCEPFIM representa a tabela/campo E120PED.CEPFIM
PEDINDITM representa a tabela/campo E120PED.INDITM
PEDCODITM representa a tabela/campo E120PED.CODITM
PEDCGCITM representa a tabela/campo E120PED.CGCITM
PEDCADITM representa a tabela/campo E120PED.CADITM
PEDIDEEXT representa a tabela/campo E120PED.IDEEXT
PEDIDCEXT representa a tabela/campo E120PED.IDCEXT
PEDCTREXT representa a tabela/campo E120PED.CTREXT
PEDCODINT representa a tabela/campo E120PED.CODINT
PEDINDPAC representa a tabela/campo E120PED.INDPAC
PEDVDIFCS representa a tabela/campo E120PED.VDIFCS
PEDEFIFCS representa a tabela/campo E120PED.EFIFCS
PEDVICSDT representa a tabela/campo E120PED.VICSDT
PEDREIFCX representa a tabela/campo E120PED.REIFCX
PEDQTMBIC representa a tabela/campo E120PED.QTMBIC
PEDVMOICM representa a tabela/campo E120PED.VMOICM
PEDQTMBIR representa a tabela/campo E120PED.QTMBIR
PEDVMOICR representa a tabela/campo E120PED.VMOICR
PEDQTMBIF representa a tabela/campo E120PED.QTMBIF
PEDVMOICF representa a tabela/campo E120PED.VMOICF
PEDQTMBID representa a tabela/campo E120PED.QTMBID
PEDVMOICD representa a tabela/campo E120PED.VMOICD
APECLI representa tabela/campo E085CLI.APECLI
NOMCLI representa tabela/campo E085CLI.NOMCLI
BAICLI representa tabela/campo E085CLI.BAICLI
CIDCLI representa tabela/campo E085CLI.CIDCLI
CEPCLI representa tabela/campo E085CLI.CEPCLI
CLICON representa tabela/campo E085CLI.CLICON
SIGUFS representa tabela/campo E085CLI.SIGUFS
ZONFRA representa tabela/campo E085CLI.ZONFRA
CODRAM representa tabela/campo E085CLI.CODRAM
TIPMER representa tabela/campo E085CLI.TIPMER
CPLEND representa tabela/campo E085CLI.CPLEND
ENDCLI representa tabela/campo E085CLI.ENDCLI
BAIENT representa tabela/campo E085CLI.BAIENT
CEPENT representa tabela/campo E085CLI.CEPENT
ESTENT representa tabela/campo E085CLI.ESTENT
NENCLI representa tabela/campo E085CLI.NENCLI
NENENT representa tabela/campo E085CLI.NENENT
CPLENT representa tabela/campo E085CLI.CPLENT
ENDENT representa tabela/campo E085CLI.ENDENT
CIDENT representa tabela/campo E085CLI.CIDENT
Abaixo segue um exemplo de regra que pode ser utilizada junto com o Identificador de Regras VEN-135PROAU01 para limitar a quantidade de pedidos que serão carregados ao formar a pré-fatura:
WHERE PEDNUMPED IN (
SELECT NUMPED FROM (SELECT ROW_NUMBER() OVER(ORDER BY A.NUMPED) AS LINHA, A.NUMPED FROM E120PED A
INNER JOIN E120IPD B ON (A.CODEMP = B.CODEMP AND A.CODFIL = B.CODFIL AND A.NUMPED = B.NUMPED) WHERE
A.CODEMP = 1
AND (A.FILFAT = 0 OR A.FILFAT = 2)
AND B.PEDPRV <> 'S'
AND A.PEDBLO <> 'S'
AND B.QTDABE > 0
AND A.SITPED IN(1, 2)
AND B.SITIPD IN (1,2)
AND A.PEDBLO <> 'S'
AND A.DATEMI >= '01/08/2023'
GROUP BY A.NUMPED) ABC WHERE ABC.LINHA < 200)
Observações
- Neste exemplo, o número de pedido que o sistema carrega (PEDNUMPED) está sendo comparado com uma abrangência de pedidos trazida pelo comando de seleção interno. Este Select interno deve receber obrigatoriamente os filtros abaixo, para que os pedidos carregados atendam as mesmas condições do Select original do sistema:
A.CODEMP = 1
AND (A.FILFAT = 0 OR A.FILFAT = 2)
AND B.PEDPRV <> 'S'
AND A.PEDBLO <> 'S'
AND B.QTDABE > 0
AND A.SITPED IN(1, 2)
AND B.SITIPD IN (1,2)
AND A.PEDBLO <> 'S'
- O que pode/deve ser alterado neste filtro é o valor da empresa que deve representar a empresa logada, e o valor da filial de faturamento, que deve representar a filial que será faturada.
- Informações como data de emissão, quantidade de registros (ABC.LINHA < 200), também podem ser alteradas.
- Também é possível adicionar filtros para complementar este exemplo citado acima, filtrando tanto pela Tabela de Pedido (Tabela A) como pela Tabela de Item (Tabela B).