View Single Post
  #6  
Old 17th November 2007, 00:13
kathuria's Avatar
kathuria kathuria is offline
Senior Member
 
Join Date: May 2004
Posts: 134
kathuria is on a distinguished road
Baan: BaaN IV, BaaN V, SSA ERP LN6.1(BaaN VI) - DB: SQL , Oracle - OS: UNIX, WIndow Server 2000/2003
Create PO & LINes by DAL

Hi,

DAL Script to Create Purchase Order and Lines.

Code:
********* Header**********************
	dal.new.object("tdpur400")
	dal.set.field("tdpur400.orno", s.orno)
	dal.set.field("tdpur400.otbp", s.bpid)
	dal.set.field("tdpur400.ptbp", s.bpid)
	dal.set.field("tdpur400.cotp", s.cotp)
	dal.set.field("tdpur400.cofc", s.cofc)
	dal.set.field("tdpur400.ccur", s.ccur)
	dal.set.field("tdpur400.odat", s.odat)
	dal.set.field("tdpur400.ddat", s.odat)
	dal.set.field("tdpur400.sbim", s.sbim)
	dal.set.field("tdpur400.refa", s.refa)
	dal.set.field("tdpur400.refb", s.refb)
	dal.set.field("tdpur400.sorn", s.sorn)

	if not isspace(s.cpay) then
		dal.set.field("tdpur400.cpay", s.cpay)
	endif
ret = dal.save.object("tdpur400")
	if (ret < 0) or (len(tdpur400.orno) <> 9) then
		ret = dal.get.error.message(w.err.msg)
		test.str = "Error in Purchase Order Header"
		error.file.generation(s.trid,s.seqn)
		message("Error......!%s", w.err.msg)
	else
		commit.transaction()
	endif

|************************Lines********************
		dal.new.object("tdpur401")
		dal.set.field("tdpur401.orno", l.orno)
		dal.set.field("tdpur401.item", l.item)
		dal.set.field("tdpur401.qoor", l.qoor)
		dal.set.field("tdpur401.cuqp", l.cuni)
		dal.set.field("tdpur401.cwar", l.cwar)

		if (tdpur401.pric = 0) and (l.pric <> 0) then
			dal.set.field("tdpur401.pric", l.pric)

			if l.pric<>0 then
				dal.set.field("tdpur401.porg",tdgen.porg.manual)
			endif
		endif

		if l.pric = 0 then
			dal.set.field("tdpur401.oamt", round(l.oamt, 4, 1))
		endif

		if not isspace(l.cprj) then
			dal.set.field("tdpur401.cprj", l.cprj)
		endif

		if l.pric = 0 then
			dal.set.field("tdpur401.oamt", round(l.oamt, 4, 1))
		endif

		ret = dal.save.object("tdpur401", db.return.error)

		if (ret >= 0) and (tdpur401.pono <> 0) then
			commit.transaction()
		else
			ret=dal.get.error.message(w.err.msg)
			test.str = "Error in Purchase Order Lines"
			error.file.generation(s.trid,s.seqn)
			message("Error......!%s", w.err.msg)
		endif
	endif
}
Regards,
Sanjay Kathuria
Reply With Quote