Baanboard.com

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

User login

Frontpage Sponsor

Main

Google search


Poll
How big is your Baan-DB (just Data AND Indexes)
0 - 200 GB
14%
200 - 500 GB
32%
500 - 800 GB
4%
800 - 1200 GB
4%
1200 - 1500 GB
11%
1500 - 2000 GB
14%
> 2000 GB
21%
Total votes: 28

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 9th August 2018, 11:10
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Function 'reloop':recursion not possible; refcount=2
Baan: ERP LN 6.1 FP11 (Infor ERP 10.5)
C/S: None/Unknown

Hi,

I have a problem on my customization session. I do a reloop function on my script but when second reloop same function then prompt the message "Function 'reloop": recursion not possible; refcount = 2". Is it cannot reloop same function? My code as below. Please advise. Thanks.

Code:
function calculation.bar()
{	
	domain tclgth  	abc,def
	domain tcpono	posi
	abc = 1
	def = 6100
	posi = 10
	test.reloop(abc, def, posi)
}

function test.reloop(domain tclgth countlongbar, domain tclgth longbarlength, domain tcpono position)
{
	domain tclgth	test.countlongbar, test.longbarlength
	domain	tcpono	posi

	test.countlongbar = countlongbar + 1 
	test.longbarlength = longbarlength +1
	posi = position + 1
	
	test.reloop(test.countlongbar, test.longbarlength, posi)
}
Reply With Quote
  #2  
Old 9th August 2018, 12:06
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 104
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
From here:
Quote:
It is possible to use recursive function calls. This means that in a function block a call to the same function is used. However, this is currently implemented only for functions without local variables and arguments.
Never really needed recursion in LN but this is kinda shabby
Reply With Quote
  #3  
Old 10th August 2018, 03:54
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by giggty View Post
From here:

Never really needed recursion in LN but this is kinda shabby
Thanks for your information. Then have any coding can work around it? Thanks.
Reply With Quote
  #4  
Old 10th August 2018, 08:24
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 104
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
Well, if you absolutely need recursion then you ought to use global variables. But in your particular case as far as I can see all you do is infinitely increment 3 variables (without even returning them). This better be done using simple for- or while-loop

Last edited by giggty : 10th August 2018 at 08:29.
Reply With Quote
  #5  
Old 10th August 2018, 08:43
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by giggty View Post
Well, if you absolutely need recursion then you ought to use global variables. But in your particular case as far as I can see all you do is infinitely increment 3 variables (without even returning them). This better be done using simple for- or while-loop
Thanks for your reply. How to use global variables? Actually my code is more completed than the above code. Please advise.
Reply With Quote
  #6  
Old 10th August 2018, 08:55
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 104
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
Instead of passing abc, def, posi as test.reloop arguments you need to declare them as global variables, then you initialize them before the first test.reloop() call and inside it you just increment abc, def, posi (without declaring local ones!).
Reply With Quote
  #7  
Old 10th August 2018, 09:13
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by giggty View Post
Instead of passing abc, def, posi as test.reloop arguments you need to declare them as global variables, then you initialize them before the first test.reloop() call and inside it you just increment abc, def, posi (without declaring local ones!).
My actual passing abc, def, posi is not increment value. It will have different value, so i want pass it back to same function to continue loop and get other value. Please advise.
Reply With Quote
  #8  
Old 10th August 2018, 09:29
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 104
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
New different values will get passed to the new layer of recursion, because those are global variables.
Post your actual may be?
Reply With Quote
Sponsored Links
  #9  
Old 10th August 2018, 09:46
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by giggty View Post
New different values will get passed to the new layer of recursion, because those are global variables.
Post your actual may be?
Hi,

my code as below.
Code:
|******************************************************************************
|* tccus0124m100  0  VRC B61C a  pmb 
|* Update Short Bar List
|* IS                                                                                                                                                                                                                                                                                                                                                                                                              
|* 2018-08-07
|******************************************************************************
|* Main table cprrp100 Planned Orders, Form Type 4
|******************************************************************************
                                                                                
