jatin_sanghi
17th February 2005, 11:43
Hi All,

i'am trying to create an AFS script for uploading the purchase orders.
i'am able to get through the header ( tdpur4101m000) , but in purchase order lines ( tdpur4105s000) the session hangs at the end.session for lines.

Also i'am trying to have multiple entries in lines for a single order, pertaing to a supplier. Please help m in solving these two issues.

My script follow as below..:


|******************************************************************************
|* tdjub9918mpol 0 VRC B40C c4 jol
|* Upload purchase orders
|* Vivek Bhatt
|* 2005-02-17
|******************************************************************************
|* Main table tdjub906 Preffered supplier by item, Form Type 4
|******************************************************************************
|****************************** declaration section ***************************

declaration:

#pragma nowarnings
#pragma used dll ottstpapihand

table ttdjub906 | Preffered supplier by item
table ttccom020
table ttdpur040



extern domain tcitem item.f
extern domain tcitem item.t
extern domain tcsuno suno.f
extern domain tcsuno suno.t
string errmsg(80)

|****************************** form section **********************************
form.1:
init.form:
get.screen.defaults()

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



choice.cont.process:
on.choice:
read.main.table()
| execute(print.data)



choice.print.data:
on.choice:
if rprt_open() then
read.main.table()
rprt_close()
else
choice.again()
endif


|****************************** field section *********************************
field.item.f:
when.field.changes:
item.t = item.f


field.suno.f:
when.field.changes:
suno.t = suno.f

|****************************** function section ******************************
functions:
function read.main.table()
{

select tccom020.*
from tccom020
where tccom020._index1 inrange {:suno.f}
and {:suno.t}
order by tccom020._index1
selectdo
insert_order()
| rprt_send()
endselect

}
function void insert_order()
{
stpapi.put.field("tdpur4101m000", "tdpur040.orno", "19")
stpapi.put.field("tdpur4101m000", "tdpur040.suno", str$(tccom020.suno))
stpapi.put.field("tdpur4101m000", "tdpur040.cotp", "HOT")
stpapi.put.field("tdpur4101m000", "tdpur040.comp", "999")
stpapi.put.field("tdpur4101m000", "tdpur040.odat", str$(date.num()))
stpapi.handle.subproc("tdpur4101m000", "tdpurl102s002", "add")
stpapi.insert("tdpurl102s002", true, errmsg)
stpapi.end.session("tdpurl102s002")
stpapi.put.field("tdpur4101m000", "tdpur040.ddat", str$(date.num()))
stpapi.insert("tdpur4101m000",true,errmsg)
stpapi.handle.subproc("tdpur4101m000", "tdpur4105s000", "add")
stpapi.continue.process("tdpur4101m000",errmsg)


select tdjub906.*
from tdjub906
where tdjub906._index1 inrange {:item.f, :tccom020.suno}
and {:item.t, :tccom020.suno}
selectdo

stpapi.put.field("tdpur4105s000","tdpur041.item", tdjub906.item) |" RITE")
stpapi.put.field("tdpur4105s000","tdpur041.cwar","CWH")
stpapi.put.field("tdpur4105s000","tdpur041.oqua",str$(tdjub906.oqty))
stpapi.handle.subproc("tdpur4105s000", "tdind0271s000", "add")
stpapi.put.field("tdind0271s000", "tdind020.exci", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.svyn", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.ocyn", str$(etol(tcyesno.no)))
stpapi.insert("tdind0271s000", true, errmsg)
stpapi.end.session("tdind0271s000")
stpapi.insert("tdpur4105s000", true, errmsg)
endselect
stpapi.end.session("tdpur4105s000")
stpapi.end.session("tdpur4101m000")

}

mark_h
17th February 2005, 18:18
Not familiar with these sessions, but I did find this post (http://www.baanboard.com/baanboard/showthread.php?t=15558&highlight=tdind0271s000).

Mark