maclezhang
19th November 2007, 09:26
We try to use AFS to develop some sessions to reduce the data inputting labour .
we wish to add salse order ,production order automatically from a middle table defined by ourself .
we import the data into middle table ,and let AFS to add records automatically into baan standard tables . we meet some errors .For sales order ,if we put values for all fields in the form ,AFS can add new records ,but the order quantity changed to Zero,but the amount is correct. if we only put value for order quantity,the records cannot be added . for production order ,afs cannot add new records , but can modify existed records .
please refer the attached program .

afs-sales-order

|******************************************************************************
|* tdsls0241 0 VRC B61C a gr
|*|******************************************************************************
|* Main table tdsls041 ? Form Type 4
|******************************************************************************

|****************************** declaration section ***************************

declaration:


table ttdsls400
table ttdsls401


#pragma used dll "otdsls4100m000f"
#pragma used dll "otdsls4100m900f"
#pragma used dll "otdsls4101m000f"
#pragma used dll "otdsls4101mt00f"
#pragma used dll "ottstpapihand"






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


choice.cont.process:
on.choice:
insert_tdsls401()


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

functions:


function insert_tdsls401()
{
long ret,retval1
string error
stpapi.put.field("tdsls4101mt00","tdsls401.orno","210000001")
stpapi.put.field("tdsls4101mt00","tdsls401.pono","50")
ret=stpapi.find("tdsls4101mt00")
if not ret=1 then
stpapi.put.field("tdsls4101mt00","tdsls401.orno","210000001")
ret=stpapi.find("tdsls4101mt00")
if ret=1 then
ret=stpapi.synchronize.dialog("tdsls4101mt00","add",error)
if ret=1 then
stpapi.put.field("tdsls4101m000","tdsls401.orno","210000001")
stpapi.put.field("tdsls4101m000","tdsls401.pono","50")
stpapi.put.field("tdsls4101m000","tdsls401.citt","CKB")
stpapi.put.field("tdsls4101m000","tform.aitc","")
stpapi.put.field("tdsls4101m000","tdsls401.item.segment.2","KA02300321")
stpapi.put.field("tdsls4101m000","tdsls401.sdsc","1")
stpapi.put.field("tdsls4101m000","tdsls401.effn","0")
stpapi.put.field("tdsls4101m000","tdsls401.dltp","15")
stpapi.put.field("tdsls4101m000","tdsls401.cwar","500")
stpapi.put.field("tdsls4101m000","tdsls401.qoor","10")
stpapi.put.field("tdsls4101m000","tdsls401.cprj","")
stpapi.put.field("tdsls4101m000","tdsls401.opol","2")
stpapi.put.field("tdsls4101m000","tdsls401.cuqs","SET")
stpapi.put.field("tdsls4101m000","tdsls401.qohb","0")
stpapi.put.field("tdsls4101m000","tdsls401.pric","1")
stpapi.put.field("tdsls4101m000","tdsls401.oamt","10")
retval1=stpapi.insert("tdsls4101m000",true,error)
endif
if not retval1 then
retval1=stpapi.recover("tdsls4101m000",error)
endif
endif
stpapi.end.session("tdsls4101mt00")
commit.transaction()
endif
}



afs-production-order
declaration:

table ttisfc001

#pragma used dll "ottstpapihand"
#pragma used dll "otisfc0501mt00f"
#pragma used dll "otisfc0101s000f"

|****************************** group section **********************************


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

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


functions:

function read.main.table()
{

long ret,retval1
string error
ret=stpapi.find("tisfc0501mt00")
ret=stpapi.synchronize.dialog("tisfc0501mt00","add",error)
if ret=1 then
stpapi.put.field("tisfc0101s000","tisfc001.pdno","201")
stpapi.put.field("tisfc0101s000","tisfc001.mitm.segment.2","CC04000010")
stpapi.put.field("tisfc0101s000","tisfc001.qrdr","1")
stpapi.form.command( "tisfc0101s000", 5, "default.qty", error )
stpapi.put.field("tisfc0101s000","tisfc001.cpla","1")
stpapi.put.field("tisfc0101s000","tisfc001.prdt",str$(utc.num()+10))
stpapi.put.field("tisfc0101s000","tisfc001.rdld",str$(utc.num()+7200))
stpapi.put.field("tisfc0101s000","tisfc001.efdt",str$(utc.num()))
stpapi.put.field("tisfc0101s000","tisfc001.cwar","500")
stpapi.put.field("tisfc0101s000","tisfc001.opro"," 23")
|stpapi.put.field("tisfc0101s000","tisfc001.pldt",str$(utc.num()))
retval1=stpapi.insert("tisfc0101mt00",true,error)
if not retval1 then
retval1=stpapi.recover("tisfc0101mt00",error)
endif
endif
stpapi.end.session("tisfc0101mt00")
commit.transaction()
message("End")
}

mark_h
19th November 2007, 14:29
Under LN (based on your profile) it seems that most people use the DAL functionality instead AFS. Search this forum and you will find plenty of threads with code - such as this one here (http://www.baanboard.com/baanboard/showthread.php?t=28812&highlight=tdsls4100m900).

maclezhang
20th November 2007, 02:39
thanks mark
we are trying the dal mode