Baanboard.com

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

User login

Frontpage Sponsor

Main

Google search


Poll
How big is your Baan-DB (just Data AND Indexes)
0 - 200 GB
18%
200 - 500 GB
26%
500 - 800 GB
3%
800 - 1200 GB
9%
1200 - 1500 GB
12%
1500 - 2000 GB
12%
> 2000 GB
21%
Total votes: 34

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 30th March 2018, 11:27
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
[AFS] Create a new record in Outbound Advice session

Hi,

I am working on an AFS program that tries to simulate user interaction in the Outbound Advice session (whinh4525m000) in order to create a new record.
Here is the code:

Code:
session.code = "whinh4525m000" | Outbound Advice Session
stpapi.clear(session.code)
if stpapi.synchronize.dialog(session.code, "add", error.msg) then
	stpapi.put.field(session.code, "whinh225.oorg", "1")
	stpapi.put.field(session.code, "whinh225.orno.segment.1", "BOX000111")
	stpapi.put.field(session.code, "whinh225.oset", "1")
	stpapi.put.field(session.code, "whinh225.pono", "1")
	stpapi.put.field(session.code, "whinh225.seqn", "0")
	stpapi.put.field(session.code, "whinh225.sern", "1")
	stpapi.put.field(session.code, "whinh225.qads", "3")
	stpapi.get.field(session.code, "whinh225.runn", output)
	ret = stpapi.insert(session.code, true, error.msg)
	if (not isspace(error.msg)) then
		message("Cannot Insert : " & error.msg)
	endif
else
	error.msg = "Cannot open synchronized dialog: " & error.msg
endif
stpapi.end.session(session.code, error.msg)
However, there is an error message at the end saying "Enter a value for the Business Object Type field.", but the field is actually not mandatory.
In addition, I tried manually putting those fields (without Business Object Type field) and the record is created just fine.
Please advice.

Regards,
Thana
Reply With Quote
  #2  
Old 30th March 2018, 19:35
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,144
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Searching for code on the site - I say one post that has orno not as a segment. So I can't answer that. I will say calling code via api code it does not always work like it does manually. In this case it might not be setting something that makes it skip checking the field. Sometimes you can do a insert without true and then do a save. I have had to do some different things like that to get API code to work in 4c4. Can't really help with LN.
__________________
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 2nd April 2018, 04:32
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
I have tried using orno not as a segment, and I have also tried insert with false then save, but no luck.
orno way gives me the same error while inserting with false then save gives me the same error on insert but not on save.
So, none of these seem to work.

Last edited by tmannais : 2nd April 2018 at 05:54. Reason: add more details
Reply With Quote
  #4  
Old 2nd April 2018, 14:38
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,144
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
You wouldn't by chance happen to have code so you could debug what is happening would you?
__________________
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
  #5  
Old 2nd April 2018, 16:18
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 114
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
orno is definitely not a segmented field. When you are creating new record by hand, do you fill only those fields you have in your code? Does it throw any messages at you during it? Try to get all messages generated in session:
Code:
ret = stpapi.insert(session.code, true, error.msg)
if not ret then
	while true 
		error.code = stpapi.get.mess.code(session.code, error.msg)
		if isspace(error.msg) then
			   break
		endif 
		message(error.msg)
	endwhile
	stpapi.recover(session.code, recover.msg)
endif
I encountered a weird error in AFS once, turned out it was another field all the time having been filled incorrectly rather then the one error message pointed to.
Reply With Quote
  #6  
