grzegorz
28th June 2008, 18:09
I have a strange problem with AFS for Purchase Order lines. My need is to update purchase price (field tdpur041.pric, i think). Should be simple, so I tried like this:


stpapi.put.field( "tdpur4102m000" , "tdpur041.orno" , str$(my.orno) )
stpapi.put.field( "tdpur4102m000" , "tdpur041.pono" , str$(my.pono) )
loc.res = stpapi.find( "tdpur4102m000" , err.msg2 )
stpapi.put.field( "tdpur4102m000", "tdpur041.pric" , str$(my.prip) )
stpapi.enum.answer( "tdpur4102m000" , "tdpur41096" , tcyesno.yes )
loc.res = stpapi.update( "tdpur4102m000" , 1 , err.msg )
if not isspace(err.msg) then
stpapi.recover( "tdpur4102m000" , err.msg2 )
stpapi.end.session( "tdpur4102m000" , err.msg2 )
return(1)
endif
stpapi.end.session( "tdpur4102s000" , err.msg2 )



Everything seems be fine, error messages are empty and stpapi.update returns with "1", but price is not updated. Of course, if I do the same manually, price change is accepted.
In afs.log I can't find any hint. Here is my log:


LOGGING STARTED
01-05-2007
120->get.fields
120<-get.fields0tdpur041.orno1tdpur041.pono1tdpur041.cprj1tipcs020.dsca0tdpur041.citt1form.aitc1tdpur041.item1tdpur041.cntr1itm.dsca0tdpur041.opol1tdpur041.revi1tdpur041.cwar1tcmcs003.dsca0disp.txta0tdpur041.cuqp1tdpur041.oqua1tdpur041.cupp0tdpur041.pric1tdpur041.plev0tdpur041.disc1tdpur041.ldam1tdpur041.dlev0ccur.dscb0tdpur041.amta1tdpur041.ddta1alt.date1back.t0order.t0disp.suno0disp.nama0tdpur041.orno0form.aitc0tdpur041.pono0tdpur041.cprj0tdpur041.item0tdpur041.cntr0itm.dsca0tdpur041.btsp1tdpur041.lsel1tdpur041.clot1tdpur041.sdsc1tdpur045.copr0tdpur041.qual1itm.stoc0itm.ordr0itm.allo0tdpur041.cono0tdpur041.posi0tdpur041.sorn0tdpur041.spon0tdpur045.torn0tdpur045.tpon0tdpur041.srvo0tdpur041.srvp0back.t0order.t0disp.suno0disp.nama0tdpur041.orno0tdpur041.pono0tdpur041.cprj0tdpur041.item0tdpur041.cntr0itm.dsca0tdpur041.cpla1tdpur041.cact1cact.desc0tdpur041.cspa1cspa.desc0tdpur041.cstl1cstl.desc0tdpur041.ccco1tppdm100.desc0tdpur041.cvat1tcmcs036.dsca0tdpur041.pacn1desc.ledger0tdpur041.dim11dim1.desc0tdpur041.dim21dim2.desc0tdpur041.dim31dim3.desc0tdpur041.dim41dim4.desc0tdpur041.dim51dim5.desc0form.aitc0back.t0order.t0disp.suno0disp.nama0labledim10labledim20labledim30labledim40labledim50
>tdpur4102m000 put.field:tdpur041.orno 300205
>tdpur4102m000 put.field:tdpur041.pono 10
>tdpur4102m000 Find
120->def.find
120<-def.find01
<tdpur4102m000 record found (1)
>tdpur4102m000 enum.answer tdpur41096:1
120->enum.answertdpur410961
120<-enum.answer0
>tdpur4102m000 put.field:tdpur041.pric 16
>tdpur4102m000 update
120->modify.set+save
120<-modify.set+save0
<tdpur4102m000
>tdpur4102m000 end.session
120->end.program
120<-end.program1


This is a fragment of larger script, with many other AFS calls. Everything works fine, except the piece above. Can somebody help me with that?

mark_h
30th June 2008, 19:58
Okay - don't know if tdpur5106s000 plays a roll on your system or not. The below works for me. Is there a reason you end tdpur4102s000 and not tdpur4102m000? You can also try stpapi.save. Another option is stpapi.update mode of 0 or false, followed by stpapi.save. Those are a couple of options I have tried before. Not sure if this helps.


