rohan_rege
3rd October 2002, 02:39
hi ,

i am using the foll code to change view in session tfacp1131s000 after i zoom to it from tfacp1130s000 on pressing the continue button.

| To put values into tfacp1131s000 session fields so that it shows req. record

stpapi.put.field( "tfacp1131s000", "tfacp200.ttyp", str$(tfacp200.ttyp) )
stpapi.put.field( "tfacp1131s000", "tfacp200.ninv", str$(ninv_final) )
stpapi.put.field( "tfacp1131s000", "tdpur045.suno", str$(read.suno) )
ret = stpapi.change.view("tfacp1131s000" , error.mess)
message(str$(ret))

if(strip$(error.mess)<>"") then
msg = f1131s000.get.last.message.code()
msg = "tfacp1131s000 change view : "& strip$(error.mess)&" "&strip$(msg)
cleanup.processes(3)
return(0)
endif

i dont know why ...but its giving me return value of 0 for ret & error ttstps0160 Update Cancelled ..when i try to change view of tfacp1130s000 using the stpapi.change.view with the proper key fields

i debugged and checked the values that r put in the field before
change.view and even they r correct...

any suggestion

rgds
Rohan

mark_h
3rd October 2002, 15:21
Could it be that when zooming from tfacp1130s000 that it automatically starts tfacp1131s000 in update mode? Then you put some information and try to do a change.view on it? I am not real familiar with these sessions and how they start.

Mark

rohan_rege
3rd October 2002, 19:23
hi mark,

i am posting the code in tfacp1130s000
as u see the tfacp200.appr decides ....zooming to tfacp1131s000
automatically...

so i reset it to a other value ...so i can get control over when to say continue in tfacp1130s000 and zoom to tfacp1131s000
(the automatic zooming is avoided)

choice.cont.process:

on.choice:

on case tfacp200.appr
case tfacp.matc.pur:
zoom.to$("tfacp1131s000",z.session,"tfacp1130","",0)

now the problem is , some times when i change.view for a particular record...it works...but other times it doesnt work
if a Matching has already been done ....in tfacp1131s000...this is ok functionally ..since it shudnt update matched/approved record

but currently for my record no matching has been done btw the receipts and invoice ...even then it shows Update cancelled error

any ideas...????

rgds
Rohan

mark_h
3rd October 2002, 19:57
I do have one idea that you could try. Just for testing purposes may you could try this:


stpapi.put.field( "tfacp1131s000", "tfacp200.ttyp", str$(tfacp200.ttyp) )
stpapi.put.field( "tfacp1131s000", "tfacp200.ninv", str$(ninv_final) )
stpapi.put.field( "tfacp1131s000", "tdpur045.suno", str$(read.suno) )
ret = stpapi.change.view("tfacp1131s000" , error.mess)

stpapi.put.field( "tfacp1131s000", "tfacp200.ttyp", str$(tfacp200.ttyp) )
stpapi.put.field( "tfacp1131s000", "tfacp200.ninv", str$(ninv_final) )
stpapi.put.field( "tfacp1131s000", "tdpur045.suno", str$(read.suno) )
ret = stpapi.change.view("tfacp1131s000" , error.mess)
if(strip$(error.mess)<>"") then
msg = f1131s000.get.last.message.code()
msg = "tfacp1131s000 change view : "& strip$(error.mess)&" "&strip$(msg)
cleanup.processes(3)
return(0)
endif


The first change view may or may not work, but it might reset the session to where the second change.view will work. I do not like this, but I can not think of anything else to try.

Mark

lbencic
4th October 2002, 22:44
Mark - None of us like it, but it seems to be a recurring AFS problem! Have you found that? I thought it was the finds/change views. Now I have narrowed it (i think) to just the first find/change view. Like you mentioned, it seems to be able to execute the second time fine *sigh*.

Probably has something to do with the entry mode of the session, as you mentioned, or other commands in the script. The first find may reset some things for the second to work properly.

I have gone as far as putting in 'Find loops', as Rohan has found already. I put in a Max find of 10, but I never seem to get past 2. The second find always works.

The theory there is to execute the find, then do get fields, then, if you do not have your record, execute the find again. Repeat until found (or MAX FINDS), but I bet you don't get past find #2.

The return value from the Find is not reliable, you should always use the get fields and check to make sure you have the proper record.

mark_h
4th October 2002, 23:33
Hi Lisa,

I have not had to do a find loop just to find a record. I have had to do 2 updates on a record. Find record, update it, find again, update a another field. I will have to keep this in mind if I do some of the receiving sessions.

Mark

jmathew
4th September 2004, 08:43
Hi Mark,

