kathuria
17th January 2005, 12:12
I have written afs script for match and approval. It's working very well for match but at the time of approval session get stuck. I am arranging code of that session. Please do needfull as soon as possible.

stpapi.handle.subproc("tfacp1130m000","tfacp1131s000","add")
stpapi.continue.process("tfacp1130m000", error.msg)
stpapi.put.field("tfacp1131s000", "tdpur045.matc", "2")
stpapi.update("tfacp1131s000",true,error.msg)
if error.msg = "" then
stpapi.end.session("tfacp1131s000")
else
stpapi.recover("tfacp1131s000",error.recv)
endif
stpapi.handle.subproc("tfacp1130m000","tfacp1140s000","update")
stpapi.handle.subproc("tfacp1140s000","tfacp1141s000","kill")
stpapi.application.option("tfacp1130m000", 1, 0, error.msg)

|stpapi.handle.subproc("tfacp1140s000","tfacp1141s000","kill")
|stpapi.update("tfacp1141s000",true,error.msg)
stpapi.end.session("tfacp1141s000")
|stpapi.zoom.option("tfacp1140s000",1,"tfacp1133s000",error.msg)
|stpapi.get.field("tfacp1133s000", "tfacp101.ttyp", ttyp)
|stpapi.get.field("tfacp1133s000", "tfacp101.ninv", tfacp005.leac)
stpapi.handle.subproc("tfacp1141s000","tfacp1141s000","update")
stpapi.continue.process("tfacp1141s000", error.msg)
stpapi.end.session("tfacp1141s000")
stpapi.put.field("tfacp1133s000", "tfacp101.leac", tfacp005.leac)
stpapi.put.field("tfacp1133s000", "tfacp101.dim1", tfacp005.dim1)
stpapi.put.field("tfacp1133s000", "tfacp101.dim2", tfacp005.dim2)
stpapi.put.field("tfacp1133s000", "tfacp101.dim3", tfacp005.dim3)
stpapi.put.field("tfacp1133s000", "tfacp101.dim4", tfacp005.dim4)
stpapi.put.field("tfacp1133s000", "tfacp101.dim5", tfacp005.dim5)
stpapi.update("tfacp1133s000",true,error.msg)
stpapi.end.session("tfacp1133s000")
stpapi.end.session("tfacp1140s000")
|stpapi.handle.subproc("tfacp1130m000","tfacp1141s000","add")
|stpapi.handle.subproc("tfacp1130m000","tfacp1133s000","add") |test
|stpapi.application.option("tfacp1130m000", 1, 0, error.msg)
if error.msg = "" then
stpapi.save("tfacp1141s000",error.msg)
stpapi.enum.answer("tfacp1141s000", "tfacp00001", tcyesno.no)
else
stpapi.recover("tfacp1141s000",error.recv)
endif
stpapi.end.session("tfacp1141s000")
||stpapi.end.session("tfacp1140s000")

if diff.amt <> 0 then
|stpapi.handle.subproc("tfacp1130m000","tfacp1140s000","ignore")
|stpapi.handle.subproc("tfacp1130m000","tfacp1133s000","add")
stpapi.continue.process("tfacp1140s000", error.msg)
|stpapi.zoom.option("tfacp1140s000",1,"tfacp1133s000",error.msg)
stpapi.get.field("tfacp1133s000", "tfacp101.ttyp", ttyp)
|stpapi.get.field("tfacp1133s000", "tfacp101.ninv", tfacp005.leac)
stpapi.put.field("tfacp1133s000", "tfacp101.leac", tfacp005.leac)
stpapi.put.field("tfacp1133s000", "tfacp101.dim1", tfacp005.dim1)
stpapi.put.field("tfacp1133s000", "tfacp101.dim2", tfacp005.dim2)
stpapi.put.field("tfacp1133s000", "tfacp101.dim3", tfacp005.dim3)
stpapi.put.field("tfacp1133s000", "tfacp101.dim4", tfacp005.dim4)
stpapi.put.field("tfacp1133s000", "tfacp101.dim5", tfacp005.dim5)
|stpapi.put.field("tfacp1120s000", "amount", str$(diff.amt))
| stpapi.insert("tfacp1133s000",true,error.msg)
stpapi.update("tfacp1133s000",true,error.msg) |guri.n

if error.msg = "" then
stpapi.end.session("tfacp1133s000")
stpapi.end.session("tfacp1140s000")
else
stpapi.recover("tfacp1133s000",error.recv)
endif
endif
endif
stpapi.end.session("tfacp1130m000")


Best Regards
Sanjay Kathuria

mark_h
18th January 2005, 19:34
Your code was confusing. First let me say I am not that familiar with this sessions and am only giving you my best guess at what should be done.


stpapi.handle.subproc("tfacp1130m000","tfacp1140s000","update")
stpapi.handle.subproc("tfacp1140s000","tfacp1141s000","kill")
stpapi.application.option("tfacp1130m000", 1, 0, error.msg)
stpapi.end.session("tfacp1141s000")
stpapi.handle.subproc("tfacp1141s000","tfacp1141s000","update")
stpapi.continue.process("tfacp1141s000", error.msg)
stpapi.end.session("tfacp1141s000")


This was very confusing - it looks like you want the 1141s000 session killed and yet then you do a continue. Also the stpapi.hanle.supproc for tfacp1141s000 for tfacp1141s000 is not needed. Assuming you want a continue in tfacp1141s000 I would make this code look like this:

| tfacp1140s000 is activated from tfacp1130m000
stpapi.handle.subproc("tfacp1130m000","tfacp1140s000","add")
| tfacp1141s000 is controlled and activated by tfacp1140s000
stpapi.handle.subproc("tfacp1140s000","tfacp1141s000","add")
| Assumes that this application.option starts tfacp1140s000 which then starts tfacp1141s000
stpapi.application.option("tfacp1130m000", 1, 0, error.msg)
| Now we do a continue in tfacp1141s000
stpapi.continue.process("tfacp1141s000", error.msg)
| Now we end tfacp1141s000 which returns us to tfacp1140s000
stpapi.end.session("tfacp1141s000")


Note that I do not know what starts the tfacp1133 session so I did not even attempt to address that session. I have never used the update option on the stpapi.handle.subproc - only the add option. The key to writing a function server is to step through it one session and command at a time making sure each step works and that you have control of the session(s). This is all a guess since I am not familiar with these session.

Mark