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
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 21st November 2013, 07:56
psuryava psuryava is offline
Junior Member
 
Join Date: Feb 2011
Posts: 24
psuryava is on a distinguished road
Baan: Baan IV - DB: Oracle - OS: AIX
AFS on session tfacp1110s000

Hi

I am trying to automate session tfgld1101m000 & tfacp1110s000 using afs, but I am not able to insert record in table tfacp200.

When I run the afs code and debug session tfacp1110s000, I noticed that event
choice.add.set --> before.choice is triggered on stpapi.insert() call.
After this the sub-session populates and calculates all the required values for tfacp200, but record is not inserted/saved !!
The control returns back to afs code with err message "Session not available".

The record is not inserted because, the main.table.io sections, before.write and after.write in session tfacp1110s000 are not executed.

I have already checked and confirmed that all required values for tfacp200 are populated through afs.
I have tried to set "do.save" flag to 0/1 in stpapi.insert() and tried calling stpapi.save() after it. But record is not inserted.

Any idea why this can be happening?

Thanks in advance.
  #2  
Old 21st November 2013, 09:08
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,286
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
Hi,

If possible please post your code. That will be give a better idea to others.

Also do a search on board. There are many similar threads.

Here is a solved thread:-

Thread
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
  #3  
Old 21st November 2013, 11:25
psuryava psuryava is offline
Junior Member
 
Join Date: Feb 2011
Posts: 24
psuryava is on a distinguished road
Baan: Baan IV - DB: Oracle - OS: AIX
afs code added

| Maintain batch
Code:
             stpapi.put.field("tfgld1101m000", "tedt.f", str$(tedt.i))
	stpapi.put.field("tfgld1101m000", "bref.f", bref.i)
	| Switch the view
	err.cde = stpapi.change.view("tfgld1101m000")
	if FAIL then
		err.msg = "View not found"
		message(err.msg)
             endif
	stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", ttyp.i)
	| Insert Transaction
	stpapi.insert("tfgld1101m000", true, err.msg)
	if FAIL then
	             message(err.msg)
		stpapi.recover("tfgld1101m000", err.msg)
	endif

| Maintain transaction
             stpapi.get.field("tfgld1101m000", "tfgld101.btno", value)
	batch.no = lval(value)
	message("Batch Number is %d", batch.no)
	
	err.cde = stpapi.browse.set("tfgld1101m000", "last.set")
	if NOT_FOUND then
		err.msg = "Maintained transaction not found"
		message(err.msg)
	endif
	err.cde = stpapi.browse.set("tfgld1101m000", "mark.occur")
	if FAIL then
		err.msg = "error in mark"
	             message(err.msg)
	endif
	stpapi.handle.subproc("tfgld1101m000", "tfacp1110s000", "add")
	stpapi.continue.process("tfgld1101m000", err.msg)
	
	if FAIL then
		message(err.msg)
		stpapi.recover("tfgld1101m000", err.msg)
	endif

		stpapi.put.field("tfacp1110s000", "tfacp200.suno", suno.i)
		stpapi.put.field("tfacp1110s000", "tfacp200.docd", str.date) 	
		stpapi.put.field("tfacp1110s000", "tfacp200.ccur", ccur.i)
		stpapi.put.field("tfacp1110s000", "screen.amnt", str$(amnt.i))
		stpapi.put.field("tfacp1110s000", "tfacp200.cvat", cvat.i)
		stpapi.put.field("tfacp1110s000", "screen.vata", str$(taxm.i))
		stpapi.put.field("tfacp1110s000", "tfacp200.isup", isup.i)
		stpapi.put.field("tfacp1110s000", "tfacp200.refr", isup.i & " ASD TEST")
		stpapi.put.field("tfacp1110s000", "tfacp200.bloc", bloc.i)
		stpapi.put.field("tfacp1110s000", "tfacp200.bdat", str.date)
		stpapi.put.field("tfacp1110s000", "tfacp200.bref", bref.i)
		stpapi.put.field("tfacp1110s000", "tfacp200.loco", str$(get.compnr()))
		stpapi.put.field("tfacp1110s000", "tfacp200.cpay", cpay.i)
		stpapi.put.field("tfacp1110s000", "tfacp200.dued", str.date)
		stpapi.put.field("tfacp1110s000", "tfacp200.paym", paym.i)
		stpapi.put.field("tfacp1110s000", "tfacp200.bank", bank.i)
		stpapi.put.field("tfacp1110s000", "tfacp200.btno", str$(batch.no))
		
		stpapi.handle.subproc("tfacp1110s000", "tfacp1130s000", "add")
		stpapi.insert("facp1110s000", true, err.msg)
		stpapi.save("tfac1110s000",err.msg)
		
	              if FAIL then
			message(err.msg)
			stpapi.recover("tfacp1110s000", err.msg)
			stpapi.end.session("tfacp1130s000")
			stpapi.end.session("tfacp1110s000")
                                      stpapi.end.session("tfgld1101m000")

		endif

             stpapi.end.session("tfacp1130s000")
	stpapi.end.session("tfacp1110s000")	
             stpapi.end.session("tfgld1101m000")

