Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
38%
Installation Wizard into new VRC
41%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 37

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 16th January 2012, 18:57
simona simona is offline
Member
 
Join Date: Jun 2006
Posts: 84
simona is on a distinguished road
Baan: IV, V, VI - DB: Microsoft SQL Server - OS: windows XP
DAL big problem - doesn't insert in tirou102
Baan: ERP LN 6.1 FP5
C/S: None/Unknown

Hello,

I have a problem and I don't know how to handle it. I hope you can help...

My DAL script for table tiitc102, when updating a line, should insert/update/delete also in tirou102. But it doesn't... only sometimes (~2 times from 10). I attached the script.

I debugged the dal script and my function after.save.object() is executing... but not writing in tirou102.
Could you please advise? Thank you!

Kind regards,
Simona

Code:
|*************************************************************
|* tiitc102  0  VRC B61U l  rom 
|* dal tiitc102
|* diciu
|* 10-02-01 [11:20]
|*************************************************************
|* Script Type: DAL
|*************************************************************
                   
#include <bic_dal2>
#include <bic_text>


function extern long before.open.object.set()
{
	return(0)
}

function extern long after.save.object(long type)
{
	table	ttirou102, ttiitc102
	long ret
	
	if type = DAL_NEW then
		select	tirou102.*
		from	tirou102 |||for update
		where	tirou102._index1 = {:tiitc102.mitm, :tiitc102.opro, :tiitc102.opno, :tiitc102.seqn}
		selectempty
		
			|dal.new.object  ("tirou102")

			tirou102.mitm = tiitc102.mitm
			tirou102.opro = tiitc102.opro
			tirou102.opno = tiitc102.opno
			tirou102.seqn = tiitc102.seqn
			tirou102.tano=tiitc102.tano
			tirou102.cwoc=tiitc102.cwoc
			tirou102.mcno=tiitc102.mcno
			tirou102.sutm=tiitc102.sutm
			tirou102.rutm=tiitc102.rutm
			tirou102.mcoc=tiitc102.mcoc
			tirou102.subr=0
			tirou102.suba=""
			tirou102.whsa=""
			if tiitc102.rutm <> 0.0 then
				tirou102.prte=60/tiitc102.rutm
			else
				tirou102.prte=0
			endif
			tirou102.indt=tiitc102.indt
			tirou102.exdt=tiitc102.exdt
			tirou102.efco=""
			tirou102.exco=""
			tirou102.bfls=tiitc102.bfls
			tirou102.cont=""
			tirou102.crem=""
			tirou102.qpnt=0
			tirou102.nnts=0
			tirou102.desn=""
			tirou102.copo=tiitc102.copo
			tirou102.scpq=0
			tirou102.ploc=""
			tirou102.ydtp=tiydtp.not.applicable
			tirou102.yldp=100
			tirou102.stcf=tcyesno.yes
			tirou102.unef=tcyesno.no
			tirou102.exin=""
			tirou102.fxsu=0
			tirou102.fdur=tcyesno.no
			tirou102.tlyn=tcyesno.no
			tirou102.trls=0
			tirou102.most=tiitc102.most
			tirou102.mopr=tiitc102.mopr
			tirou102.cact=""
			tirou102.tuni=tctope.days
			tirou102.qutm=0
			tirou102.trdl=0
			tirou102.mvtm=0
			tirou102.dmso=tcyesno.no
			
			dal.new("tirou102", ttirou102, e, true, db.retry)
			
		endselect	
	endif
	
	if type = DAL_UPDATE then
		select	tirou102.*
		from	tirou102 for update
		where	tirou102._index1 = {:tiitc102.mitm, :tiitc102.opro, :tiitc102.opno, :tiitc102.seqn}
		selectdo
			tirou102.tano=tiitc102.tano
			tirou102.cwoc=tiitc102.cwoc
			tirou102.mcno=tiitc102.mcno
			tirou102.sutm=tiitc102.sutm
			tirou102.rutm=tiitc102.rutm
			tirou102.mcoc=tiitc102.mcoc
			tirou102.subr=0
			tirou102.suba=""
			tirou102.whsa=""
			if tiitc102.rutm <> 0.0 then
				tirou102.prte=60/tiitc102.rutm
			else
				tirou102.prte=0
			endif
			tirou102.indt=tiitc102.indt
			tirou102.exdt=tiitc102.exdt
			tirou102.efco=""
			tirou102.exco=""
			tirou102.bfls=tiitc102.bfls
			tirou102.cont=""
			tirou102.crem=""
			tirou102.qpnt=0
			tirou102.nnts=0
			tirou102.desn=""
			tirou102.copo=tiitc102.copo
			tirou102.scpq=0
			tirou102.ploc=""
			tirou102.ydtp=tiydtp.not.applicable
			tirou102.yldp=100
			tirou102.stcf=tcyesno.yes
			tirou102.unef=tcyesno.no
			tirou102.exin=""
			tirou102.fxsu=0
			tirou102.fdur=tcyesno.no
			tirou102.tlyn=tcyesno.no
			tirou102.trls=0
			tirou102.most=tiitc102.most
			tirou102.mopr=tiitc102.mopr
			tirou102.cact=""
			tirou102.tuni=tctope.days
			tirou102.qutm=0
			tirou102.trdl=0
			tirou102.mvtm=0
			tirou102.dmso=tcyesno.no
			
			|||ret=TEXT.COPY("tirou102.txta", "tiitc102.txtb", "", "", "", "", "", "")

			dal.update("tirou102", ttirou102, e, false, db.retry)
		endselect
	endif
	
	return(0)
}


