Hi everybody!
I have a for each inside a block in the structure, but everytime in the second register, I have an erro saying thats a duplicated data... (for each item-doc-est of docum-est no-lock:)
How can I correct this?
for each docum-est
where docum-est.cod-estab = tt-recebimento.cod-estabel
and docum-est.serie-docto = tt-recebimento.serie-docto
and docum-est.nro-docto = tt-recebimento.nro-docto
and docum-est.nat-operacao = tt-recebimento.nat-operacao
and docum-est.cod-emitente = tt-recebimento.cod-emitente no-lock :
find first emitente where emitente.cod-emitente = docum-est.cod-emitente no-lock no-error.
assign idCode = docum-est.cod-estab + "-" + docum-est.serie-docto + "-" + docum-est.nro-docto + "-" + string(docum-est.cod-emitente) + "-" + docum-est.nat-operacao.
httpUrl = "10.0.1.204:8091/.../set.json". /* "10.0.1.67:8091/.../set.json" */
oJson = new JsonObject().
oJson:Add('appId', 'totvs.1').
oJson:Add('token', '').
oJson:Add('activityId', 1).
oJson:Add('idCode', IdCode).
oJson:Add('invoice', docum-est.nro-docto).
oJson:Add('arrivalDate', docum-est.dt-emissao).
oJson:Add('supplierId', emitente.cod-emitente).
oJson:Add('supplierName', emitente.nome-emit).
oJson:Add('supplierCnpj', emitente.cgc).
itemsJson = new JSonObject().
oJson:Add('items', itemsJson).
materialJson = new JSonObject().
ItemsJson:Add('material', materialJson).
for each item-doc-est of docum-est no-lock:
find first item where item.it-codigo = item-doc-est.it-codigo no-lock no-error.
find first item-reserva where item-reserva.it-codigo = item.it-codigo no-lock no-error.
materialJson:Add('id', item-doc-est.it-codigo).
materialJson:Add('name', item.desc-item).
materialJson:Add('desc1', item.narrativa).
materialJson:Add('grade', 0).
ItemsJson:Add('itemIdx', Item-doc-est.sequencia).
ItemsJson:Add('itemSupBatch', Item-doc-est.lote).
ItemsJson:Add('itemErpBatch', Item-doc-est.lote).
ItemsJson:Add('itemExpiration', item-doc-est.dat-valid-lote-fabrican).
ItemsJson:Add('itemProduction', '').
ItemsJson:Add('itemUnit', Item-doc-est.un).
ItemsJson:Add('convFactor', '').
ItemsJson:Add('itemSetpoint', Item-doc-est.quantidade).
ItemsJson:Add('itemMin', Item-reserva.dec-2).
ItemsJson:Add('itemMax',Item-reserva.dec-1).
end.
oRequest = RequestBuilder:Post(httpUrl, oJson)
:AcceptJson()
:Request.
oResponse = ClientBuilder:Build():Client:Execute(oRequest).
if type-of(oResponse:Entity, JsonObject) then do:
message 1 skip
string(oResponse:Entity) view-as alert-box.
oJsonRespObj = cast(oResponse:Entity, JsonObject).
message 'TESTE ' oJsonRespObj:GetCharacter("msg")
view-as alert-box.
/*
message string(oJsonRespObj:GetInt64("Id"))
string(oJsonRespObj:GetInt64("companyId"))
oJsonRespObj:GetCharacter("date")
oJsonRespObj:GetCharacter("batchIdcode") view-as alert-box.
*/
end.
end.