|****************************** declaration section ***************************
declaration:
#include <bic_dam>

  	table   tcprrp100	| Planned Orders
	table	ttccus024	| Short Bar List
	table	ttibom010	| BOM
	table	ttccus025	| Cut List Calculation
  
   	extern  domain  cpcom.plnc	order.scenario
	extern  domain  tckoor          order.type
	extern	domain	cpitem		order.item
	extern	domain	cpcom.quan	order.qty
	extern	domain	tclgth		long.lgth, short.lgth
	extern	domain	tcitem		short.item, short.item.without.project
	extern	domain	tcsect		short.section
	extern	domain	tiqbm2		short.qty, total.bom.qty
	
	string	temp.txt(250), instr(1)
	long 	str.no, i, pos.1, ret


|****************************** program section ********************************
before.program:
	

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

|****************************** functions **************************************
Functions:

function extern upd.short.bar()
{	
	calculate.long.bar()
}

function calculate.long.bar()
{	
	domain tcpono	position
	long countg, countss, count.lgth, i2
	countg = 1
	countss = 0

	while countg <> 0
		countg = 0
		
		select count(tccus024.lgth):count.lgth
		from tccus024
		where tccus024.tqty > 0
		group by tccus024.sect
		selectdo
		endselect

		for i2 = 0 to (count.lgth - 1)
			countg = countg + 1
		endfor

		if (countg > 0) then

			position = 0
			countss = countss + 1

			reloop(countss, long.lgth, position)
		endif
	endwhile
}


function reloop(long countlongbar, domain tclgth longbarlength, domain tcpono position)
{
	domain	tcsect	ssection
	domain	tclgth	mmbalance, newquty, iw

	long slength, squty, allocatedqty
	long longs, temp, balance
	
		
	select tccus024.*
	from tccus024
	where tccus024.tqty > 0 and tccus024.lgth <= :longbarlength
	order by tccus024.lgth desc as set with 1 rows
	selectdo
	endselect

	ssection = tccus024.sect
	slength = tccus024.lgth
	squty = tccus024.tqty
	allocatedqty = tccus024.oqty
	position = position + 10

	mmbalance = 0			| use to store long bar balance
	longs = longbarlength		| assign long bar balance to a new variable longs

	iw = longs / slength		| use long bar balance to divide then we will get how many qty can produce

	temp = 0			| use to store the actual length of produce qty times short length

	balance = 0			| use to store if the short lgth still have balance qty after produce

	if (iw > squty) then
		balance = 0 				| set to zero
		newquty = squty				| set new qty = short lgth balance qty
		temp = slength * round(newquty,0,0)	| short lgth * new qty
		mmbalance = longs - temp		| current long bar balance - temp
		iw = newquty				| new short bar lgth able produce qty to new qty

	else
		balance = squty - round(iw,0,0)		| new short lgth balance qty
		temp = slength * round(iw,0,0)		| total produce short lgth
		mmbalance = longs - temp		| update long bar balance = current long bar balance - temp
	endif	

	|******* Update balance qty and temp total back to table **************
	select tccus024.*
	from tccus024 for update
	where tccus024.sect = :ssection and tccus024.lgth = :slength
	selectdo
		ret = dal.change.object("tccus024")
		
		dal.set.field("tccus024.sect", ssection)
		dal.set.field("tccus024.lgth", str$(slength))
		dal.set.field("tccus024.tqty", str$(balance))
				
		ret = dal.save.object("tccus024")
		commit.transaction()
	endselect
	
	|******* Insert Cut List Table **************
	select tccus025.*
	from tccus025 for update
	where tccus025.sect = :ssection |and tccus025.slen = :slength
	selectdo
		ret = dal.change.object("tccus025")
		
		dal.set.field("tccus025.sect", ssection)
		dal.set.field("tccus025.slen", str$(slength))
		dal.set.field("tccus025.csle", str$(round(iw,0,0)))
		dal.set.field("tccus025.clle", str$(countlongbar))
		dal.set.field("tccus025.lbal", str$(mmbalance))

		ret = dal.save.object("tccus025")
		commit.transaction()
	selectempty
		ret = dal.new.object("tccus025")
		
		dal.set.field("tccus025.pono", position)
		dal.set.field("tccus025.sect", ssection)
		dal.set.field("tccus025.slen", str$(slength))
		dal.set.field("tccus025.csle", str$(round(iw,0,0)))
		dal.set.field("tccus025.clle", str$(countlongbar))
		dal.set.field("tccus025.lbal", str$(mmbalance))
				
		ret = dal.save.object("tccus025")
		commit.transaction()	
	endselect

	if (mmbalance = 0) then
		stop()
	else
		reloop(countlongbar, mmbalance, position)
	endif
}

