MaPedNew

Cria pedido de venda programaticamente (alternativa ao MsExecAuto MATA410). Mais leve em integracoes simples.

Assinatura: MaPedNew(aCab, aItens, [lLib]) -> lOk

Retorna: Logical

MaPedNew e a forma "programatica" de criar pedido sem passar pela tela MATA410. Usada em integracoes com marketplace, ERPs externos.

aCab := { ;
    {"C5_NUM",      U_NumPed(),      NIL}, ;
    {"C5_CLIENTE",  "000001",        NIL}, ;
    {"C5_LOJACLI",  "01",            NIL}, ;
    {"C5_CONDPAG",  "001",           NIL}, ;
    {"C5_TIPO",     "N",             NIL}  ;
}
aItens := { ;
    { ;
        {"C6_PRODUTO", "100001", NIL}, ;
        {"C6_QTDVEN",  10,       NIL}, ;
        {"C6_PRCVEN",  99.90,    NIL}, ;
        {"C6_TES",     "501",    NIL}  ;
    } ;
}

If MaPedNew(aCab, aItens, .T.)  // .T. = libera junto
    ConOut("Pedido criado")
Else
    ConOut("Erro: " + cValToChar(GetMsgErro()))
EndIf

Pegadinhas

Veja também