Last edited by mark_h : 21st November 2013 at 14:37. Reason: Add code tags
  #4  
Old 21st November 2013, 12:25
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,286
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
Hi,

Is it working fine now? Or still causing issues? Have you looked at the mentioned thread?
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
  #5  
Old 21st November 2013, 12:39
psuryava psuryava is offline
Junior Member
 
Join Date: Feb 2011
Posts: 24
psuryava is on a distinguished road
Baan: Baan IV - DB: Oracle - OS: AIX
Yes i looked at the thread mentioned by you.
The error was still not resolved.

on stpapi.insert() --> in session tfacp1110s000, choice.add.set--> before.choice is invoked and after that nothing is processed in the sub-session.
the control comes back to afs with error --"Session not available".

I have posted the code for reference
  #6  
Old 21st November 2013, 12:58
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,286
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
Hi,

You code looks quite different from the one posted in the thread. Well right now cant think of the error. Will run a test against your code and will see if I get something.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
  #7  
Old 21st November 2013, 14:39
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,903
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Is this a typo in the code or in the post "stpapi.insert("facp1110s000", true, err.msg)"? Note it should be tfacp1110s000.
__________________
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.
  #8  
Old 21st November 2013, 14:41
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,903
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Same for stpapi.save("tfac1110s000",err.msg). Missing the p in tfacp.
__________________
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.
  #9  
Old 22nd November 2013, 04:30
psuryava psuryava is offline
Junior Member
 
Join Date: Feb 2011
Posts: 24
psuryava is on a distinguished road
Baan: Baan IV - DB: Oracle - OS: AIX
yes it is a typo error while pasting the code
  #10  