Please advise.

Last edited by tracylee : 10th August 2018 at 10:30.
Reply With Quote
  #10  
Old 10th August 2018, 10:26
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 104
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
Try something like this:
Code:
|******************************************************************************
|* tccus0124m100  0  VRC B61C a  pmb 
|* Update Short Bar List
|* IS                                                                                                                                                                                                                                                                                                                                                                                                              
|* 2018-08-07
|******************************************************************************
|* Main table cprrp100 Planned Orders, Form Type 4
|******************************************************************************
                                                                                
|****************************** declaration section ***************************
declaration:
#include <bic_dam>

  	table   tcprrp100	| Planned Orders
	table	ttccus024	| Short Bar List
	table	ttibom010	| BOM
	table	ttccus025	| Cut List Calculation
  
   	extern	domain	cpcom.plnc	order.scenario
	extern	domain	tckoor		order.type
	extern	domain	cpitem		order.item
	extern	domain	cpcom.quan	order.qty
	extern	domain	tclgth		long.lgth, short.lgth
	extern	domain	tcitem		short.item, short.item.without.project
	extern	domain	tcsect		short.section
	extern	domain	tiqbm2		short.qty, total.bom.qty
	
	string	temp.txt(250), instr(1)
	long 	str.no, i, pos.1, ret

	long	countlongbar
	domain	tclgth 	longbarlength
	domain 	tcpono	position

	domain	tcsect	ssection
	domain	tclgth	mmbalance, newquty, iw

	long	slength, squty, allocatedqty
	long	longs, temp, balance


|****************************** program section ********************************
before.program:
	

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

|****************************** functions **************************************
Functions:

function extern upd.short.bar()
{	
	calculate.long.bar()
}

function calculate.long.bar()
{	
	domain tcpono	position
	long countg, countss, count.lgth, i2
	countg = 1
	countlongbar = 0
	longbarlength = 0

	while countg <> 0
		countg = 0
		
		select count(tccus024.lgth):count.lgth
		from tccus024
		where tccus024.tqty > 0
		group by tccus024.sect
		selectdo
		endselect

		for i2 = 0 to (count.lgth - 1)
			countg = countg + 1
		endfor

		if (countg > 0) then

			position = 0
			countlongbar = countlongbar + 1

			reloop()
		endif
	endwhile
}


