CP_CSTFX;Lancamentos de Custo Fixo;sys_tbbrow; 7; 0;20;79;padrao;;
:SKEL
VARIAVEL w_colsep = chr(179)
VARIAVEL w_headsep = chr(196)
VARIAVEL zBlDiv={||nDiv:=if(CP_DIVISAO>0,CP_DIVISAO,val(left(Cp_SubDiv,3))), if(nDiv=0,put_var("cp_divisao",nDiv),""), cp_divis->(DbSeek(nDiv)),cp_divis->Desc}
VARIAVEL zBlSubDiv={||nDiv:=if(CP_DIVISAO>0,CP_DIVISAO,val(left(Cp_SubDiv,3))), cp_divisao=0.and.(reglock(),_field->cp_divisao:=nDiv,.t.), val(left(cp_subdiv,3))<>cp_divisao.and.(RegLock(),_field->cp_subdiv:=StrZero(nDiv,3)+SubStr(cp_subdiv,4),.t.), cp_subd->(DbSeek(cp_cstfx->cp_subdiv)),cp_subd->Desc}
VARIAVEL zBlkF = {|xFor| sccpfor->(dbgoto(xfor)), sccpfor->cp_fantasi }

VARIAVEL zRecn := CP_CSTFX->(Recno())
VARIAVEL zArea0 := CP_CSTFX->(lTrim(Str(Select(),4)))
VARIAVEL zbOpenAll := {|| Abra("0NOIDX",R_SIGA,"sccpfor","sccpfor","sccpfor","cp_nome"), Abra("0NOIDX",R_SIGA,"CP_DIVIS","CP_DIVIS","CP_DIVIS","CP_DIVISAO"), Abra("0NOIDX",r_siga,"cp_subd", "cp_subd", "cp_subd", "cp_subdiv"), Abra_Arq("cp_cstfx",,zArea0,r_siga) }
VARIAVEL znil := eVal( zbOpenAll )
VARIAVEL zbAction := {|bFunction| zrecn:=Recno(), eVal(bFunction), eVal(zbOpenAll), DbGoTo(zRecn), DobRefresh()}

VARIAVEL zbRelat := {||Relat('lst_exec("CP_CSTFX")',"nb","NaoFecheNaSaida","X")}

VARIAVEL zbClose:={|cAlias| Select(cAlias)>0 .and. ( (cAlias)->(DbCloseArea()), .t.) }
COMANDO SAIDA znil = ( eVal(zbClose,'Cp_Divis'), eVal(zbClose,'Cp_SubD'), eVal(zbClose,'SccpFor') )
:TBMT
 22;tb_insert(D_OB);Ins-Inclui ;
 65;tb_update(D_OB);A-Altera ;
  7;tb_del(D_ob);DEL-DELeta ;
 13;doget(D_ob);Enter-Edita ;
 32;tb_cons();Barra-Exibe ;
 73;eVal(zbAction, zbRelat);I-Imprime ;
 80;tb_pesq(D_OB);P-Pesquisa ;
 84;tb_locate(D_oB);T-Busca_Trecho ;
 76;tb_locate(D_oB);L-Busca_Iniciais ;
 67;tb_locate(D_oB);C-Repete_Busca ;
 79;tb_index(D_OB);O-Ordena ;
 70;tb_filter(d_ob);F-Filtra ;
 69;tb_filter(d_ob,"Exp");E-Filtra_Expressao ;
 61;doget(D_ob,,.t.);=-Repete_Edicao ;
:TBFI
Historico;CP_DESC;C;@S30; 25;;
Valor;CP_VALOR;N;99999.99;  8;;
Forn;CP_COD_FOR;N;9999;  4;;
Forn;eval(zBlkF,CP_COD_FOR);P;@s12; 12;N;
Dv;CP_DIVISAO;N;99; 2;;
Divisao;Eval(zBlDiv);C;@s35; 14;N;
SubDv;CP_SUBDIV;C;99999;5;;
SubDiv;Eval(zBlSubDiv);C;@s35; 14;N;
DEmis;CP_DIAEMIS;N;99;  5;;
DVenc;CP_DIAVENC;N;99;  5;;
PzVen;CP_PZ_VENC;N;99;  5;;