mstockre
2nd December 2004, 00:26
Im trying to use AFS to add sales orders into baan. Im currently getting an error in the AFS log: "Cost price structure not present for this date" . Session ticpr2210m00 cost is set for dates. For the item in question, the information is completely. You can manually run the session tdsls4101m000 then tdsls410s000 and the sales order for the item will enter, but not if I try through AFS. Im new to AFS so any help as to what I could be doing wrong would be appreciated.

Here is our coding:

Varibles in the stpapi.put statements are define as string with a value defind.

|************************************************************************************
function run.main.sess()
{
|*** This function invokes session tdsls04101m000

|************fields from the file*********************


stpapi.put.field("tdsls4101m001", "tdsls040.eono", eono)
|stpapi.put.field("tdsls4101m001", "tdsls040.odat", str$(odat))
|stpapi.put.field("tdsls4101m001", "tdsls040.prdt", str$(ddat))

|*************fields from varibles********************

stpapi.put.field("tdsls4101m001", "tdsls040.cuno", cuno)
stpapi.put.field("tdsls4101m001", "tdsls040.crep", crep)

write.err.record()

if all.ok then

stpapi.insert("tdsls4101m001",1,err)
stpapi.save("tdsls4101m001",err)
run.sub.sess()
endif
stpapi.end.session("tdsls4101m001")

if all.ok then
rec.writ = rec.writ + 1
else
rec.rej = rec.rej + 1
endif


}

function run.sub.sess()
{
|*** This function invokes sub-session tdsls4102s000 and updates the
|*** quantity field

stpapi.handle.subproc( "tdsls4101m001", "tdsls4102s001", "add")

if strip$(err) = "" then

stpapi.put.field("tdsls4102s001", "tdsls041.cuno",cuno)
stpapi.put.field("tdsls4102s001", "tdsls041.eseq",eseq)
stpapi.put.field("tdsls4102s001", "tdsls041.item", item)

||stpapi.put.field("tdsls4102s001", "tdsls041.citt",citt)
||stpapi.put.field("tdsls4102s001", "tdsls041.opol",opol)



stpapi.insert("tdsls4102s001",1,err)
stpapi.save("tdsls4102s001",err)
if strip$(err) <> "" then
write.err.record()
if strip$(err) <> "" then
write.err.record()
endif
else
write.err.record()
endif

stpapi.end.session("tdsls4102s001")
stpapi.handle.subproc( "tdsls4101m001", "tdsls4102s001", "kill")

Thank you,

Marianne

kathuria
2nd December 2004, 07:23
Dear Marianne,


I adding three more lines in your afs script. Ity will definatily solve your problem , because few days back i was facing same problem.


Sanjay



stpapi.handle.subproc( "tdsls4101m001", "tdsls4102s001", "add")

if strip$(err) = "" then

stpapi.put.field("tdsls4102s001", "tdsls041.cuno",cuno)
stpapi.put.field("tdsls4102s001", "tdsls041.eseq",eseq)
stpapi.put.field("tdsls4102s001", "tdsls041.item", item)


|************************Additional Lines*********
|**************Define date in declaration section
date = date.num()
stpapi.put.field("tdsls4102s001","tdsls041.ddta",str$(date))
stpapi.put.field("tdsls4102s001", "tdsls041.odat", str$(date))
stpapi.put.field("tdsls4102s001", "tdsls041.prdt", str$(date))

|*****************************************




||stpapi.put.field("tdsls4102s001", "tdsls041.citt",citt)
||stpapi.put.field("tdsls4102s001", "tdsls041.opol",opol)



stpapi.insert("tdsls4102s001",1,err)
stpapi.save("tdsls4102s001",err)

mstockre
6th December 2004, 17:00
Thank you for your guidance on the date formate. I have changed my dates to the following format below. Im getting an error "receipt date cant before delivery date" and "delivery date cant before receipt date". The actual dates check out fine in the debugger. I think my date format is still wrong so the dates cant import into the session causing these error. Any suggestion on date formats would be greatly appreciated.


order date and delivery date are coming from a file in the format 12/03/04.
del.date

string deldate(6)
string orderdate(6)
string recdate(6)

domain tcdate del.date
domain tcdate order.date
domain tcdate rec.date



curr1.mm = ddat(1;2)
curr1.dd = ddat(4;2)
curr1.yy = ddat(7;2)

deldate = (curr1.mm&curr1.dd&curr1.yy)
del.date = INPUTSTR.TO.DATE(deldate,"%D002")
deldate=date.to.inputstr$( del.date, "%D002",6)


|********get our order and rec dates.
curr.mm = odat(1;2)
curr.dd = odat(4;2)
curr.yy = odat(7;2)

orderdate =(curr.mm&curr.dd&curr.yy)
order.date = inputstr.to.date(orderdate,"%D002")

rec.date = (del.date + 1)
orderdate=date.to.inputstr$( order.date, "%D002",6)
recdate=date.to.inputstr$( rec.date, "%D002",6)

|del.date = INPUTSTR.TO.DATE(ddat,"%D002,2")
|order.date = INPUTSTR.TO.DATE(odat,"%D002,2")
|rec.date = INPUTSTR.TO.DATE(odat,"%D002,2")


Thanks,
Marianne

mark_h
6th December 2004, 17:52
I use something like this when reading dates:

num.day = val(read.date(4;2))
num.month = val(read.date(1;2))
num.year = val(read.date(7;4))
adj.date = date.to.num(num.year, num.month, num.day)

In my case the date comes in as 12/23/2004. You could probably write a routine for two digit years, but I recommend using 4 digit years since we are still so close to 1999.

Mark