function reloop()
{
	select tccus024.*
	from tccus024
	where tccus024.tqty > 0 and tccus024.lgth <= :longbarlength
	order by tccus024.lgth desc as set with 1 rows
	selectdo
	endselect

	ssection = tccus024.sect
	slength = tccus024.lgth
	squty = tccus024.tqty
	allocatedqty = tccus024.oqty
	position = position + 10

	mmbalance = 0			| use to store long bar balance
	longs = longbarlength		| assign long bar balance to a new variable longs

	iw = longs / slength		| use long bar balance to divide then we will get how many qty can produce

	temp = 0			| use to store the actual length of produce qty times short length

	balance = 0			| use to store if the short lgth still have balance qty after produce

	if (iw > squty) then
		balance = 0 				| set to zero
		newquty = squty				| set new qty = short lgth balance qty
		temp = slength * round(newquty,0,0)	| short lgth * new qty
		mmbalance = longs - temp		| current long bar balance - temp
		iw = newquty				| new short bar lgth able produce qty to new qty

	else
		balance = squty - round(iw,0,0)		| new short lgth balance qty
		temp = slength * round(iw,0,0)		| total produce short lgth
		mmbalance = longs - temp		| update long bar balance = current long bar balance - temp
	endif	

	|******* Update balance qty and temp total back to table **************
	select tccus024.*
	from tccus024 for update
	where tccus024.sect = :ssection and tccus024.lgth = :slength
	selectdo
		ret = dal.change.object("tccus024")
		
		dal.set.field("tccus024.sect", ssection)
		dal.set.field("tccus024.lgth", str$(slength))
		dal.set.field("tccus024.tqty", str$(balance))
				
		ret = dal.save.object("tccus024")
		commit.transaction()
	endselect
	
	|******* Insert Cut List Table **************
	select tccus025.*
	from tccus025 for update
	where tccus025.sect = :ssection |and tccus025.slen = :slength
	selectdo
		ret = dal.change.object("tccus025")
		
		dal.set.field("tccus025.sect", ssection)
		dal.set.field("tccus025.slen", str$(slength))
		dal.set.field("tccus025.csle", str$(round(iw,0,0)))
		dal.set.field("tccus025.clle", str$(countlongbar))
		dal.set.field("tccus025.lbal", str$(mmbalance))

		ret = dal.save.object("tccus025")
		commit.transaction()
	selectempty
		ret = dal.new.object("tccus025")
		
		dal.set.field("tccus025.pono", position)
		dal.set.field("tccus025.sect", ssection)
		dal.set.field("tccus025.slen", str$(slength))
		dal.set.field("tccus025.csle", str$(round(iw,0,0)))
		dal.set.field("tccus025.clle", str$(countlongbar))
		dal.set.field("tccus025.lbal", str$(mmbalance))
				
		ret = dal.save.object("tccus025")
		commit.transaction()	
	endselect

	if (mmbalance = 0) then
		stop()
	else
		longbarlength = mmbalance
		reloop()
	endif
}
Reply With Quote
  #11  
Old 10th August 2018, 11:08
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by giggty View Post
Try something like this:
Code:
|******************************************************************************
|* tccus0124m100  0  VRC B61C a  pmb 
|* Update Short Bar List
|* IS                                                                                                                                                                                                                                                                                                                                                                                                              
|* 2018-08-07
|******************************************************************************
|* Main table cprrp100 Planned Orders, Form Type 4
|******************************************************************************
                                                                                
|****************************** declaration section ***************************
declaration:
#include <bic_dam>

  	table   tcprrp100	| Planned Orders
	table	ttccus024	| Short Bar List
	table	ttibom010	| BOM
	table	ttccus025	| Cut List Calculation
  
   	extern	domain	cpcom.plnc	order.scenario
	extern	domain	tckoor		order.type
	extern	domain	cpitem		order.item
	extern	domain	cpcom.quan	order.qty
	extern	domain	tclgth		long.lgth, short.lgth
	extern	domain	tcitem		short.item, short.item.without.project
	extern	domain	tcsect		short.section
	extern	domain	tiqbm2		short.qty, total.bom.qty
	
	string	temp.txt(250), instr(1)
	long 	str.no, i, pos.1, ret

	long	countlongbar
	domain	tclgth 	longbarlength
	domain 	tcpono	position

	domain	tcsect	ssection
	domain	tclgth	mmbalance, newquty, iw

	long	slength, squty, allocatedqty
	long	longs, temp, balance


|****************************** program section ********************************
before.program:
	

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

|****************************** functions **************************************
Functions:

function extern upd.short.bar()
{	
	calculate.long.bar()
}