stpapi.put.field( "tdpur4102m000" , "tdpur041.orno" , "437980" )
stpapi.put.field( "tdpur4102m000" , "tdpur041.pono" , "1" )
rc = stpapi.find( "tdpur4102m000" , err )
stpapi.handle.subproc("tdpur5106s000", "tdpur4102m000", "ADD")
stpapi.put.field( "tdpur4102m000", "tdpur041.pric" , str$(150.00) )
| stpapi.enum.answer( "tdpur4102m000" , "tdpur41096" , tcyesno.yes )
rc = stpapi.update( "tdpur4102m000" , 1 , err )
stpapi.continue.process("tdpur5106s000",err)
stpapi.end.session("tdpur5106s000",err)
stpapi.end.session( "tdpur4102m000" , err )

grzegorz
2nd July 2008, 11:46
Thank you for your answer. I also tried a lot of things before posting my problem here. And, the most inspiring part of it was your "mantra". So, problem is solved by upgrading to newer SP and Porting Set!
However, when one problem is solved, at least two new raise (as usual). So, now I ran into known issue with Maintain Receipt and freezing session tdilc4113s000. Before update it was working fine and now it hangs on first stpapi.put.field for tdilc4113s000.

I tried to use the trick with boi.call variable

boi.call = "tdboidll0011.Create"

But it does not help.
Other suggestions found on forum also did't help in my case.

So, I would like to ask, if somebody has a running solution with AFS for Maintain Receipt with ILC. If yes, then please post it and state, on which porting set and service pack does it work. Also I will be grateful for any updated information about how to solve problem with freezing session tdilc4113s000.

BTW: I'm on SP18 and port 6.1c.07.06 now.

mark_h
2nd July 2008, 15:08
Sorry to say, but I had to add code to the Baan sessions to get them to work. I had to do this for service pack 18. Do you own source code? I had to use qkey to make a few changes to get things to work. I also had to do this for maintain approvals.

grzegorz
2nd July 2008, 15:17
Oh, no!. I dont have access to source code. Now I'm just installing service packs up to 24 andwe will see if it helps.
My luck that i work on a development box and can freely play around with service packs and porting sets.

mark_h
2nd July 2008, 16:00
Please let me know if it works. I might be able to remove the coding changes I made - that would be nice.

grzegorz
2nd July 2008, 16:07
Of course, please be patient. SP24 won't be ready until tomorow.

mark_h
2nd July 2008, 16:50
I am impressed - it takes us months to do a service pack.

grzegorz
3rd July 2008, 12:52
So, for now we raised from SP18 on SP23. Problem with tdilc4113s000 is still not solved completely, but the session behaves slightly different. In SP18 the session froze after first stpapi.put.field("tdilc4113s000"...) call. Now the session stops for several seconds and goes on. But, if it comes to stpapi.insert( "tdilc4113s000"...) it freezes forever.
Program script looks like that:

stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(loc.reno))
stpapi.put.field("tdpur4120m000","tdpur045.orno",str$(orno))
stpapi.put.field("tdpur4120m000","tdpur045.pono",str$(pono))
loc.res = stpapi.find("tdpur4120m000",err.msg)
if not isspace( err.msg ) or loc.res <> 1 then
stpapi.end.session("tdpur4120m000", err.msg2)
zonk() |show error
return
endif
boi.call = "tdboidll0011.Create" | not helpful much
stpapi.put.field("tdpur4120m000","tdpur045.diqu",str$(diqu))
stpapi.put.field("tdpur4120m000","tdpur045.date",str$(date))
stpapi.put.field("tdpur4120m000","tdpur045.dqua",str$(dqua))
stpapi.update("tdpur4120m000",1,err.msg)
stpapi.handle.subproc("tdpur4120m000","tdilc4113s000","add")
if not isspace(err.msg) then
stpapi.recover( "tdpur4120m000" , err.msg2 )
stpapi.end.session("tdilc4113s000", err.msg2)
stpapi.end.session("tdpur4120m000", err.msg2)
zonk()
return
endif
stpapi.put.field("tdilc4113s000", "tdilc402.clot",clot)
stpapi.put.field("tdilc4113s000",tdilc402.date",str$(date))
stpapi.put.field("tdilc4113s000", "tdilc402.qstr",str$(dqua))
stpapi.put.field("tdilc4113s000", "tdilc402.qstc",str$(nqua))
stpapi.insert("tdilc4113s000",1,err.msg)
if not isspace(err.msg) then
stpapi.recover("tdilc4113s000" , err.msg2 )
stpapi.recover("tdpur4120s000" , err.msg2 )
stpapi.end.session("tdilc4113s000", err.msg2)
stpapi.end.session("tdpur4120m000", err.msg2)
zonk()
return
endif
stpapi.end.session("tdilc4113s000", err.msg2)
stpapi.end.session("tdpur4120m000", err.msg2)



In AFSLOG there are some new messages in this case:

... *** here is stpapi.put.field("tdilc4113s000","tdilc402.clot", clot )
56dll->serv (handle.subsessiontdilc4113s0002166)
tdilc4113s000waiting for prev cont.proc
*** here the session freezes for 10 seconds
tdilc4113s000waiting timed out
>tdilc4113s000(167) put.field:tdilc402.clot ASDWSWS
*** and it goes forward, then come other fields:
tdilc4113s000waiting for prev cont.proc
tdilc4113s000waiting timed out
>tdilc4113s000(167) put.field:tdilc402.date 733403
tdilc4113s000waiting for prev cont.proc
tdilc4113s000waiting timed out
>tdilc4113s000(167) put.field:tdilc402.qstr 100
tdilc4113s000waiting for prev cont.proc
tdilc4113s000waiting timed out
>tdilc4113s000(167) put.field:tdilc402.qstc 100

*** here is a stpapi.insert call
>tdilc4113s000 insert
tdilc4113s000waiting for prev cont.proc
tdilc4113s000waiting timed out
156dll->serv (add.set+save167)
tdilc4113s000(167)-RUNNING:add.set+save
*** farewell and goodbye


Have you seen something like that? What "cont.proc" is the session waiting for? - there is no active cont.proc option there. And I have a question for Mark : can you describe what changes have you done in source code, maybe it helps to understand the flow of opreation in tdilc4113s000 better.

grzegorz
3rd July 2008, 15:17
Additional info: SP24 doesn't change the situation.

mark_h
3rd July 2008, 17:56
Okay - I did notice in your code you have the stpapi.handle after the update - you should reverse these lines.

stpapi.update("tdpur4120m000",1,err.msg)
stpapi.handle.subproc("tdpur4120m000","tdilc4113s000","add")

First here is my code - note I always create receipt for all lines and then modify only the line that is needed. Second please note that I used qkey to modify source scripts.

function extern domain tcrcno create_receipt( domain tcrcno receipt.number,
domain tcorno purchase.order,
domain tcpono purchase.line,
domain tcqiv1 packingslip.qty,
domain tcqiv1 received.qty,
domain tcdate received.date,
domain tdltc.clot purchase.lot,
domain tcdate purchaselot.date,
domain tcconv conv.factor,
domain tccuni purchase.unit,
domain tcitem purchase.item,
ref string msg())
{
string dummy(6)

| Creating a receipt always use 0 for the tdpur045.reno field.
msg = ""
stpapi.handle.subproc("tdpur4120m000","tdpur4224s000","add")
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(0))
rc = stpapi.change.view("tdpur4120m000",msg)
if not isspace(msg) then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif

| Always use tdpur4224s000 to create receipt for all lines.
stpapi.put.field("tdpur4224s000","form.orno",str$(purchase.order))
stpapi.continue.process("tdpur4224s000",msg)
stpapi.end.session("tdpur4224s000")
if not isspace(msg) and strip$(msg)<> "Process is gone" then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif
msg = ""

| Try a pause to make sure receipt is completed.
suspend(3000)
| Get the receipt so you can use the modify receipt to update. the field.
stpapi.get.field("tdpur4120m000","tdpur045.reno",dummy)
receipt.number = val(dummy)
stpapi.end.session("tdpur4120m000")

| Verify this receipt number has this PO and line on it.
select tdpur045.reno
from tdpur045
where tdpur045._index6 = {:receipt.number,:purchase.order,:purchase.line}
as set with 1 rows
selectdo
selectempty
receipt.number = 0
endselect
if receipt.number = 0 then
msg = "Receipt failed."
return(0)
endif

| Now go modify the new receipt.
modify_receipt( receipt.number,
purchase.order,
purchase.line,
packingslip.qty,
received.qty,
received.date,
purchase.lot,
purchaselot.date,
conv.factor,
purchase.unit,
purchase.item,
msg)
return(receipt.number)
}
|******************************************************************************
|* API Code for modifying an existing receipt.
|******************************************************************************
function extern modify_receipt( domain tcrcno receipt.number,
domain tcorno purchase.order,
domain tcpono purchase.line,
domain tcqiv1 packingslip.qty,
domain tcqiv1 received.qty,
domain tcdate received.date,
domain tdltc.clot purchase.lot,
domain tcdate purchaselot.date,
domain tcconv conv.factor,
domain tccuni purchase.unit,
domain tcitem purchase.item,
ref string msg())
{
string dummy(6), error_code(16)
domain tcorno get.orno
domain tcpono get.pono

select tiitm001.stgu, tiitm001.kitm
from tiitm001
where tiitm001._index1 = {:purchase.item}
as set with 1 rows
selectdo
endselect

msg = ""
boi.call = "tdboidll0011.Create"
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(receipt.number))
stpapi.put.field("tdpur4120m000","tdpur045.orno",str$(purchase.order))
stpapi.put.field("tdpur4120m000","tdpur045.pono",str$(purchase.line))
rc = stpapi.find("tdpur4120m000",msg)
if not isspace(msg) or rc<>1 then
stpapi.end.session("tdpur4120m000")
return
endif