|simona:
function extern long before.destroy.object()
{
	long ret
	select	tirou102.*
	from	tirou102 for update
	where	tirou102._index1 = {:tiitc102.mitm, :tiitc102.opro, :tiitc102.opno, :tiitc102.seqn}
	selectdo   
		|||ret=text.delete("tirou102.txta", "")

		dal.destroy("tirou102", ttirou102, e, false, db.retry)
	endselect
	return(0)
}





function extern long after.get.object(long dir)
{
	return(0)
}

function extern long before.get.object(long dir)
{
	return(0)
}

function extern long after.change.object  ()
{
return(0)

}

function extern after.commit.transaction  ()
{
long r
r=2

}

function extern long after.new.object  ()
{
return(0)
}

function extern long before.change.object  ()
{
return(0)
}


function extern long before.new.object()
{
    | The DAL now knows that a new record is about to be created.
    return(0)
}


function extern long before.save.object(long mode)
{
long r
   if mode = DAL_NEW then
        | this is code from before.write subsection
       r=2   

    else
        | this is code from before.rewrite subsection
      r=2   

    endif
    return(0)
}

Last edited by mark_h : 19th January 2012 at 17:45. Reason: Add code tags instead of quote
Reply With Quote
  #2  
Old 17th January 2012, 08:06
v_kewl v_kewl is offline
Member
 
Join Date: Dec 2008
Posts: 49
v_kewl is on a distinguished road
Baan: LN 6.1 - DB: MS SQL - OS: Windows 2003
Hi Simona,

What is the error code you are getting ? And just a suggestion as you have included <bic_dal2> it will be better if you use "dal.new.object" followed by field value assignment then "dal.save.object" in case of DAL_NEW and for DAL_UPDATE you can use initially "dal.change.object" followed by field value assignment then "dal.save.object".

Regards,
Gaurav
Reply With Quote
  #3  
Old 17th January 2012, 18:53
ipineda's Avatar
ipineda ipineda is offline
Member
 
Join Date: Aug 2008
Posts: 38
ipineda is on a distinguished road
Baan: BaaN V, LN - DB: Oracle - OS: Unix, Windows
Hi simona,

You have the following errors:

1. You have to assign the values of tirou102 with DAL function dal.set.field().
2. I suggest you to replace:
dal.new() --> dal.new.object()
dal.update() --> dal.change.object()
dal.destroy() --> dal.destroy.object()
This is because these ones are new versions of the ones you are using.
3. Don´t delete the tirou102 record form before.destroy.object(), instead use after.destroy.object() hook.


Here i suggest you how the code should look like:

Code:
function extern long after.save.object(long type)
{
	if type = DAL_NEW then
		dummy.ret = dal.new.object("tirou102")
		
		dal.set.field("tirou102.field1", value)
		dal.set.field("tirou102.field2", value)
		...
		
		dummy.ret = dal.save.object("tirou102")
	endif
	
	if type = DAL_UPDATE then
		select	tirou102.*
		from	tirou102 for update
		where	.....
		selectdo
			dummy.ret = dal.change.object("tirou102")
			
			dal.set.field("tirou102.field1", value)
			dal.set.field("tirou102.field2", value)
			...
			
			dummy.ret = dal.save.object("tirou102")
		endselect
	endif
}
function extern long afer.destroy.object()
{
	select	tirou102.*
	from	tirou102 for update
	where	.....
	selectdo
		dummy.ret = dal.destroy.object("tirou102")
	endselect
}

