Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Friends, I need to create a QVD or a LOAD NFE_CTE create the table, based on information from 3 tables: NFE_EMIT, NFE_DEST and CTE:
-------------------------------------------------------------- Português ------------------------------------------------------------------
Amigos, estou precisando criar um QVD ou num LOAD criar a tabela NFE_CTE, baseado nas informações de 3 tabelas: NFE_EMIT, NFE_DEST e CTE, sendo:
------------------------------------------------------------------------------------------------------------------------------------------------
NFE_EMIT: (nfe_emit.qvd)
COD_INFNFE | CNPJ_CPF_EMIT |
---|---|
201300123 | 99999999000254 |
201300124 | 88888888000199 |
201300125 | 77777777000126 |
201300126 | 66666666000210 |
NFE_DEST: (nfe_dest.qvd)
COD_INFNFE | CNPJ_CPF_DEST |
---|---|
201300123 | 55555555000987 |
201300124 | 44444444000135 |
201300125 | 33333333000123 |
201300126 | 22222222000158 |
CTE: (cte.qvd)
COD_DOC_FISCAL | CNPJ_REM | CNPJ_CPF |
---|---|---|
321654 | 99999999000254 | 55555555000987 |
321655 | 88888888000199 | 44444444000135 |
321656 | 77777777000126 | 33333333000123 |
321657 | 66666666000210 | 22222222000158 |
The table below does not exist, create it would be ideal in qvw from QVDs above.
-------------------------------------------------------------- Português ------------------------------------------------------------------
A tabela abaixo não existe, o ideal seria cria-la no QVW a partir dos QVDs acima mencionados.
------------------------------------------------------------------------------------------------------------------------------------------------
NFE_CTE:
COD_INFNFE | COD_DOC_FISCAL |
---|---|
201300123 | 321654 |
201300124 | 321655 |
201300125 | 321656 |
201300126 | 321657 |
How should I do?
I appreciate the help and sorry for the English.
-------------------------------------------------------------- Português ------------------------------------------------------------------
Qual seria o procedimento?
Agradeço antecipadamente qualquer ajuda e desculpe pelo inglês.
------------------------------------------------------------------------------------------------------------------------------------------------
Sávio Bueno.
Looks like NFE_EMIT.CNPJ_CPF_EMIT=CTE.CNPJ_REM, and NFE_DEST.CNPJ_CPF_DEST=CTE.CNPJ_CPF. If this is correct:
Result:
LOAD DISTINCT
COD_INFNFE,
CNPJ_CPF_EMIT as CNPJ_REM
FROM nfe_emit.qvd (qvd);
JOIN (Result) LOAD DISTINCT
COD_INFNFE,
CNPJ_CPF_DEST as CNPJ_CPF
FROM nfe_dest.qvd (qvd);
JOIN (Result) LOAD DISTINCT
CNPJ_REM,
CNPJ_CPF,
COD_DOC_FISCAL
FROM cte.qvd (qvd);
You get table with four fields - COD_INFNFE, COD_DOC_FISCAL, CNPJ_REM, and CNPJ_CPF.
The last two are for joining. Probably one is enough, you know better. If you don't need these two fields, you can remove them at the end:
DROP FIELDS CNPJ_REM, CNPJ_CPF;
Regards,
Michael
Looks like NFE_EMIT.CNPJ_CPF_EMIT=CTE.CNPJ_REM, and NFE_DEST.CNPJ_CPF_DEST=CTE.CNPJ_CPF. If this is correct:
Result:
LOAD DISTINCT
COD_INFNFE,
CNPJ_CPF_EMIT as CNPJ_REM
FROM nfe_emit.qvd (qvd);
JOIN (Result) LOAD DISTINCT
COD_INFNFE,
CNPJ_CPF_DEST as CNPJ_CPF
FROM nfe_dest.qvd (qvd);
JOIN (Result) LOAD DISTINCT
CNPJ_REM,
CNPJ_CPF,
COD_DOC_FISCAL
FROM cte.qvd (qvd);
You get table with four fields - COD_INFNFE, COD_DOC_FISCAL, CNPJ_REM, and CNPJ_CPF.
The last two are for joining. Probably one is enough, you know better. If you don't need these two fields, you can remove them at the end:
DROP FIELDS CNPJ_REM, CNPJ_CPF;
Regards,
Michael
Thank you Michael. It worked well.