cherokee
4th May 2006, 15:54
Hello everyone,

I want to delete some Items by Code System but, this code below here isn't working. First, it does not find the record I request. Second, it does not return any error when performs the find and/or delete commands. I check the values that it finds and are different to the ones I requested. Besides that, I let it continue to see if it deletes the ones it has found but doesn't delete it either nor returns error message and seems that the everything went fine but isn't it.


....
stpapi.put.field("tiitm0112m000",tiitm012.citt,t.citt)
stpapi.put.field("tiitm0112m000",tiitm012.cuno,dummy.cuno)
stpapi.put.field("tiitm0112m000",tiitm012.suno,t.suno)
stpapi.put.field("tiitm0112m000",tiitm012.item,t.item)
stpapi.put.field("tiitm0112m000",tiitm012.cntr,dummy.cntr)
|stpapi.change.view("tiitm0112m000",error.msg) |I tried this way as well
if stpapi.find("tiitm0112m000",error.msg) = 1 then
on.change.check(t.citt)
on.change.check(t.suno)
on.change.check(t.item)
stpapi.get.field("tiitm0112m000","tiitm012.citt",t.citt)
stpapi.get.field("tiitm0112m000","tiitm012.suno",t.suno)
stpapi.get.field("tiitm0112m000","tiitm012.item",t.item)
stpapi.get.field("tiitm0112m000","tiitm012.aitc",t.aitc)
if changed(t.citt) or changed(t.suno) or changed(t.item) then
|this checks if it found a different record to the one I requested.
stpapi.end.session("tiitm0112m000")
return(false)
endif
|if stpapi.mark("tiitm0112m000", error.msg) then | I tried to mark it before I deleted. Doesn't work either.
stpapi.delete("tiitm0112m000", true, error.msg)
|endif
if not isspace(error.msg) then
stpapi.recover("tiitm0112m000", error.msg)
stpapi.end.session("tiitm0112m000")
return(false)
endif
stpapi.end.session("tiitm0112m000")
return(true)
}


Does anyone see a problem(s) in this code?

Thanks in advance,

Carlos

mark_h
4th May 2006, 21:36
Is this a typo?

stpapi.put.field("tiitm0112m000",tiitm012.citt,t.citt)
stpapi.put.field("tiitm0112m000",tiitm012.cuno,dummy.cuno)
stpapi.put.field("tiitm0112m000",tiitm012.suno,t.suno)
stpapi.put.field("tiitm0112m000",tiitm012.item,t.item)
stpapi.put.field("tiitm0112m000",tiitm012.cntr,dummy.cntr)

Because it should be :

stpapi.put.field("tiitm0112m000","tiitm012.citt",t.citt)
stpapi.put.field("tiitm0112m000","tiitm012.cuno",dummy.cuno)
stpapi.put.field("tiitm0112m000","tiitm012.suno",t.suno)
stpapi.put.field("tiitm0112m000","tiitm012.item",t.item)
stpapi.put.field("tiitm0112m000","tiitm012.cntr",dummy.cntr)

Looks like you missed some quotes. I also expect that change.view is the correct selection, and would be what I tried first.

cherokee
4th May 2006, 22:23
It does work... thanks a lot Mark. Silly error.

the only thing is that stpapi.change.view does not give the exact record, gives me the next one... but stpapi.find works perfect.

Carlos
:)