| Prepare to handle lot controlled items.
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.handle.subproc("tdpur4120m000","tdilc4113s000","add")
endif

stpapi.put.field("tdpur4120m000","tdpur045.diqu",str$(packingslip.qty))
stpapi.put.field("tdpur4120m000","tdpur045.date",str$(received.date))
stpapi.put.field("tdpur4120m000","tdpur045.dqua",str$(received.qty))
rc = stpapi.update("tdpur4120m000",1,msg)
if not isspace(msg) or rc<>1 then
if not isspace(purchase.lot) or conv.factor>1 then
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
return
endif

| Need to handle the conversion factor.
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.put.field("tdilc4113s000", "tdilc402.clot",purchase.lot)
stpapi.put.field("tdilc4113s000", "tdilc402.date",str$(purchaselot.date))
stpapi.put.field("tdilc4113s000", "tdilc402.qstr",str$(received.qty*conv.factor))
stpapi.put.field("tdilc4113s000", "tdilc402.qstc",str$(received.qty*conv.factor))
rc = stpapi.insert("tdilc4113s000",1,msg)
error_code = stpapi.get.mess.code("tdilc4113s000",msg)
if strip$(error_code) = "tdilc40062" then
msg = ""
endif
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
}


Second here is the code from tdpur4120m000:

|******************************************************************************
|* 20050418 Mark Holland 04/18/2005
|* Added boi variables and set g.sub.session for service pack changes. These
|* changes allow the receipt afs programs to work.
|******************************************************************************
|* Script Type: 123
|******************************************************************************
|****************************** DECLARATION SECTION ***************************
declaration:
table ttdpur045 | Purchase Orders
table ttdpur975 | Maintain Approvals Date Tracking
| 20060821.st Add additional tables
table ttdpur041 | Purchase Order lines
table ttiitm001 | Item master

| 20050418.st Added these variables
extern domain tcmcs.str132 boi.call
extern long boi.bqua.flag
extern domain tcbool g.sub.session | 20050418.end
| 20060821.st Add additional variable
extern domain tckitm check.item.type
extern domain tcqrd1 ordr.qty, bcko.qty
|#pobj added by QKEY 3.70
|#end add by QKEY

field.tdpur045.dqua:
before.input:
|20050418.st Added this if statement. Might need to modify this to check
| the calling session to make sure it was tdapi.
if api.mode then
g.sub.session = true
endif


No changes were actually made in tdilc4113s000.

grzegorz
3rd July 2008, 18:18
Thank you for your answer. The version I posted is one of many I tried, and stpapi.handle.subproc was already almost everywhere, before update, on top of whole function, after update, no change. I'm doing quit the same procedure, first I create receipt for all PO lines, then (its different than in your case, but it should not matter ) I remove those lines that are not in delivery. In the end I want to put quantities in delivered lines. Unfortunately I dont have source codes nor qkey, so I have to find another way (if any exists). Thank you again.

grzegorz
7th July 2008, 09:56
Problem is solved. I must have been blind!
It's true, that a variable "boi.call" must be set. The session tdilc4113 imports it from parent process (tdpur4120). And tdpur4120 imports it from my session and it seems that import function is called somewhere in before.program section. So, in my sequece:

stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(loc.reno))
stpapi.put.field("tdpur4120m000","tdpur045.orno",str$(orno))
stpapi.put.field("tdpur4120m000","tdpur045.pono",str$(pono))
loc.res = stpapi.find("tdpur4120m000",err.msg)
boi.call = "tdboidll0011.Create"

session tdpur4120m000 is started with first stpapi.put.field. It imports boi.call, which is NOT SET at this moment. So, setting boi.call at the place I've done is simply TOO LATE.

So, I moved up the line with boi.call = "tdboidll0011.Create" before first stdapi.call , and the session tdilc4114s000 does not freeze anymore.

kmcinc
26th October 2017, 04:18
I would like to add that variable 'boi.call' should be declared as 'extern'.