Passo a passo: | //DOCUMENTO TIPO NORMAL #Include "Protheus.ch" #Include "RwMake.ch" #Include "TbiConn.ch" #Include "Coverage.ch" User Function EX103DHR()
Local aCab := {} Local aItem := {} Local aItens := {} Local aItensDHR := {} Local nOpc := 3 Local cNum := "" Local nI := 0 Local nX := 0 Local nReg := 1 Local cInicio := Time()
Private lMsErroAuto := .F. Private lMsHelpAuto := .T. Private lTemF1GFE := .F.
PREPARE ENVIRONMENT EMPRESA "T1" FILIAL "D MG 01" MODULO "COM" FUNNAME "MATA103"
For nI := 1 To nReg lMsErroAuto := .F. aCab := {} aItem := {} aItens := {} If nOpc == 3 cNum := GetSxeNum("SF1","F1_DOC") SF1->(dbSetOrder(1)) While SF1->(dbSeek(xFilial("SF1")+cNum)) ConfirmSX8() cNum := GetSxeNum("SF1","F1_DOC") EndDo Elseif nOpc == 5 cNum := "COMSP137 " Endif
aadd(aCab,{"F1_FORMUL" ,"N" ,NIL}) aadd(aCab,{"F1_DOC" ,cNum ,NIL}) aadd(aCab,{"F1_SERIE" ,"1 " ,NIL}) aadd(aCab,{"F1_FORNECE" ,"FAB007" ,NIL}) aadd(aCab,{"F1_LOJA" ,"01" ,NIL}) aadd(aCab,{"F1_EMISSAO" ,DDATABASE ,NIL}) aadd(aCab,{"F1_DTDIGIT" ,DDATABASE ,NIL}) aadd(aCab,{"F1_TIPO" ,"N" ,NIL}) aadd(aCab,{"F1_ESPECIE" ,"NFE" ,NIL}) aadd(aCab,{"F1_COND" ,"000" ,NIL}) aadd(aCab,{"F1_STATUS" , "A" , Nil}) For nX := 1 To 2 cProd1 := "ISPUB001" aItem := {} aadd(aItem,{"D1_ITEM" ,StrZero(nX,TamSx3("D1_ITEM")[1]) ,NIL}) aadd(aItem,{"D1_COD" ,PadR(cProd1,TamSx3("D1_COD")[1]) ,NIL}) aadd(aItem,{"D1_UM" ,"UN" ,NIL}) aadd(aItem,{"D1_LOCAL" ,"01" ,NIL}) aadd(aItem,{"D1_QUANT" ,1 ,NIL}) aadd(aItem,{"D1_VUNIT" ,Iif(nX==1,10000,20000) ,NIL}) aadd(aItem,{"D1_TOTAL" ,Iif(nX==1,10000,20000) ,NIL}) aadd(aItem,{"D1_TES" ,"115" ,NIL}) aAdd(aItens,aItem) Next nX If nOpc == 3 For nX := 1 to 2 aItem := {} aAdd(aItensDHR, Array(2)) aItensDHR[Len(aItensDHR)][1] := StrZero(nX,TamSx3("DHR_ITEM")[1]) aItensDHR[Len(aItensDHR)][2] := {} aAdd(aItem, {"DHR_FILIAL" , xFilial("DHR") , Nil}) aAdd(aItem, {"DHR_ITEM" , StrZero(nX,TamSx3("DHR_ITEM")[1]) , Nil}) aAdd(aItem, {"DHR_DOC" , cNum , Nil}) aAdd(aItem, {"DHR_SERIE" , "1 " , Nil}) aAdd(aItem, {"DHR_FORNECE" , "FAB007" , Nil}) aAdd(aItem, {"DHR_LOJA" , "01" , Nil}) aAdd(aItem, {"DHR_NATREN" , Iif(nX==1,"10001","10002") , Nil}) aAdd(aItem, {"DHR_PSIR" , "1594984685" , Nil}) aAdd(aItem, {"DHR_TSIR" , "1" , Nil}) aAdd(aItem, {"DHR_ISIR" , "16543545435135" , Nil}) aAdd(aItem, {"DHR_BASUIR" , 5000 , Nil}) aAdd(aItem, {"DHR_PSPIS" , "1594984685" , Nil}) aAdd(aItem, {"DHR_TSPIS" , "1" , Nil}) aAdd(aItem, {"DHR_ISPIS" , "16543545435145" , Nil}) aAdd(aItem, {"DHR_BSUPIS" , 1000 , Nil}) aAdd(aItem, {"DHR_PSCOF" , "1594984685" , Nil}) aAdd(aItem, {"DHR_TSCOF" , "1" , Nil}) aAdd(aItem, {"DHR_ISCOF" , "16543545435150" , Nil}) aAdd(aItem, {"DHR_BSUCOF" , 2000 , Nil}) aAdd(aItem, {"DHR_PSCSL" , "1594984685" , Nil}) aAdd(aItem, {"DHR_TSCSL" , "1" , Nil}) aAdd(aItem, {"DHR_ISCSL" , "16543545435155" , Nil}) aAdd(aItem, {"DHR_BSUCSL" , 3000 , Nil}) aAdd(aItensDHR[Len(aItensDHR)][2], aClone(aItem)) Next nX Endif
MSExecAuto({|x,y,z,a| MATA103(x,y,z,,,,,,,,,,a)},aCab,aItens,nOpc,aItensDHR) If !lMsErroAuto ConOut(" Incluido NF: " + cNum) Else MostraErro()
ConOut("Erro na inclusao!") Exit EndIf Next nI
Conout("Inicio: " + cInicio) ConOut("Fim: " + Time())
RESET ENVIRONMENT
Return
|