function calculate.long.bar()
{	
	domain tcpono	position
	long countg, countss, count.lgth, i2
	countg = 1
	countlongbar = 0
	longbarlength = 0

	while countg <> 0
		countg = 0
		
		select count(tccus024.lgth):count.lgth
		from tccus024
		where tccus024.tqty > 0
		group by tccus024.sect
		selectdo
		endselect

		for i2 = 0 to (count.lgth - 1)
			countg = countg + 1
		endfor

		if (countg > 0) then

			position = 0
			countlongbar = countlongbar + 1

			reloop()
		endif
	endwhile
}


function reloop()
{
	select tccus024.*
	from tccus024
	where tccus024.tqty > 0 and tccus024.lgth <= :longbarlength
	order by tccus024.lgth desc as set with 1 rows
	selectdo
	endselect

	ssection = tccus024.sect
	slength = tccus024.lgth
	squty = tccus024.tqty
	allocatedqty = tccus024.oqty
	position = position + 10

	mmbalance = 0			| use to store long bar balance
	longs = longbarlength		| assign long bar balance to a new variable longs

	iw = longs / slength		| use long bar balance to divide then we will get how many qty can produce

	temp = 0			| use to store the actual length of produce qty times short length

	balance = 0			| use to store if the short lgth still have balance qty after produce

	if (iw > squty) then
		balance = 0 				| set to zero
		newquty = squty				| set new qty = short lgth balance qty
		temp = slength * round(newquty,0,0)	| short lgth * new qty
		mmbalance = longs - temp		| current long bar balance - temp
		iw = newquty				| new short bar lgth able produce qty to new qty

	else
		balance = squty - round(iw,0,0)		| new short lgth balance qty
		temp = slength * round(iw,0,0)		| total produce short lgth
		mmbalance = longs - temp		| update long bar balance = current long bar balance - temp
	endif	

	|******* Update balance qty and temp total back to table **************
	select tccus024.*
	from tccus024 for update
	where tccus024.sect = :ssection and tccus024.lgth = :slength
	selectdo
		ret = dal.change.object("tccus024")
		
		dal.set.field("tccus024.sect", ssection)
		dal.set.field("tccus024.lgth", str$(slength))
		dal.set.field("tccus024.tqty", str$(balance))
				
		ret = dal.save.object("tccus024")
		commit.transaction()
	endselect
	
	|******* Insert Cut List Table **************
	select tccus025.*
	from tccus025 for update
	where tccus025.sect = :ssection |and tccus025.slen = :slength
	selectdo
		ret = dal.change.object("tccus025")
		
		dal.set.field("tccus025.sect", ssection)
		dal.set.field("tccus025.slen", str$(slength))
		dal.set.field("tccus025.csle", str$(round(iw,0,0)))
		dal.set.field("tccus025.clle", str$(countlongbar))
		dal.set.field("tccus025.lbal", str$(mmbalance))

		ret = dal.save.object("tccus025")
		commit.transaction()
	selectempty
		ret = dal.new.object("tccus025")
		
		dal.set.field("tccus025.pono", position)
		dal.set.field("tccus025.sect", ssection)
		dal.set.field("tccus025.slen", str$(slength))
		dal.set.field("tccus025.csle", str$(round(iw,0,0)))
		dal.set.field("tccus025.clle", str$(countlongbar))
		dal.set.field("tccus025.lbal", str$(mmbalance))
				
		ret = dal.save.object("tccus025")
		commit.transaction()	
	endselect

	if (mmbalance = 0) then
		stop()
	else
		longbarlength = mmbalance
		reloop()
	endif
}
Hi,

Thanks a lot. Now it can reloop all.
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
Error while opening opening purchase order naga ch Tools Administration & Installation 6 17th June 2016 23:42
How to call AFS in sp24? PV Ramone AFS/DDC/OLE: Function servers 4 2nd September 2008 12:06
Compile error,help! gavin_wusj Tools Development 5 5th April 2005 10:09
xml question steveauckly Tools Development 4 27th July 2004 11:41


All times are GMT +2. The time now is 00:57.


©2001-2018 - Baanboard.com - Baanforums.com