rohan_rege
11th October 2002, 00:12
Hi ,
In a error handling function , when I have to change all the records in tfacp1131s000 to Not Matched , I am using the following code to browse thru the records and then update each records Match field to NO.....

Problem is it behaves very unpredictably ...
sometimes even when there are records whose Match field has to be changed to NO...the first stpapi.browse.set with the first.set option returns a 0.

I dont know why its behaving this way.........?

Any ideas ???????

The following is the piece of that code:

ret = stpapi.browse.set("tfacp1131s000" , "first.set" , error.mess)
while ret
stpapi.mark("tfacp1131s000" , error.mess)
stpapi.put.field("tfacp1131s000" ,"tdpur045.matc" , str$(unmatch))
ret = stpapi.update("tfacp1131s000" ,1 , error.mess)
if ret = 0 then
cleanup.processes(3)
msg = "Matching/Approving already done in another invoice , so cant Unmatch and delete Invoice"
return(0)
endif
ret = stpapi.browse.set("tfacp1131s000" ,"next.set" , error.mess)
endwhile

mark_h
11th October 2002, 16:07
Hi rohan,

When you get to the first stpapi.browse is it in update or edit mode? Maybe you need to do it twice as Lisa suggested in another post.

Mark

rohan_rege
11th October 2002, 16:59
hi mark,


ya , i tried putting the stpapai.browse.set in a while loop....till it either finds the record or till the count < 11.

it is working fine now.......


but i kindaa didnt understand why it behaves this way....??

rgds
Rohan

mark_h
11th October 2002, 19:54
That is one of the mysteries. I think it is the way the sessions start, but that is a guess.

Mark

rohan_rege
15th October 2002, 23:31
hi ,

i am somehow again facing the problem for session tfacp1131s000 where i am trying a browse.set , but it somehow doesnt get the record....

i verified by using a find for a particular record - it returns 1 for find indicating the record exist..also i verified manually

problem is i want to delete the records when there is an error and so i have to use browse.set to go thru and reset all the records in tfacp1131s000

but it wont just find the record

also i tried changing the view...but its not allowed ,it gives a error Update Cancelled

The code :
while ret = 0 and count < 11
ret = stpapi.browse.set("tfacp1131s000" , "first.set" , error.mess)
count = count + 1
endwhile

ret always returns 0
any suggestions .....

Rgds
Rohan

mark_h
15th October 2002, 23:36
Have you tried stpapi.recover when you get the error?

Mark

rohan_rege
15th October 2002, 23:58
hi mark,

actually , in tfacp1131s000 after i match all the invoices ....

there might be two cases after this ......

case 1 :

when a invoice detail doesnot get matched then that record along with all other invoice lines that matched for that particular invoice r unmatched using the unmatch.and.delete.invoice() function as follows
ON CASE ttyp
CASE "AP1":
ret
=ap1(ttyp,ninv_final,read.orno,read.pono,read.srnb,read.match,read.qty,read.inv.amt,msg)

if ret = 0 then
stpapi.end.session("tfacp1131s000")
stpapi.end.session("tfacp1130s000")
ret = unmatch.and.delete.invoice(read.orno , read.pono , read.srnb ,ttyp,ninv_final,read.suno.temp,msg)
return(0)
endif

case 2: if all lines matched properly and then there is a problem approving , then i use unmatch.and.delete.invoice() func again



ret=ap1_approval_process(ttyp,ninv_final,read.leac,read.dim1,read.dim2,read.dim3,read.dim4,read.dim5,read.leac.amt,msg)

if ret=0 then
ret = unmatch.and.delete.invoice(read.orno , read.pono , read.srnb ,ttyp,ninv_final,read.suno.temp,msg)
return(0)
endif

In unmatch.and.delete.invoice() i get to tfacp1131s000 session and then am trying to use stpapi.browse.set to go thru all the records that are matched ...and reset them back to unmatched...

problem is ,as i said ..the stpapi.browse.set wont even find the first record......browsing thru all records is a far off thing

i tried using find to see if the session actually had the record ...
and i found that it does ........
i also tried to mark the record to make it current and then browse...but that doesnt work either

god knows whats wrong ....

rgds
Rohan

mark_h
16th October 2002, 03:54
In which case does the stpapi.browse not work? I notice in one case you end both sessions and in the other you do not. Maybe that was just a mis-print in the post. Is the tfacp1131s000 session already open when you are trying to do the stpapi.browse.set? The reason I ask is because it almost sounds like the tfacp1131s000 session does not know about the records and needs to be refreshed. I would expect closing the session and re-opening would fix that, but I am not sure if that is feasible.

Mark

rohan_rege
16th October 2002, 17:33
hi mark,

In which case does the stpapi.browse not work? I notice in one case you end both sessions and in the other you do not. Maybe that was just a mis-print in the post.

RE : In the second case my aprroval process closes both the sessions...so i dont have to cose it again

Is the tfacp1131s000 session already open when you are trying to do the stpapi.browse.set? The reason I ask is because it almost sounds like the tfacp1131s000 session does not know about the records and needs to be refreshed. I would expect closing the session and re-opening would fix that, but I am not sure if that is feasible.

RE : ya , currently i am doing that only..closing and re-opening the session in unmatch.and.delete() function..
also i checked whether tfacp1131s000 knows abt the record by using a stpapi.get.field on the view fields and also on the multioccurence reocrds........it find the record in that session correctly......but the problem is find wont suffice ...i want to browse thru all records and delete all those that can be deleted

IMP:
Also one more different impt. question .......at places i have used stpapi.end.session , which sometimes gets executed even when the session is not open.....this i found doesnot hang the program....but do u think it causes any problems

mark_h
16th October 2002, 19:40
Is there anything in the error message on the stpapi.browse.set? Since you know a find works is there a possibility of doing some kind of find before the stpapi.browse.set. I am starting to run out of ideas.

Mark

rohan_rege
16th October 2002, 21:07
hi mark ,


actually i tried using some sort of find ...but it wudnt work....

then i used the manual method to see actually what was happening.....

when i was doing so , i accidently hit across a form command in the same session tfacp1131s000 Unmatch Receipts which does the unmatching......

so all i do is call this form command instead of actually trying to unmatch the receipts myself

So i have to no longer to bother abt stpapi.browse.set problem for this session........

sometimes the straight forward solutions are easier and hence overlooked .......same happened with me...

good at least i realised it before i had given up....


Thanks for ur help..

rgds
Rohan