Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   AFS/DDC/OLE: Function servers (http://www.baanboard.com/baanboard/forumdisplay.php?f=59)
-   -   How to make API if you have more purchase orders for one supplier and item? (http://www.baanboard.com/baanboard/showthread.php?t=56046)

confused 4th June 2009 14:14

How to make API if you have more purchase orders for one supplier and item?
 
I tried to make API which would make maintain receipts form my session. I managed to do it if I have only one purchase order for suppllier and item, but if I have more than one purchase order for supplier/item (which is my case), I cannot mark approppriate record.
Can anybody help me?

there is my code:

function extern long sdanfdll9997.new.receipt(
domain tcsuno suno.i,
domain tcorno orno.i,
domain tcpono pono.i,
domain tcqrd1 diqu.i,
domain tcqrd1 dqua.i,
domain tcqrd1 bqua.i,
domain tcdate date.i,
domain tdpur.dino dino.i,
domain tcyesno disp.y,
ref domain tcrcno reno.e,
ref domain tcmcs.str1 stat.e)
{
long ret
string err(80)
string reno.s(6)
long i.fpom

stpapi.put.field("tdpur4120m000", "tdpur045.reno", str$(serija.prijema))
stpapi.put.field("tdpur4120m000", "form.dino", dino.i)
stpapi.handle.subproc( "tdpur4120m000", "tdpur4131s000", "add")
ret = stpapi.change.view("tdpur4120m000", err)
if ret = 0 then
| error
if disp.y = tcyesno.yes then
message("ERROR API: " & strip$(err))
endif
stpapi.end.session("tdpur4120m000")
return(0)
endif


|**** looking for new reno
stpapi.put.field("tdpur4131s000","tdpur045.suno",suno.i)
stpapi.put.field("tdpur4131s000","tdpur045.orno",str$(orno.i))
stpapi.put.field("tdpur4131s000","tdpur045.pono",str$(pono.i))
stpapi.put.field("tdpur4131s000","tdpur045.ddtb",str$(zdnab501.date))
ret = stpapi.find("tdpur4131s000", err)

ret.mark = stpapi.mark("tdpur4131s000")
stpapi.continue.process("tdpur4131s000",err)
stpapi.end.session("tdpur4224s000")

if ret = 0 then
| error
if disp.y = tcyesno.yes then
message("ERROR API: " & strip$(err))
endif
stpapi.end.session("tdpur4131s000")
stpapi.end.session("tdpur4120m000")
return(0)
endif

stpapi.put.field("tdpur4131s000","tdpur045.mark",str$(1))
ret = stpapi.update("tdpur4131s000", 1 ,err)
if ret = 0 then
if disp.y = tcyesno.yes then
message("ERROR API: " & strip$(err))
endif
stpapi.end.session("tdpur4131s000")
stpapi.end.session("tdpur4120m000")
return(0)
endif
stpapi.end.session("tdpur4131s000")

| zde je nutno pockat, nez se naplni cislo prijmu
reno.s = "0"
i.fpom = 0
while lval(reno.s) = 0
stpapi.get.field("tdpur4120m000", "tdpur045.reno", reno.s)
i.fpom = i.fpom + 1
if i.fpom > 10000 then
break
endif
endwhile
stpapi.put.field("tdpur4120m000", "tdpur045.reno", reno.s)
stpapi.put.field("tdpur4120m000", "tdpur045.orno", str$(orno.i))
stpapi.put.field("tdpur4120m000", "tdpur045.pono", str$(pono.i))
ret = stpapi.find("tdpur4120m000", err)
if ret = 0 then |or ret = 2 then
if disp.y = tcyesno.yes then
message("ERROR API: " & strip$(err) & " ! " &
"Provjerite prijem: " & reno.s)
endif
stpapi.end.session("tdpur4120m000")
return(0)
endif
stpapi.put.field("tdpur4120m000", "tdpur045.diqu", str$(diqu.i))
stpapi.put.field("tdpur4120m000", "tdpur045.date", str$(date.i))
stpapi.put.field("tdpur4120m000", "tdpur045.dqua", str$(dqua.i))
stpapi.put.field("tdpur4120m000", "tdpur045.bqua", str$(bqua.i))
ret = stpapi.update("tdpur4120m000", 1 , err)
if ret = 0 then
if disp.y = tcyesno.yes then
message("ERROR API: " & strip$(err) & " ! " &
"Zkontrolujte příjem číslo: " & reno.s)
endif
stpapi.end.session("tdpur4120m000")
return(0)
endif
| **
stpapi.find("tdpur4120m000", err)
stpapi.get.field("tdpur4120m000", "status", stat.e)
stpapi.end.session("tdpur4120m000")
reno.e = lval(reno.s)
return(1)
}

confused 4th June 2009 15:30

I made another attempt: now I can mark appropriate record, but it doesn't make receipt.

|**** looking for a new reno
stpapi.put.field("tdpur4131s000","tdpur045.suno",suno.i)
stpapi.put.field("tdpur4131s000","tdpur045.orno",str$(orno.i))
stpapi.put.field("tdpur4131s000","tdpur045.pono",str$(pono.i))
stpapi.put.field("tdpur4131s000","tdpur045.ddtb",str$(zdnab501.date))
ret.find = stpapi.find("tdpur4131s000", err.find)

if ret.find = 0 then | error
message("ERROR API: " & strip$(err))
stpapi.end.session("tdpur4131s000")
stpapi.end.session("tdpur4120m000")
return(0)
endif

stpapi.get.field("tdpur4131s000","tdpur045.orno" ,orno.t)
stpapi.get.field("tdpur4131s000","tdpur045.pono" ,pono.t)
stpapi.get.field("tdpur4131s000","tdpur045.srnb" ,srnb.t)

if orno.t = str$(orno.i) and pono.t = str$(pono.i) then
pravi = 1
else
pravi = 0
endif
while pravi = 0 |*** looking for a record

ret.find = stpapi.browse.set("tdpur4131s000","next.set",err.find)
stpapi.get.field("tdpur4131s000","tdpur045.orno" ,orno.t)
stpapi.get.field("tdpur4131s000","tdpur045.pono" ,pono.t)
if orno.t = str$(orno.i) and pono.t = str$(pono.i) then
pravi = 1
| message(orno.t & "/" & pono.t)
stpapi.get.field("tdpur4131s000","tdpur045.orno" ,orno.t)
stpapi.get.field("tdpur4131s000","tdpur045.pono" ,pono.t)
stpapi.get.field("tdpur4131s000","tdpur045.srnb" ,srnb.t)
message(orno.t & "/" & pono.t & "-" & srnb.t)
else
pravi = 0
endif

endwhile

ret.mark = stpapi.mark("tdpur4131s000")
stpapi.get.field("tdpur4131s000","tdpur045.orno" ,orno.t)
stpapi.get.field("tdpur4131s000","tdpur045.pono" ,pono.t)
stpapi.get.field("tdpur4131s000","tdpur045.srnb" ,srnb.t)
message(orno.t & "/" & pono.t & "-" & srnb.t & " prvi put")



stpapi.put.field("tdpur4131s000","tdpur045.mark",str$(1))
ret = stpapi.update("tdpur4131s000", 1 ,err)
if ret = 0 then
if disp.y = tcyesno.yes then
message("ERROR API: " & strip$(err))
endif
stpapi.end.session("tdpur4131s000")
stpapi.end.session("tdpur4120m000")
return(0)
endif
stpapi.continue.process("tdpur4131s000",err)
stpapi.end.session("tdpur4224s000")
| stpapi.end.session("tdpur4131s000")

| zde je nutno pockat, nez se naplni cislo prijmu
reno.s = "0"
i.fpom = 0
while lval(reno.s) = 0
stpapi.get.field("tdpur4120m000", "tdpur045.reno", reno.s)
i.fpom = i.fpom + 1
if i.fpom > 10000 then
break
endif
endwhile
stpapi.put.field("tdpur4120m000", "tdpur045.reno", reno.s)
stpapi.put.field("tdpur4120m000", "tdpur045.orno", str$(orno.i))
stpapi.put.field("tdpur4120m000", "tdpur045.pono", str$(pono.i))
ret = stpapi.find("tdpur4120m000", err)
if ret = 0 then |or ret = 2 then
if disp.y = tcyesno.yes then
message("ERROR API: " & strip$(err) & " ! " &
"Provjerite prijem: " & reno.s)
endif
stpapi.end.session("tdpur4120m000")
return(0)
endif
stpapi.put.field("tdpur4120m000", "tdpur045.diqu", str$(diqu.i))
stpapi.put.field("tdpur4120m000", "tdpur045.date", str$(date.i))
stpapi.put.field("tdpur4120m000", "tdpur045.dqua", str$(dqua.i))
stpapi.put.field("tdpur4120m000", "tdpur045.bqua", str$(bqua.i))
ret = stpapi.update("tdpur4120m000", 1 , err)
if ret = 0 then
if disp.y = tcyesno.yes then
message("ERROR API: " & strip$(err) & " ! " &
"Zkontrolujte příjem číslo: " & reno.s)
endif
stpapi.end.session("tdpur4120m000")
return(0)
endif
| **
stpapi.find("tdpur4120m000", err)
stpapi.get.field("tdpur4120m000", "status", stat.e)
stpapi.end.session("tdpur4120m000")
reno.e = lval(reno.s)
return(1)

mark_h 4th June 2009 19:22

The only thing I can thing of is to try a find on tdpur4131s000 versus on browse or change view. I would probably try change view, then find right after it. Seems to me I had to do that in one session.

jcomboue 18th February 2010 17:47

see my thread with this code
 
http://www.baanboard.com/baanboard/s...ad.php?t=57845


All times are GMT +2. The time now is 13:22.


vB.Sponsors
©2001-2018 - Baanboard.com - Baanforums.com