Also remember that errors may occur so it is a good idea to see if DAL is giving you messages, you can do it with dal.get.error.message().

I hope this information will help you.
Reply With Quote
  #4  
Old 17th January 2012, 19:10
vahdani's Avatar
vahdani vahdani is offline
Guru
 
Join Date: Aug 2002
Location: Cologne, Germany
Posts: 418
vahdani is on a distinguished road
Baan: all - DB: all - OS: Unix / Win2K
Use Dal 2

Hi,

if I'm right you are on LN. Then you should use the beautiful DAL2 methods.

Here is the script as it should be

Code:
extern long after.save.object(long type)
{
	table ttirou102, ttiitc102
	long ret

	ret = 0
	if type = DAL_NEW then
		select	tirou102.*
		from	tirou102
		where	tirou102._index1 = {:tiitc102.mitm, :tiitc102.opro, :tiitc102.opno, :tiitc102.seqn}
		selectempty
			dal.new.object ("tirou102")
			dal.set.field("tirou102.mitm", tiitc102.mitm)
			dal.set.field("tirou102.opro", tiitc102.opro)
			dal.set.field("tirou102.opno", tiitc102.opno)
			dal.set.field("tirou102.seqn", tiitc102.seqn)
			set.tirou102.fields()
			ret = dal.save.object("tirou102")
		endselect 
	endif

	if type = DAL_UPDATE then
		select tirou102.*
		from tirou102 for update
		where tirou102._index1 = {:tiitc102.mitm, :tiitc102.opro, :tiitc102.opno, :tiitc102.seqn}
		selectdo
			dal.change.object("tirou102")
			set.tirou102.fields()
			ret = dal.save.object("tirou102")
		endselect 
	endif			

	return(ret)	|return dal.save.object result!!!
}

function set.tirou102.fields()
{
	dal.set.field("tirou102.tano", tiitc102.tano)
	dal.set.field("tirou102.cwoc", tiitc102.cwoc)
	dal.set.field("tirou102.mcno", tiitc102.mcno)
	dal.set.field("tirou102.sutm", tiitc102.sutm)
	dal.set.field("tirou102.rutm", tiitc102.rutm)
	dal.set.field("tirou102.mcoc", tiitc102.mcoc)
	if tiitc102.rutm <> 0.0 then
		|this may be calculated in DAL so comment it out
		dal.set.field("tirou102.prte", 60/tiitc102.rutm)
	endif
	dal.set.field("tirou102.indt", tiitc102.indt)
	dal.set.field("tirou102.exdt", tiitc102.exdt)
	dal.set.field("tirou102.bfls", tiitc102.bfls)
	dal.set.field("tirou102.copo", tiitc102.copo)
	dal.set.field("tirou102.ydtp", tiydtp.not.applicable)
	dal.set.field("tirou102.yldp", 100)
	dal.set.field("tirou102.stcf", tcyesno.yes)
	dal.set.field("tirou102.unef", tcyesno.no)
	dal.set.field("tirou102.fdur", tcyesno.no)
	dal.set.field("tirou102.tlyn", tcyesno.no)
	dal.set.field("tirou102.most", tiitc102.most)
	dal.set.field("tirou102.mopr", tiitc102.mopr)
	dal.set.field("tirou102.tuni", tctope.days)
	dal.set.field("tirou102.dmso", tcyesno.no)
}
__________________
May the force be with you!
Reply With Quote
Sponsored Links
  #5  
Old 19th January 2012, 14:50
simona simona is offline
Member
 
Join Date: Jun 2006
Posts: 84
simona is on a distinguished road
Baan: IV, V, VI - DB: Microsoft SQL Server - OS: windows XP
It's working!! Thanks!!!!!

Hi,

Replacing old functions with the new ones and making from type Dal to Dal2 solved my problems.

Thank you everybody!

Sim
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Big problem script with Informix and Oracle gget79 Tools Development 9 24th September 2011 03:03
Big problem with an Batchjob h3nke82 Tools Administration & Installation 1 18th October 2008 11:23
new table record insert problem tina.guntner Tools Development 32 14th January 2003 20:37
BIG problem with printing pjohns Tools Administration & Installation 3 31st May 2002 20:15


All times are GMT +2. The time now is 15:45.


©2001-2017 - Baanboard.com - Baanforums.com