cQuery:=" SELECT ZT9_FILIAL,ZT9_NOME,ZT9_CGC,ZT9_RG,ZT9_NREDUZ, ZT9_END, ZT9_COMPLE, ZT9_BAIRRO, " cQuery+=" ZT9_MUN, ZT9_EST, ZT9_ENDCOB, ZT9_ENDREC, ZT9_BAICOB, ZT9_MUNC, ZT9_ESTC, ZT9_CONTAT, ZT9_REFBAN, " cQuery+=" ZT9_RCOM1, ZT9_RCOM2, ZT9_RCOM3, ZT9_FONEBA, " cQuery+=" CASE " cQuery+=" WHEN ZT9_SUSCRE > 0 THEN ZT9_SUSCRE " cQuery+=" ELSE CASE " cQuery+=" WHEN LEN(ZT9_CGC) > 11 THEN 2000 " cQuery+=" ELSE 1000 " cQuery+=" END " cQuery+=" END ZT9_SUSCRE, " cQuery+=" ZT9_RAMO, ZT9_COND, ZT9_TIPDOC, ZT9_VEND, ZT9_DTIMP, ZT9_HRIMP, ZT9_USIMP, D_E_L_E_T_, R_E_C_N_O_, ZT9_DTAPRO, ZT9_STATUS, ZT9_USAPRO, ZT9_HORAPR, " cQuery+=" ZT9_OBS, ZT9_IE, ZT9_TEL,ZT9_EMAIL, ZT9_CEP " cQuery+=" FROM "+RetSqlName("ZT9")+" ZT9 " cQuery+=" WHERE ZT9_EST BETWEEN '"+MV_PAR01+"' AND '"+MV_PAR02+"' AND D_E_L_E_T_= ''" cQuery+=" AND REPLACE(REPLACE(REPLACE(ZT9_CGC,'.',''),'-',''),'/','') NOT IN (SELECT A1_CGC FROM "+RetSqlName("SA1")+")" If AllTrim(CUSERNAME) $ GETMV("MV_ANACLI") cQuery+=" AND ZT9_STATUS='' " Else cQuery+=" AND ZT9_STATUS='O' " EndIf If Select("Qry") != 0 Qry->(dbCloseArea ()) Endif TCQUERY cQuery NEW ALIAS "Qry" //"QryC5" Aadd(aTit, ' ') Aadd(aTam, 10 ) dbSelectArea("SX3") dbSetOrder(1) dbSeek("ZT9") While !Eof() .And. SX3->X3_ARQUIVO == "ZT9" If (X3Uso(SX3->X3_USADO) .And. (cNivel >= SX3->X3_NIVEL) ) if '|'+Rtrim(SX3->X3_CAMPO)+'|' $ _cCampos Aadd(aHead, { AllTrim(X3Titulo()),; SX3->X3_CAMPO,; SX3->X3_PICTURE,; SX3->X3_TAMANHO,; SX3->X3_DECIMAL,; SX3->X3_VALID,; SX3->X3_USADO,; SX3->X3_TIPO,; SX3->X3_ARQUIVO,; SX3->X3_CONTEXT } ) Aadd(aTit, AllTrim(X3Titulo())) Aadd(aTam, 40 ) Endif EndIf dbSelectArea("SX3") dbSkip() EndDo // Montagem das linhas a serem exibidas. dbSelectArea("Qry") dbGoTop()