I have been tring AFS for Maintain Inbound and facing the same problem. The code that i have written is given below, but even after 2nd time the return value is still 0. Is there any solution to this?

string item(16)
item = ""
stpapi.put.field("tdilc4103m000", "runnumber", str$(1))
stpapi.put.field("tdilc4103m000", "k.o.order", str$(6))
stpapi.put.field("tdilc4103m000", "ordernr", str$(430051))

stpapi.handle.subproc("tdilc4103m000", "tdilc4104s000", "add")
stpapi.zoom.option("tdilc4103m000", 1, "tdilc4104s000", error.msg)
stpapi.continue.process("tdilc4104s000", error.msg)

stpapi.put.field("tdilc4104s000", "tdilc402.koor", str$(6))
stpapi.put.field("tdilc4104s000", "tdilc402.orno", str$(430051))
stpapi.put.field("tdilc4104s000", "tdilc402.pono", str$(1000))
stpapi.put.field("tdilc4104s000", "tdilc402.sera", str$(1))
stpapi.put.field("tdilc4104s000", "tdilc402.serb", str$(2))
ret1 = stpapi.change.view("tdilc4104s000", error.msg)

stpapi.put.field("tdilc4104s000", "tdilc402.koor", str$(6))
stpapi.put.field("tdilc4104s000", "tdilc402.orno", str$(430051))
stpapi.put.field("tdilc4104s000", "tdilc402.pono", str$(1000))
stpapi.put.field("tdilc4104s000", "tdilc402.sera", str$(1))
stpapi.put.field("tdilc4104s000", "tdilc402.serb", str$(2))
ret1 = stpapi.change.view("tdilc4104s000", error.msg)
if not ret then
stpapi.get.field("tdilc4104s000", "tdilc402.item", item)
endif
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")

Thanks,
John Mathew

mark_h
5th September 2004, 03:21
Not sure I have done one on maintain inbound - I think I only had to generate and release. Anyway the one thing I notice is that you have this:


stpapi.handle.subproc("tdilc4103m000", "tdilc4104s000", "add")
stpapi.zoom.option("tdilc4103m000", 1, "tdilc4104s000", error.msg)
stpapi.continue.process("tdilc4104s000", error.msg)


I would expect it to be zoom or continue to activate tdilc4104s000, but not both. I know on outbound I just use continue. I would probably remove the zoom command. Now that I mention that I do recall not having to do two finds. I will have to check it when I return from vacation.

Mark

jmathew
5th September 2004, 08:52
Hi Mark,

I have taken off Continue from the coding, but the same problem still exists.

mark_h
13th September 2004, 03:04
When I get back to work tomorrow I will check and see if I did one for maintain inbound. If so I will post the code. I know I have one for maintain outbound and I may post it as an example. Or have you got it fixed since I last visited?

Mark

mark_h
13th September 2004, 15:54
Here is what mine looks like - in my case I am inserting a record for a receipt.


function extern maintain_inbound( domain tcmcs.str12 runnumber,
domain tdilc.kooa order.type,
domain tcorno order.number,
domain tdilc.loca order.location,
ref string msg())
{
long rc
string dummy(32)

msg = ""
stpapi.handle.subproc("tdilc4103m000","tdilc4104s000","add")
stpapi.put.field("tdilc4103m000","runnumber",runnumber)
stpapi.put.field("tdilc4103m000","k.o.order",str$(order.type))
stpapi.put.field("tdilc4103m000","ordernr",str$(order.number))
stpapi.continue.process("tdilc4103m000",msg)
if not isspace(msg) then
stpapi.end.session("tdilc4103m000")
return
endif
stpapi.handle.subproc("tdilc4104s000","tdilc4515s000","add")
stpapi.insert("tdilc4104s000",1,msg)
stpapi.put.field("tdilc4515s000","tdilc402.koor",str$(order.type))
stpapi.put.field("tdilc4515s000","tdilc402.orno",str$(order.number))
rc = stpapi.change.view("tdilc4515s000",msg)
if not isspace(msg) or rc<>1 then
msg = "Production order not ready for delivery"
stpapi.end.session("tdilc4515s000")
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
return
endif
rc = stpapi.browse.set("tdilc4515s000","last.set", msg)
rc = stpapi.mark("tdilc4515s000",msg)
stpapi.continue.process("tdilc4515s000",msg)
if not isspace(msg) or rc<>1 then
stpapi.end.session("tdilc4515s000")
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
return
endif
stpapi.end.session("tdilc4515s000")
stpapi.put.field("tdilc4104s000","tdilc402.loca",order.location)
stpapi.update("tdilc4104s000",1,msg)
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
}


Mark