Gagandeep
20th March 2012, 14:30
Hi,
Does anyone has code to update Standard cost by AFS (Baan IVc4)?
My code opens session ticpr2210m000, but no calculation/ updations are performed. No error is returned.
Please help..

mark_h
21st March 2012, 14:14
This is the correct forum for questions like this - searching this forum I found this thread (http://www.baanboard.com/baanboard/showthread.php?t=6182&highlight=ticpr2210m000&page=2) and then this thread here (http://www.baanboard.com/baanboard/showthread.php?t=60845&highlight=ticpr2210m000). If this session is doing multiple reports then it may be an issue.
I used this code once to see if the error report came up:

stpapi.put.field("ticpr2210m000","item.f","PLM7249037M")
stpapi.put.field("ticpr2210m000","item.t","PLM7249037M")
stpapi.put.field("ticpr2210m000","cntr.f","")
stpapi.put.field("ticpr2210m000","cntr.t","ZZZ")
stpapi.put.field("ticpr2210m000","citg.f","")
stpapi.put.field("ticpr2210m000","citg.t","ZZZZZZ")
stpapi.put.field("ticpr2210m000","calc.cd","CPC")
stpapi.put.field("ticpr2210m000","calc.date",str$(date.num()))
stpapi.put.field("ticpr2210m000","calc.meth",str$(etol(tcccmt.top.down)))
stpapi.put.field("ticpr2210m000","actualize.copr",str$(etol(tcyesno.yes)))
spool.device = "D66"
stpapi.set.report("ticpr2210m000","rticpr221001000",spool.device,msg)
stpapi.continue.process("ticpr2210m000",msg)
message("mess:%s",msg)
stpapi.end.session("ticpr2210m000")

What I did not do was check to see if the session actually updated cost prices.

Gagandeep
21st March 2012, 14:41
Thanks a lot Mark.
My code is quite similar.


declaration:
#pragma used dll ottstpapihand

#define CALC.COST "ticpr2210m000"
#define COST.RPRT "rticpr221001000"

table tticpr300 | Standard Cost Price by Item
table ttiitm001 | Items
table tticpr010 | Cost Price Components


extern domain tcitem item.f fixed
extern domain tccpcc cpcc.f
extern domain tcyesno update
extern domain tcmcs.str50 rprt_log, error, error.recv

| #include <bic_tt>
|****************************** form section **********************************

form.1:
init.form:
get.screen.defaults()

|****************************** choice section ********************************

choice.cont.process:
on.choice:
read.main.table()


|****************************** field section *********************************
|****************************** function section ******************************

functions:

function read.main.table()
{
rprt_log = creat.tmp.file$(bse.tmp.dir$())
error = ""

stpapi.put.field(CALC.COST,"item.f",item.f)
stpapi.put.field(CALC.COST,"item.t",item.f)
stpapi.put.field(CALC.COST,"cntr.f","")
stpapi.put.field(CALC.COST,"cntr.t","ZZZ")
stpapi.put.field(CALC.COST,"citg.f","")
stpapi.put.field(CALC.COST,"citg.t","ZZZZZZ")
stpapi.put.field(CALC.COST,"calc.cd",cpcc.f)
stpapi.put.field(CALC.COST,"calc.meth",str$(etol(tcccmt.top.down)))
stpapi.put.field(CALC.COST,"calc.date",str$(date.num()))
stpapi.put.field(CALC.COST,"actualize.copr",str$(etol(tcyesno.yes)))

stpapi.put.field(CALC.COST, "spool.fileout", rprt_log)
stpapi.set.report(CALC.COST,COST.RPRT,"ASCIF",error)
if isspace(error) then
stpapi.continue.process(CALC.COST, error)
else
stpapi.recover(CALC.COST, error.recv)
endif
stpapi.end.session(CALC.COST)

if not isspace(error) then
message("%s", error)
endif

if not isspace(error.recv) then
message("%s", error.recv)
endif
}

Unfortunately, both codes do not update standard cost. However, as suggested by you in another thread, ticpr2220m000 can be used by AFS.

We are running Baan IV Sp30