Old 22nd November 2013, 04:51
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,903
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Here is my code from one session that does work. I attack it a little differently than you do. Not sure this will work for you - there could be differences in libraries and objects.
Code:
Function process.selected.date()
{
                sel.date = tfudi030.date
                sel.ttyp = tfudi030.ttyp
| Added just because the user might get cute and try to process a Transaction
| type thru the session that it is not designed for.
                if sel.ttyp<>"APG" and sel.ttyp<>"APD" then
                                message("Transaction type not defined by program.")
                                return
                endif
| Create batch - note subroutine leaves the two tfgld sessions open      
                if api.create.batch() then
                                stpapi.end.session("tfgld1101s000") 
                                stpapi.end.session("tfgld1100m000")
                                return
                endif

|Start processing the data selected.
                select    a.srno:sel.srno
                from      tfudi030 a
                where   a._index1 = {:sel.date, :sel.ttyp}
                selectdo
                                db.retry.point()
                                select    tfudi030.*
                                from      tfudi030 for update
                                where   tfudi030._index1 = {:sel.date, :sel.ttyp, :sel.srno}
                                as set with 1 rows
                                selectdo
| 20080207.st Reverse the oncase statement since get.max.refr needs tiudi035.pref
| to already be set.
| Did a case statement because they might add transaction types later.
                                                on case sel.ttyp
                                                case "APG":
                                                                tfudi035.pref = "G"
                                                                break
                                                case "APD":
                                                                tfudi035.pref = "D"
                                                                break
                                                endcase
                                                sel.refr = get.max.refr()                | 20080207.en
                                                api.create.invoice()
                                                if isspace(e.msg) then
                                                                tfudi035.date = sel.date
                                                                tfudi035.ttyp = tfudi030.ttyp
                                                                tfudi035.srno = get.max.srno()
                                                                tfudi035.suno = tfudi030.suno
                                                                tfudi035.isup = tfudi030.isup
                                                                tfudi035.reas = tfudi030.reas
                                                                tfudi035.leac = tfudi030.leac
                                                                tfudi035.amnt = tfudi030.amnt
                                                                tfudi035.refr = sel.refr
                                                                tfudi035.dtep = date.num()
                                                                tfudi035.btno = sel.btno
                                                                tfudi035.user = logname$
                                                                db.insert(ttfudi035)
                                                                db.delete(ttfudi030,db.retry)
                                                else
                                                                tfudi030.err = e.msg
                                                                db.update(ttfudi030,db.retry)
                                                endif
                                endselect
                                commit.transaction()
                endselect
                stpapi.end.session("tfgld1101s000") 
                stpapi.end.session("tfgld1100m000")
}
function domain tcorno get.max.srno()
{
                domain                tcorno   max.srno
                max.srno = 0
                select    max(a.srno):max.srno
                from      tfudi035 a
                where   a._index1 = {:sel.date, :sel.ttyp}
                selectdo
                endselect
                max.srno = max.srno + 1
                return(max.srno)
}
| Reference number must be unique
function domain tcorno get.max.refr()
{
                domain                tcorno   max.refr
                select    max(a.refr):max.refr
                from      tfudi035 a
                where   a.pref = :tfudi035.pref
                selectdo
                selectempty
                                max.refr = 9999
                endselect
                max.refr = max.refr + 1
                return(max.refr)
}
function api.create.invoice()
{
                domain                tcmcs.str80         hold.msg
                
|Active the tfacp1110s000 session.
                stpapi.continue.process("tfgld1101s000", e.msg)
                
| Clear insert mode.
                stpapi.save("tfacp1110s000",e.msg)
| Add the new record - note isup and refr must be unique on our system.
                stpapi.put.field("tfacp1110s000", "tfacp200.suno", strip$(tfudi030.suno))
                stpapi.put.field("tfacp1110s000", "tfacp200.isup", str$(tfudi030.isup))
                stpapi.put.field("tfacp1110s000", "tfacp200.docd", str$(date.num()))
                stpapi.put.field("tfacp1110s000", "tfacp200.refr", tfudi035.pref & str$(sel.refr))  
                stpapi.put.field("tfacp1110s000", "screen.amnt", str$(round(tfudi030.amnt, 2, 0))) 
                stpapi.put.field("tfacp1110s000", "tfacp200.reas", tfudi030.reas ) 
                stpapi.handle.subproc("tfacp1110s000", "tfacp1120s000", "add")
                rc = stpapi.insert("tfacp1110s000", 1, e.msg) 
                if not isspace(e.msg) then
                                stpapi.end.session("tfacp1110s000") 
                                return
                endif
|Insert the account on tfacp1120s000     
                stpapi.put.field("tfacp1120s000", "tfgld102.leac", tfudi030.leac) 
                rc = stpapi.insert("tfacp1120s000", 1, e.msg)
                if not isspace(e.msg) then
                                stpapi.end.session("tfacp1120s000")
                                hold.msg = e.msg
                                stpapi.delete("tfacp1110s000", true, e.msg)
                                e.msg = hold.msg
                                stpapi.end.session("tfacp1110s000") 
                                return
                endif
| End the two sessions
                stpapi.end.session("tfacp1120s000")
                stpapi.end.session("tfacp1110s000") 
}
function long     api.create.batch()
{
                
|  tfgld1100m000 (Maintain Transactions) 
|  Put data and create batch
                stpapi.put.field("tfgld1100m000", "tfgld100.tedt", str$(date.num())) 
                stpapi.put.field("tfgld1100m000", "tfgld100.bref", sprintf$("Garnishments %D(%02m/%02d/%02y)", date.num())) 
                rc = stpapi.insert("tfgld1100m000", 1, e.msg) 
                if not isspace(e.msg) then
                                message("Unable to create transaction type.")
                                return(true)
                endif
| Get the batch created.               
                stpapi.get.field("tfgld1100m000","tfgld100.btno",e.msg)
                sel.btno = val(strip$(e.msg))
| Activate tfgld1101s000 subsession       
                stpapi.handle.subproc("tfgld1100m000", "tfgld1101s000", "add")
                stpapi.continue.process("tfgld1100m000", e.msg)
| Clear the input mode the session starts in       
                stpapi.save("tfgld1101s000",e.msg)
| Put the transaction type           
                stpapi.put.field("tfgld1101s000", "tfgld101.ttyp", strip$(tfudi030.ttyp)) 
                rc = stpapi.insert("tfgld1101s000", 1, e.msg)       
                if not isspace(e.msg) then
                                message("Unable to create transaction type.")
                                return(true)
                endif
                return(false)
}
__________________
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.
Sponsored Links
  #11  
Old 22nd November 2013, 06:03
psuryava psuryava is offline
Junior Member
 
Join Date: Feb 2011
Posts: 24
psuryava is on a distinguished road
Baan: Baan IV - DB: Oracle - OS: AIX
thanks Mark,
Will try to check with my code
  #12  
Old 23rd November 2013, 07:53
psuryava psuryava is offline
Junior Member
 
Join Date: Feb 2011
Posts: 24
psuryava is on a distinguished road
Baan: Baan IV - DB: Oracle - OS: AIX
Thanks for your help.
the issue was resolved !
  #13  
Old 24th November 2013, 21:27
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,903
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
What was the solution if you don't mind?
__________________
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.
Closed Thread


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
PDF problem while running session on AFS saumya AFS/DDC/OLE: Function servers 4 2nd August 2013 18:52
Sub session activating another sub session in AFS ameya_gidwani Distribution, Transportation & Warehousing 0 9th April 2013 13:33
AFS session not terminating in batch job rduncan10 AFS/DDC/OLE: Function servers 3 13th December 2012 14:45
How can I get PID of a session activated with AFS? simona Tools Development 6 6th June 2008 16:25
AFS - problem running session in a job aobrien AFS/DDC/OLE: Function servers 15 2nd April 2004 14:51


All times are GMT +2. The time now is 04:20.


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