Old 3rd April 2018, 05:09
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
mark_h, I tried debugging the AFS.
Here's the result:
Code:
LOGGING STARTED
03-04-2018
>whinh4525m000 clear
45dll->serv (getxml)
45dll->serv (startwhinh4525m000100)
47serv<-4gl (api.child.startedwhinh4525m00045)
47serv<-4gl (init.ready)
whinh4525m000(47)-RUNNING:
45dll->serv (startwhinh4525m0001whinh4525m000114)
49serv<-4gl (init.ready)
whinh4525m000(49)-RUNNING:
45dll->serv (syncadd47)
whinh4525m000(47)-RUNNING:syncadd
47serv<-4gl (syncadd0)
whinh4525m000(47)-RUNNING:
>whinh4525m000(47) put.field:whinh225.oorg 1
>whinh4525m000(47) put.field:whinh225.orno BOX000111
>whinh4525m000(47) put.field:whinh225.oset 1
>whinh4525m000(47) put.field:whinh225.pono 1
>whinh4525m000(47) put.field:whinh225.seqn 0
>whinh4525m000(47) put.field:whinh225.sern 1
>whinh4525m000 get.field:whinh225.oorg
<whinh4525m000(49) get.field:whinh225.oorg=1
>whinh4525m000 get.field:whinh225.orno
<whinh4525m000(49) get.field:whinh225.orno=BOX000111
>whinh4525m000 get.field:whinh225.pono
<whinh4525m000(49) get.field:whinh225.pono=1
>whinh4525m000 get.field:whinh225.seqn
<whinh4525m000(49) get.field:whinh225.seqn=0
>whinh4525m000 get.field:whinh225.sern
<whinh4525m000(49) get.field:whinh225.sern=1
>whinh4525m000 get.field:whinh225.oset
<whinh4525m000(49) get.field:whinh225.oset=1
>whinh4525m000(47) put.field:whinh225.qads 3
>whinh4525m000 get.field:whinh225.runn
<whinh4525m000(49) get.field:whinh225.runn=            
>whinh4525m000 insert
45dll->serv (add.set+save49)
whinh4525m000(49)-RUNNING:add.set+save
49serv<-4gl (add.set+save10)
whinh4525m000(49)-RUNNING:
<whinh4525m000 Enter a value for the Business Object Type field.
>whinh4525m000 get.mess.code
<whinh4525m000 
>whinh4525m000 get.field:whinh225.oorg
<whinh4525m000(49) get.field:whinh225.oorg=1
>whinh4525m000 get.field:whinh225.orno
<whinh4525m000(49) get.field:whinh225.orno=BOX000002
>whinh4525m000 get.field:whinh225.pono
<whinh4525m000(49) get.field:whinh225.pono=10
>whinh4525m000 get.field:whinh225.seqn
<whinh4525m000(49) get.field:whinh225.seqn=0
>whinh4525m000 get.field:whinh225.sern
<whinh4525m000(49) get.field:whinh225.sern=2
>whinh4525m000 get.field:whinh225.oset
<whinh4525m000(49) get.field:whinh225.oset=1
>whinh4525m000 end.session
45dll->serv (end.program47)
whinh4525m000(47)-RUNNING:end.program
whinh4525m000(49)-RUNNING:end.program
47serv<-4gl (end.program0)
whinh4525m000(47)-RUNNING:
47dll->serv (whinh4525m000: exit(47))
49dll->serv (whinh4525m000: exit(49))
It looks like I put the fields correctly but it still asks for Business Object Type field.
And giggty, I also tried your code but it displays no error messages.
Reply With Quote
  #7  
Old 3rd April 2018, 14:55
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,144
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
I was hoping you had baan source code you could debug and step thru to see what is happening. My suspicion is that when you run it manually and move thru the fields and event gets hit which says that business object type field is not needed, but when you run it via AFS code it does not hit that event. Is it possible to put that field and then maybe go back and edit it to make it empty?
__________________
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
Sponsored Links
  #8  
Old 4th April 2018, 04:37
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
I don't have the source code.
I have tried putting the Business Object Type field but it then asked for another non-mandatory field, and when I put in the field it gave me another error. So, I think it is not the way it should be because I have to put so many non-mandatory fields that are not even required. Most of them will be left blank by the users when manually create as well.
However, yesterday I gave DAL a try and it seems to do the work just fine. So, I want to ask what are the things I should keep in mind when I try to use DAL instead of AFS for the same work.
Reply With Quote
  #9  
Old 4th April 2018, 16:21
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 114
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
I tried to create an Advice through AFS filling in exactly the same fields and values I use when doing it manually and it throws an error regarding some irrelevant existing line I could not figure it out.
So if DAL approach worked for you then just go for it. Nothing special to keep in mind here, DAL does the heavy lifting
Reply With Quote
  #10  
Old 5th April 2018, 04:44
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
Thank you mark_h and giggty for the advice. I finally use the DAL instead of AFS to solve this problem. It works like a charm and it is way eaiser than I thought. Here's the code for anyone who is having the same problem as I was.

*only the DAL part*
Code:
if dal.new.object("whinh225") <> 0 then
	dal.get.error.message(error.msg)
	return(error.msg)
endif
dal.set.field("whinh225.oorg", i.tdcrm411.oorg)
dal.set.field("whinh225.orno", str$(i.tdcrm411.orno))
dal.set.field("whinh225.oset", i.tdcrm411.oset)
dal.set.field("whinh225.pono", i.tdcrm411.pono)
dal.set.field("whinh225.seqn", i.tdcrm411.seqn)
dal.set.field("whinh225.sern", i.tdcrm411.sern)
dal.set.field("whinh225.locf", str$(i.tdcrm411.loca))
dal.set.field("whinh225.clot", str$(i.tdcrm411.clot))
dal.set.field("whinh225.qads", i.tdcrm411.qads)
dal.set.field("whinh225.idat", i.tdcrm411.idat)
if dal.save.object("whinh225") <> 0 then
	dal.get.error.message(error.msg)
	return(error.msg)
endif
if get.var(pid,"whinh225.runn", o.tdcrm411.runn) <> 1 then
	error.msg = "Cannot get Run Number."
endif
return(error.msg)

Last edited by tmannais : 5th April 2018 at 04:46. Reason: fix code indentation
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
AFS Field Value disappeared after putting into Field infatuated01 AFS/DDC/OLE: Function servers 3 12th February 2018 15:02
URL to a specifc session and record mpolnz Tools Administration & Installation 1 23rd March 2012 14:28
Issue in new developed maintain session VishalMistry Tools Development 2 12th August 2010 06:59
synchronizing different occurrences on parent session from child Ruskin Tools Development 8 18th March 2008 18:56
tfacp9450m000 FIBU Brush Up Kai's Forum Users Deutsches Forum 1 16th November 1999 01:00


All times are GMT +2. The time now is 01:14.


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