Product: | TOTVS Backoffice |
Product Line: | Protheus Line |
Industry: | Services |
Module: | TOTVS Backoffice (Protheus Line) - Fixed Assets (SIGAATF) |
Function: | ATFI012 |
Country: | Brazil |
Ticket: | Internal |
Requisite/Story/Issue | DSERCTR1-46829 |
Entry Point AF012POS runs at the end of routine ATFI012, allowing the return of processing to be handled in accordance with specific needs. This entry point is activated after the receipt of single message of fixed asset registration, allowing the customization of actions or final validations before closing the routine.
aRet := ExecBlock("AF012POS", .F., .F., {lRet, cXmlRet, cTypeTrans, cTypeMsg, cVersion, cTransac, lEAIObj})
If ValType(aRet) = "A" .and. len(aRet) > 1
lRet := aRet[1]
cXmlRet := aRet[2]
Endif |
User Function AF012POS()
Local aRet := {}
Local lRet := ParamIXB[1]
Local cXml := ParamIXB[2]
Local cTypeTrans := ParamIXB[3]
Local lObjJSON := ParamIXB[7]
Local cErro := ""
Local oXml as object
// Handle XML only if the routine returned true.
If lRet .and. !lObjJSON
If cTypeTrans == TRANS_SEND
// Handle XML.
oXml := tXmlManager():New()
oXml:Parse("<AF012POS>" + cXml + "</AF012POS>")
If Empty(cErro := oXml:Error())
oXml:XPathAddNode("/AF012POS/BusinessContent", "N1_NUFINAM", IntCliExt(,, SN1->N1_NUFINAM, MsgUVer('ATFA012', 'ASSETS'))[2])
Endif
// A processing error occurred.
If empty(cErro)
lRet := .T.
cXml := LimpaXML(oXml:Save2String())
Else
lRet := .F.
cXml := "<![CDATA[" + _NoTags(cErro) + "]]>"
Endif
oXml := nil
ElseIf cTypeTrans == TRANS_RECEIVE
Endif
Endif
aRet := {lRet, cXml}
Return aRet
/*/{Protheus.doc} LimpaXML
Auxiliary function to remove the prolog from the XML created.
@param cXml XML Text to be cleared.
@author
@version P12
@since 2/21/2019
@return cXml - (character) XML Text without prolog.
/*/
Static Function LimpaXML(cXml)
Local cXmlRet := AllTrim(cXml)
Local nChar
// Remove prolog from message.
If cXmlRet = "<?"
cXmlRet := SubStr(cXmlRet, At("?>", cXmlRet) + 2)
Endif
// Remove the line indent (CR and LF) and spaces from the beginning of the string.
Do While (nChar := asc(left(cXmlRet, 1)), nChar = 10 .or. nChar = 13 .or. nChar = 32)
cXmlRet := SubStr(cXmlRet, 2)
EndDo
// Remove the line indent (CR and LF) and spaces from the end of the string.
Do While (nChar := asc(right(cXmlRet, 1)), nChar = 10 .or. nChar = 13 .or. nChar = 32)
cXmlRet := SubStr(cXmlRet, 1, len(cXmlRet) - 1)
EndDo
// Remove the <AF012POS> and </AF012POS>.
If cXmlRet = "<AF012POS>" .and. right(cXmlRet, 11) == "</AF012POS>"
cXmlRet := SubStr(cXmlRet, 11, len(cXmlRet) - 21)
Endif
Return cXmlRet
/*/{Protheus.doc} MsgUVer
Function that checks the version of a single message registered in the EAI adapter.
You must DELETE this function and replace it for the function FwAdapterVersion()
after its publication in Lib of 2019.
@param cRotina Routine that has the Single Message IntegDef
@param cMensagem Name of Single Message to be searched
@author Felipe Raposo
@since 11/23/2018
@return xVersion - version of registered single message. If not found, it returns null.
/*/
Static Function MsgUVer(cRotina, cMensagem)
Local aArea := GetArea()
Local aAreaXX4 := XX4->(GetArea())
Local xVersion
If FindFunction("FwAdapterVersion")
xVersion := FwAdapterVersion(cRotina, cMensagem)
ElseIf XX4->(FieldPos('XX4_SNDVER')) > 0
cMensagem := Padr(cMensagem, Len(XX4->XX4_MODEL))
cRotina := Padr(cRotina, Len(XX4->XX4_ROTINA))
XX4->(dbSetOrder(1))
If XX4->(msSeek(xFilial() + cRotina + cMensagem, .F.) .and. !empty(XX4_SNDVER))
xVersion := AllTrim(XX4->XX4_SNDVER)
Endif
Endif
RestArea(aAreaXX4)
RestArea(aArea)
Return xVersion |
|