Baanboard.com

Go Back   Baanboard.com > Forum > Baan SIGs > AFS/DDC/OLE: Function servers

User login

Frontpage Sponsor

Main

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

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 23rd July 2015, 18:17
OmeLuuk's Avatar
OmeLuuk OmeLuuk is offline
Guru
 
Join Date: Mar 2002
Location: The Netherlands
Posts: 1,075
OmeLuuk is on a distinguished road
Baan: Infor LN 6.1 10.2.1 - DB: MS SQL2008 - OS: VM WindowsServer2008R2
Thumbs up Very nasty work around for an ugly problem AFS finds and updates WRONG RECORD

I want to share a solution with you for a situation mentioned several times on this board:
I want to use AFS in a session where I could not manage to select the right record to update although the syntax in AFS is correct.
Code:
	    ret = stpapi.sort.by("tdisa0601m000", "1", o.err.msg)
	    stpapi.put.field("tdisa0601m000", "tdisa001.item.segment2",
					trim$(tdisa001.item))
	    ret = stpapi.find("tdisa0601m000", o.err.msg)
	    if ret = 1 then
| But once here it appears that something is DEAD WRONG
Note: I thought that the session had to be started (and finding the default record selection would be done after the index selection) before I do a put on the session, but that does not help.
Code:
		stpapi.get.field("tdisa0601m000", "tdisa001.item", item)
| item is not the same as tdisa001.item but *another*

So I figured out the solution offered on the board, using browse.set (or browse.view, depending on the session type) but it takes an awful lot of time to get things done since we have loads of items to sell:
Code:
		if not ( trim$(item) = trim$(tdisa001.item) ) then
		    repeat
			if item < tdisa001.item then
			    ret = stpapi.browse.set("tdisa0601m000", "next.set",
		    			o.err.msg)
			else
			    ret = stpapi.browse.set("tdisa0601m000", "prev.set",
		    			o.err.msg)
			endif
			stpapi.get.field("tdisa0601m000", "tdisa001.item", item)
		    until ( trim$(item) = trim$(tdisa001.item) or ret = 0 )
		endif
This works for sure, but it has to browse through all items before it may continue with the correct one. And this has to be done many times for all items on my to-do list.

When running a DBS log I noticed that the record marked as *another* item was the *saved default* item (or after I removed my defaults it appeared to be the *first* item).

Now I added a trick
Before the first AFS call on the session where I need the record, I trick the 4GL session by setting the defaults in the stored session defaults to my current record ->
Code:
	update.current.tools("tdisa0601m000", "tdisa001.item:=" & 
				quoted.string(tdisa001.item), ttyeno.yes)
Where the function is defined like:
Code:
functions:
function update.current.tools(		domain	ttst13	i.sess,
					domain	ttst200	i.rcrd,
					domain	ttyeno	i.socc)
{	| Note: i.socc = yes means single occ (no = multi occ)
	table	tttadv990
	long	companion
	companion = get.compnr()
	if compnr.check(000) then
		db.retry.point()
		select	ttadv990.*
		from	ttadv990 for update
		where	ttadv990._compnr = 000
		and	ttadv990._index1 = {:logname$, :companion, :i.sess}
		selectdo
			db.delete(tttadv990, db.retry)
		endselect
		commit.transaction()
		db.retry.point()
		select	ttadv990.*
		from	ttadv990 for update
		where	ttadv990._compnr = 000
		and	ttadv990._index1 = {:logname$, :companion, :i.sess}
		selectdo
		selectempty
			ttadv990.user = logname$
			ttadv990.comp = companion
			ttadv990.sess = i.sess
			ttadv990.sequ = 1
			ttadv990.socc = i.socc
			ttadv990.rcrd = i.rcrd
			db.insert(tttadv990, db.retry)
		endselect
		commit.transaction()
	endif
	if compnr.check(companion) then
	endif
}
It seems to work fine for me Please tell me if it works for you too
__________________
Also read Luke 24:4-8

Last edited by OmeLuuk : 17th August 2015 at 13:17. Reason: Code optimized
Reply With Quote
  #2  
Old 23rd July 2015, 19:21
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,322
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
Quite a hack!

What if we simply clear the defaults before running the AFS and not saving any defaults? Because, there are instances when even the device details are stored by users as defaults and which does cause problems.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #3  
Old 23rd July 2015, 20:55
OmeLuuk's Avatar
OmeLuuk OmeLuuk is offline
Guru
 
Join Date: Mar 2002
Location: The Netherlands
Posts: 1,075
OmeLuuk is on a distinguished road
Baan: Infor LN 6.1 10.2.1 - DB: MS SQL2008 - OS: VM WindowsServer2008R2
Quote:
Originally Posted by bhushanchanda View Post
Quite a hack!

What if we simply clear the defaults before running the AFS and not saving any defaults? Because, there are instances when even the device details are stored by users as defaults and which does cause problems.
Removing all defaults will lead to finding the first topmost record and thus not solve the problem. We force the wrong RIGHT found record to be presented as the first by session defaults.
__________________
Also read Luke 24:4-8
Reply With Quote
Sponsored Links
  #4  
Old 24th July 2015, 11:03
günther günther is offline
Guru
 
Join Date: Jan 2002
Location: Ehingen, Germany
Posts: 573
günther is on a distinguished road
Baan: IVc4 - DB: Informix - OS: HP-UX
Hi,

I think I had a similiar problem with a session that had start option 44 "get defaults". I got around by copying the session and changing the start Option.
But I'm on Baan IV.

Regards
Günther
Reply With Quote
  #5  
Old 24th July 2015, 15:24
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,934
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Thumbs up

Nice hack and thanks for sharing it. I can't remember which session it was that I did where the stpapi.browse would move to the next record but would not make it current(no stpapi.mark did not work) - all the actions tried to happen on the first record. I believe what I did was stpapi.browse, get fields, then execute a stpapi.find to make it current. But this is a hack I never thought of - great solution.

Same here Gunther. Then one of the first things I do it a user calls and says one function servers is not working is to delete all user defaults for all sessions.

Plus it looks like I need to get some updated documention. I did not even know about the stpapi.sort.by option. I might have to see if that even compiles on our 4c4 system.
__________________
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
  #6  
Old 17th August 2015, 13:21
OmeLuuk's Avatar
OmeLuuk OmeLuuk is offline
Guru
 
Join Date: Mar 2002
Location: The Netherlands
Posts: 1,075
OmeLuuk is on a distinguished road
Baan: Infor LN 6.1 10.2.1 - DB: MS SQL2008 - OS: VM WindowsServer2008R2
Quote:
Originally Posted by günther View Post
I think I had a similiar problem with a session that had start option 44 "get defaults". I got around by copying the session and changing the start Option.
Yes Günther, that should also work, but I want to leave the standard functionality and operation as is without making even the slightest change.
__________________
Also read Luke 24:4-8
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


All times are GMT +2. The time now is 11:08.


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