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
17%
200 - 500 GB
17%
500 - 800 GB
6%
800 - 1200 GB
6%
1200 - 1500 GB
17%
1500 - 2000 GB
17%
> 2000 GB
22%
Total votes: 18

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 12th July 2018, 10:18
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 94
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
Is there a function or codes similar to try()...catch()?
Baan: ERP LN 6.1 FP11 (Infor ERP 10.5)
C/S: Both

Hi,

As the title says, is there a function or codes similar to try()...catch()?
I have been using a session to execute things by keeping the session running all the time (infinite loop with timer interval) and just detect when to run a specific part of codes if the conditions are met. However, there are times when something is wrong and the session just crashes and exits by itself.
I just want to know how to keep it running even though there is an error occur just like try()...catch() in other programming languages nowadays.
In summary, I want to keep a session running even if there is an error occurred.

Regards,
Thana
Reply With Quote
Sponsored Links
  #2  
Old 12th July 2018, 19:14
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,122
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Wait for others - what popped into my mind is you could probably write a script or code to check to see if the session is running. If it is not then kick the session off again.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #3  
Old 13th July 2018, 14:12
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,355
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
I am not aware of any exceptions handling capabilities in BaaN/LN programming. But, we do have the return values for each and every transactions also we have the retry points.

You can suppress the crashes and use the variables to detect the errors.

If possible, can you please elaborate with an example?
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #4  
Old 13th July 2018, 22:04
NPRao's Avatar
NPRao NPRao is offline
Guru
 
Join Date: Aug 2001
Location: Pacific NW, USA
Posts: 3,066
NPRao will become famous soon enough
Baan: Baan 4-5,5.2(Reger),LN-6.1,Infor LN-10.x - DB: Oracle,MS-SQL - OS: HPUX, Linux, Windows
Quote:
Wait for others - what popped into my mind is you could probably write a script or code to check to see if the session is running. If it is not then kick the session off again.
Refer to the threads to check if the Session is in use or not.

Reload this Page CODE: Show which session a user is running

Post 3GL/4GL Script for USER TRACKING! (Windows Version)
__________________
The art of perfection does not lie in doing extraordinary things but, doing ordinary things extraordinarily well. [-N. Prashanth Rao]
How To Ask Questions The Smart Way,BaaNBoard,NPRao
Reply With Quote
  #5  
Old 16th July 2018, 04:48
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 94
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
Thanks everyone for the suggestions.

@bhushanchanda
This is an example code snippet:
************************************

Code:
 . . . 

before.program:
old.process.end = true |* check if it is running
set.timer(500)	|* run choice.interrupt on the interval

choice.interrupt:
on.choice:
if old.process.end then
	old.process.end = false
	run.main() |* the process that might make a fatal error
	old.process.end = true
endif

 . . . 

functions:

function run.main()
{
	domain	tdcrm.emsg		error.msg
	error.msg = ""
	
	select	tdcrm417.*
	from	tdcrm417 for update
	where	tdcrm417.stat = tdcrm.stat.open |* only process for lines that have 'open' status
	selectdo
		db.retry.point()
                update.to.processing() |* set status to 'processing'
			error.msg = process.afs.header( |* the code that performs AFS (main work)
				tdcrm417.rqno,
				tdcrm417.mode,
				tdcrm417.rcod
			)
		if not isspace(error.msg) then
			update.to.error(error.msg) |* set status to 'error'
		else
			update.to.processed() |* set status to 'processed'
		endif
		db.update(ttdcrm417, db.retry)
		commit.transaction()
	selectempty
	endselect
}

function domain tdcrm.emsg process.afs.header(
	domain	tcrqno		i.tdcrm417.rqno,
	domain	tcmcs.long	i.tdcrm417.mode,
	domain	tccdis		i.tdcrm417.rcod
)
{
	string	session.code(13)
	domain	tdcrm.emsg	error.msg, recov.error.msg
	long 	ret

	error.msg = ""
	session.code = M.PURCHASE.REQUISITION.APPROVAL.PROGRESS
	stpapi.clear(session.code)
	
	stpapi.put.field(session.code, "tdpur206.rqno", str$(i.tdcrm417.rqno))
	ret = stpapi.change.view(session.code, error.msg)
	if not isspace(error.msg) then
		stpapi.end.session(session.code)
		error.msg = "Cannot change view: " & error.msg
		return(error.msg)
	endif
	stpapi.put.field(session.code, "tdpur206.srno", "1")
	if stpapi.find(session.code, error.msg) <> 1 then
		error.msg = "Cannot find: " & error.msg
		stpapi.end.session(session.code)
		return(error.msg)
	endif
	if stpapi.mark(session.code, error.msg) <> 1 then
		error.msg = "Cannot mark: " & error.msg
		stpapi.end.session(session.code)
		return(error.msg)
	endif
	if i.tdcrm417.mode = 0 then
		stpapi.form.command(session.code, 5, "approve.requisition", error.msg)
		if not isspace(error.msg) then
			error.msg = "Cannot Approve: " & error.msg
			stpapi.end.session(session.code)
			return(error.msg)
		endif
	endif
	if i.tdcrm417.mode = 1 then
		stpapi.form.command(session.code, 5, "reject.requisition", error.msg)
		if not isspace(error.msg) then
			error.msg = "Cannot Reject: " & error.msg
			stpapi.end.session(session.code)
			return(error.msg)
		endif
	endif
	stpapi.end.session(session.code)
	return(error.msg)
}

 . . .
************************************
The code works just fine most of the time, but sometimes it just crashes by itself from locking problem or sometimes with system bugs that happen from installing new solutions by the admin. I want it to be able to continue to process by the interval even if the previous round caused fatal errors or something similar that forces it to exit its process.

@mark_h, @NPRao
I will have a look at the Windows version because we are using Windows, and if it fits the case that I am having then I will try it.

Last edited by tmannais : 17th July 2018 at 03:40. Reason: add code tag
Reply With Quote
  #6  
Old 16th July 2018, 19:45
NPRao's Avatar
NPRao NPRao is offline
Guru
 
Join Date: Aug 2001
Location: Pacific NW, USA
Posts: 3,066
NPRao will become famous soon enough
Baan: Baan 4-5,5.2(Reger),LN-6.1,Infor LN-10.x - DB: Oracle,MS-SQL - OS: HPUX, Linux, Windows
Quote:
The code works just fine most of the time, but sometimes it just crashes by itself from locking problem or sometimes with system bugs that happen from installing new solutions by the admin.
- I don't think my utility will help you out in this situation since this is a function call in your main program.
- You can make your core program into a 3-GL and use activate() and pstat() to check its still running, if not call activate() again.

- Also, it is expected all the users and batch jobs are offline when installing the PMC solutions, Porting Set, Create/Convert process so that the Shared Memory and Data Dictionary can be refreshed. So you need an option to shut your process down gracefully.

- You have to investigate why the fatal errors are generated and find work-around.

- Locking issues can be genuine and sometimes need a DBA level privilege to detect and kill them. You can mitigate some issues by using ora_timeout or msql_timeout. You can also research if you can use the options with predefined variable error.bypass and check for the 107 error and send an email alert.
New functions to support error bypass functionality:
Quote:
db.set.error.bypass.on()
db.get.error.bypass()
db.set.error.bypass.off()
- You cannot code for every possible scenario (Application, Server, Database failures etc.).

I think you have to revisit the Solution Design.

Please use the code tags to make it easy for us to read it.
__________________
The art of perfection does not lie in doing extraordinary things but, doing ordinary things extraordinarily well. [-N. Prashanth Rao]
How To Ask Questions The Smart Way,BaaNBoard,NPRao

Last edited by NPRao : 16th July 2018 at 19:52.
Reply With Quote
  #7  
Old 17th July 2018, 04:43
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 94
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
Thanks NPRao. I will try what you suggested.
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 22:42
tibom1213m000(Detect low level code and loop) Issue mark_h Tools Development 8 3rd December 2012 18:29
How to call AFS in sp24? PV Ramone AFS/DDC/OLE: Function servers 4 2nd September 2008 11:06
xml question steveauckly Tools Development 4 27th July 2004 10:41


All times are GMT +2. The time now is 19:25.


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