Histórico da Página
GFEXWS13
GFEXWS14 - Manipulação das Informações a Serem Gravadas no GFE
Características do Requisito
Linha de Produto: | Protheus |
Segmento: | Distribuição e Logística |
Módulo: | SIGAGFE |
Ponto de Entrada - GFEXWS13
Descrição: | Permitir a manipulação das informações a serem gravadas no GFE. | ||||||||||||
Localização: | Antes de realizar a chamada das funções que realizarão a gravação das tabelas no GFE. | ||||||||||||
Programa Fonte: | GFEXWSFUN - Serviço de Integração do Frete Embarcador (SIGAGFE) | ||||||||||||
Parâmetros: |
| ||||||||||||
Retorno: |
|
Bloco de código | ||||||
---|---|---|---|---|---|---|
| ||||||
User Function GFEXWS13GFEXWS14() aDados := PARAMIXB[1] oModel := PARAMIXB[2] cTransp := '' cClFrete := '' lElimin := .T. If Alltrim(aDados[2]) == 'AGRUROM' cAliGWN := GetNextAlias() cQuery := " SELECT GWN.* FROM "+RetSQLName("GWN")+" GWN WHERE" cQuery += " GWN.GWN_XDEL = '1' AND " cQuery += " GWN.D_E_L_E_T_ <> '*' " Query := ChangeQuery(cQuery) dbUseArea( .T., "TOPCONN", TCGENQRY(,,cQuery),cAliGWN, .F., .T.) dbSelectArea((cAliGWN)) (cAliGWN)->( dbGoTop() ) While !(cAliGWN)->( Eof() ) if (cAliGWN)->GWN_XVAL <> '1' lElimin := .F. EndIf (cAliGWN)->( dbSkip() ) EndDo cAliasGWN := GetNextAlias() dbUseArea( .T., "TOPCONN", TCGENQRY(,,cQuery),cAliasGWN, .F., .T.) dbSelectArea((cAliasGWN)) (cAliasGWN)->( dbGoTop() ) While !((cAliasGWN)->( Eof() ) ) dbSelectArea("GWN") If dbSeek( (cAliasGWN)->GWN_FILIAL + (cAliasGWN)->GWN_NRROM) If lElimin == .F. RecLock("GWN",.F.) GWN->GWN_XDEL := '' GWN->GWN_XVAL := '' MsUnlock() Else dbSelectArea("GW1") dbSetOrder(09) dbSeek(xFilial("GW1")+GWN->GWN_NRROM,.T.) While !Eof() .And. GW1->GW1_NRROM == GWN->GWN_NRROM RecLock("GW1",.F.) GW1->GW1_CARREG := "AGRUPAR" GW1->GW1_XCDTRP := GWN->GWN_CDTRP GW1->GW1_ROMCF := GWN->GWN_CDCLFR MsUnlock() dbSelectArea("GW1") dbSkip() EndDo oModel:Activate() lRet:= oModel:VldData() If (lRet) oModel:CommitData() EndIf // lRet EndIf // Elimina EndIf (cAliasGWN)->( dbSkip() ) EndDo cAliasGW1 := GetNextAlias() cQuery := " SELECT GW1.* FROM "+RetSQLName("GW1")+" GW1 WHERE" cQuery += " GW1.GW1_CARREG = 'AGRUPAR' AND " cQuery += " GW1.D_E_L_E_T_ <> '*' " cQuery += " ORDER BY GW1.GW1_XCDTRP, GW1.GW1_ROMCF" cQuery := ChangeQuery(cQuery) dbUseArea( .T., "TOPCONN", TCGENQRY(,,cQuery),cAliasGW1, .F., .T.) dbSelectArea((cAliasGW1)) (cAliasGW1)->( dbGoTop() ) While !((cAliasGW1)->( Eof() ) ) //Se registro do transportador for diferente do atual if cTransp == '' .Or. cClFrete == '' .Or. cTransp <> (cAliasGW1)->GW1_XCDTRP .Or. cClFrete <> (cAliasGW1)->GW1_ROMCF //Calcula o romaneio anterior GFECalCAut() RecLock("GWN",.T.) GWN->GWN_FILIAL := (cAliasGW1)->GW1_FILIAL GWN->GWN_NRROM := GETSXENUM("GWN","GWN_NRROM") GWN->GWN_CDTRP := (cAliasGW1)->GW1_XCDTRP GWN->GWN_CDTPOP := BuscaParam("MV_TPOPEMB","",Alltrim(xFilial("GWN") )) GWN->GWN_CDCLFR := (cAliasGW1)->GW1_ROMCF GWN->GWN_DTIMPL := DDATABASE GWN->GWN_HRIMPL := TIME() GWN->GWN_OBS := 'Criação de romaneios via coletor de dados' GWN->GWN_SIT := '3' GWN->GWN_CALC := '2' GWN->GWN_AGRUP := '2' GWN->GWN_BLOQPF := '2' GWN->GWN_ORI := '1' GWN->GWN_USUIMP := USRRETNAME(RETCODUSR()) GWN->GWN_DTSAI := DDATABASE GWN->GWN_HRSAI := time() MsUnlock() ConfirmSx8() EndIf cTransp := (cAliasGW1)->GW1_XCDTRP cClFrete := (cAliasGW1)->GW1_ROMCF dbSelectArea("GW1") GW1->( dbSetOrder(1) ) If GW1->( dbSeek((cAliasGW1)->GW1_FILIAL + (cAliasGW1)->GW1_CDTPDC + (cAliasGW1)->GW1_EMISDC + (cAliasGW1)->GW1_SERDC + (cAliasGW1)->GW1_NRDC) ) RecLock("GW1",.F.) GW1->GW1_NRROM := GWN->GWN_NRROM GW1->GW1_CARREG := GWN->GWN_NRROM GW1->GW1_CALCAT := '1' GW1->GW1_SIT := '4' GW1->GW1_DTLIB := dDataBase GW1->GW1_HRLIB := SubStr(Time(), 1, 5) GW1->GW1_DTSAI := dDataBase GW1->GW1_HRSAI := SubStr(Time(), 1, 5) MsUnlock() EndIF (cAliasGW1)->( dbSkip() ) EndDo GFECalCAut() Else dbSelectArea("GWN") If dbSeek( PADR(Alltrim(aDados[1]) , TamSX3("GWN_FILIAL" )[1],'') + ; PADL(Alltrim(aDados[2]) , TamSX3("GWN_NRROM" )[1],'0')) RecLock("GWN",.F.) GWN->GWN_XDEL := '1' MsUnlock() If GWN->GWN_SIT == '3' //Necessario reabrir GFEA050REA(.T.) EndIF If GWN->GWN_SIT <> '3' RecLock("GWN",.F.) GWN->GWN_XVAL := '1' MsUnlock() Else aErro := oModel:GetErrorMessage() conout("Erro na exclusão do registro. Motivo: " + aErro[6]) EndIf EndIF EndIF Return 'ok' |
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas