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
38%
Installation Wizard into new VRC
41%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 37

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 10th February 2016, 21:58
eric.dizon's Avatar
eric.dizon eric.dizon is offline
Senior Member
 
Join Date: Feb 2012
Posts: 151
eric.dizon is on a distinguished road
Baan: ERP LN - DB: MS SQL - OS: 2003
Thumbs up AFS - insert record in whinh5120m100

Hello, I am trying to get back using AFS again. I have the following code below to insert a new record in the Adjustment Order MMT session. It works on inserting the header records but I am having issues in inserting the detail records. I cannot seem to get past the issues I have. The code as it stands works on inserting the header record but having a error "Reason: Lot Bxxxx not found for item. " - What table do I verify if the lot is there? I try entering the same values using the actual session and it saves them no error.


string main.sess(13)
string sync.sess(13)
main.sess = "whinh5120m100"
sync.sess = "whinh5121m000"


stpapi.clear(main.sess)
stpapi.put.field(main.sess, "whinh520.orno", "ADJ")
stpapi.put.field(main.sess, "whinh520.cwar", "300832")
stpapi.put.field(main.sess, "whinh520.adrn", "INV17")
stpapi.put.field(main.sess, "whinh520.emno", "")
stpapi.put.field(main.sess, "whinh520.adst", "10")
stpapi.put.field(main.sess, "whinh520.mnad", "1")


h.ret = stpapi.insert(main.sess,true,errmsg)
if h.ret then |Insert succeeds
stpapi.get.field(main.sess, "whinh520.orno", l.orno)

|Find the record created
First question : Should I be using the main.sess or the sync.sess ? I tried both but having different issues
stpapi.put.field(sync.sess, "whinh521.orno", l.orno )
ret = stpapi.find(sync.sess , errfindmsg)
if isspace(errfindmsg)
2nd Q: Which session do I sync main or sync session ?
3rd Q: I am inserting a detail record do I use "add/modify" ?

ret = stpapi.synchronize.dialog(sync.sess, "modify", errmsg)
if ret then |
stpapi.put.field(sync.sess, "whinh521.orno", l.orno)
stpapi.put.field(sync.sess, "whinh521.pono", "1")
stpapi.put.field(sync.sess, "whinh521.cwar", "300832")
|stpapi.put.field(sync.sess, "whinh521.item", " CSBP043-030AAAA")
stpapi.put.field(sync.sess, "whin521.item.segment.1", "" ) |value(1; 9)
stpapi.put.field(sync.sess, "whin521.item.segment.2", "CSBP043-030AAAA") | CSBP043-030AAAA
stpapi.put.field(sync.sess, "whinh521.clot", "B00000575-15-10-0016") | l.clot) |B00000575-15-10-0016
stpapi.put.field(sync.sess, "whinh521.stun", "m") | Handling Unit
stpapi.put.field(sync.sess, "whinh521.qadr", str$(l.rmmt)) | Inventory Adjusted
l.vari = v.qhnd - l.rmmt
stpapi.put.field(sync.sess, "whinh521.qrvr", str$(l.vari)) | Variance
stpapi.put.field(sync.sess, "whinh521.adrn", "INV17")

4th Q: Do I use stpapi.insert or stpapi.update ?
rval = stpapi.insert(sync.sess,true,errmsg) | "Get an error here: Lot number not found "
if rval then |If insert fails
ret = stpapi.save(sync.sess, saveerror)

endif



endif

endif
Reply With Quote
  #2  
Old 11th February 2016, 06:19
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,313
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 can use DAL instead of AFS over here as you are just inserting the data. Else, you can create the header with your AFS and insert the lines using DAL.

It's an MMT session, so there are chances of getting errors. Another solution is to go with Easy Entry Adjustment Order session.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #3  
Old 11th February 2016, 16:11
eric.dizon's Avatar
eric.dizon eric.dizon is offline
Senior Member
 
Join Date: Feb 2012
Posts: 151
eric.dizon is on a distinguished road
Baan: ERP LN - DB: MS SQL - OS: 2003
DAL vs. AFS

Hi bhushanchanda,

I am trying to trigger this function from a MMT form command or menu while a record is selected.
You always directed me to use DAL to solve the issue for AFS in LN. I have a couple of questions on how to this and an example would be nice too.

1. How can I trigger the DAL function from my custom MMT session?
2. If I am inserting an adjustment order and the reason I am using AFS is there maybe validation and triggers that need to happen just using simple db.update commands. Will does trigger any DALs related to entering Adjustment orders ?


Regards,

Eric
Reply With Quote
  #4  
Old 11th February 2016, 18:31
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,924
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Please post only in one forum. This is the correct forum for AFS questions.

Thanks
__________________
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 12th February 2016, 15:42
eric.dizon's Avatar
eric.dizon eric.dizon is offline
Senior Member
 
Join Date: Feb 2012
Posts: 151
eric.dizon is on a distinguished road
Baan: ERP LN - DB: MS SQL - OS: 2003
Thank you all for your replies and help. I will try and will update which one worked.
Reply With Quote
  #6  
Old 16th February 2016, 15:48
eric.dizon's Avatar
eric.dizon eric.dizon is offline
Senior Member
 
Join Date: Feb 2012
Posts: 151
eric.dizon is on a distinguished road
Baan: ERP LN - DB: MS SQL - OS: 2003
Thanks bhushan! Now I've learn something new with DAL that if dal.* command instead of db.* Validation gets triggered
Reply With Quote
  #7  
Old 27th February 2016, 15:36
Ajesh's Avatar
Ajesh Ajesh is offline
Guru
 
Join Date: Feb 2009
Posts: 444
Ajesh is on a distinguished road
Baan: LN 10.4 - DB: Oracle - OS: HP-Unix
Hi Eric

You are going to insert a fresh record in the detail session, isnt it? It has to be in "Add" Mode..
Reply With Quote
  #8  
Old 31st October 2016, 16:14
eric.dizon's Avatar
eric.dizon eric.dizon is offline
Senior Member
 
Join Date: Feb 2012
Posts: 151
eric.dizon is on a distinguished road
Baan: ERP LN - DB: MS SQL - OS: 2003
Thank you for your Bhushan.
Reply With Quote
  #9  
Old 11th February 2016, 06:22
sam291091's Avatar
sam291091 sam291091 is offline
Member
 
Join Date: Feb 2014
Location: Surat Gujarat
Posts: 68
sam291091 is on a distinguished road
Baan: ERP LN FP9 - DB: MY SQL - OS: Windows
Thumbs up

Hi,
Try following code for Line Insertion
Code:
stpapi.put.field(main.sess, "whinh520.orno", l.orno ) |"ADJ003147")
ret = stpapi.find(main.sess , errfindmsg)
stpapi.handle.subproc(main.sess ,sync.sess ,"add")
stpapi.put.field(sync.sess, "whinh521.orno", l.orno)
stpapi.put.field(sync.sess, "whinh521.pono", "1")
stpapi.put.field(sync.sess, "whinh521.cwar", "300832")
stpapi.put.field(sync.sess, "whin521.item.segment.1", "" ) |value(1; 9)
stpapi.put.field(sync.sess, "whin521.item.segment.2", "CSBP043-030AAAA") | CSBP043-030AAAA
stpapi.put.field(sync.sess, "whinh521.clot", l.clot) |B00000575-15-10-0016
stpapi.put.field(sync.sess, "whinh521.stun", "m") | Handling Unit
stpapi.put.field(sync.sess, "whinh521.qadr", str$(l.rmmt)) | Inventory Adjusted
l.vari = v.qhnd - l.rmmt
stpapi.put.field(sync.sess, "whinh521.qrvr", str$(l.vari)) | Variance
stpapi.put.field(sync.sess, "whinh521.adrn", "INV17")
rval = stpapi.insert(sync.sess,true,errmsg)
Reply With Quote
  #10  
Old 11th February 2016, 18:50
eric.dizon's Avatar
eric.dizon eric.dizon is offline
Senior Member
 
Join Date: Feb 2012
Posts: 151
eric.dizon is on a distinguished road
Baan: ERP LN - DB: MS SQL - OS: 2003
Hi sam291091,

I tried your code below to include handle ? I get same error command disabled.
If I try to add this after stpapi.handle using "add" - I still get command disabled.
ret = stpapi.synchronize.dialog(sync.sess, "add", errmsg)

else if I use modify I get Adjustment Order not found. Enter another order.
ret = stpapi.synchronize.dialog(sync.sess, "modify", errmsg)

stpapi.put.field(main.sess, "whinh520.orno", l.orno ) |"ADJ003147")
ret = stpapi.find(main.sess , errfindmsg)
stpapi.handle.subproc(main.sess ,sync.sess ,"add")
stpapi.put.field(sync.sess, "whinh521.orno", l.orno)
stpapi.put.field(sync.sess, "whinh521.pono", "1")
stpapi.put.field(sync.sess, "whinh521.cwar", "300832")
stpapi.put.field(sync.sess, "whin521.item.segment.1", "" ) |value(1; 9)
stpapi.put.field(sync.sess, "whin521.item.segment.2", "CSBP043-030AAAA") | CSBP043-030AAAA
stpapi.put.field(sync.sess, "whinh521.clot", l.clot) |B00000575-15-10-0016
stpapi.put.field(sync.sess, "whinh521.stun", "m") | Handling Unit
stpapi.put.field(sync.sess, "whinh521.qadr", str$(l.rmmt)) | Inventory Adjusted
l.vari = v.qhnd - l.rmmt
stpapi.put.field(sync.sess, "whinh521.qrvr", str$(l.vari)) | Variance
stpapi.put.field(sync.sess, "whinh521.adrn", "INV17")
rval = stpapi.insert(sync.sess,true,errmsg)
Reply With Quote
  #11  
Old 11th February 2016, 19:58
eric.dizon's Avatar
eric.dizon eric.dizon is offline
Senior Member
 
Join Date: Feb 2012
Posts: 151
eric.dizon is on a distinguished road
Baan: ERP LN - DB: MS SQL - OS: 2003
Hi sam291091,

I tried your code below to include handle ? I get same error command disabled.
If I try to add this after stpapi.handle using "add" - I still get command disabled.
ret = stpapi.synchronize.dialog(sync.sess, "add", errmsg)

else if I use modify I get Adjustment Order not found. Enter another order.
ret = stpapi.synchronize.dialog(sync.sess, "modify", errmsg)

stpapi.put.field(main.sess, "whinh520.orno", l.orno ) |"ADJ003147")
ret = stpapi.find(main.sess , errfindmsg)
stpapi.handle.subproc(main.sess ,sync.sess ,"add")
stpapi.put.field(sync.sess, "whinh521.orno", l.orno)
stpapi.put.field(sync.sess, "whinh521.pono", "1")
stpapi.put.field(sync.sess, "whinh521.cwar", "300832")
stpapi.put.field(sync.sess, "whin521.item.segment.1", "" ) |value(1; 9)
stpapi.put.field(sync.sess, "whin521.item.segment.2", "CSBP043-030AAAA") | CSBP043-030AAAA
stpapi.put.field(sync.sess, "whinh521.clot", l.clot) |B00000575-15-10-0016
stpapi.put.field(sync.sess, "whinh521.stun", "m") | Handling Unit
stpapi.put.field(sync.sess, "whinh521.qadr", str$(l.rmmt)) | Inventory Adjusted
l.vari = v.qhnd - l.rmmt
stpapi.put.field(sync.sess, "whinh521.qrvr", str$(l.vari)) | Variance
stpapi.put.field(sync.sess, "whinh521.adrn", "INV17")
rval = stpapi.insert(sync.sess,true,errmsg)
Reply With Quote
  #12  
Old 12th February 2016, 09:12
shashig shashig is offline
Junior Member
 
Join Date: Jul 2009
Location: Jakarta, Indonesia
Posts: 15
shashig is on a distinguished road
Baan: BaaN IV c4, ERP LN 10.3, LN 10.4 - DB: Informix, Oracle, MS-SQL 2008 - OS: Windows and Unix
Try this

function extern long afs.whinh5120m000.insert.lines(domain tcorno i.orno, domain tcitem i.item,
domain tccdis i.adrn, domain tcqst1 i.qvrr,
domain tcclot i.clot, ref string err.msg)
{
long ret, ret1
string line(5), err1
domain tcclot i.lot
long adj.pono

adj.pono = 0
err.msg = ""

stpapi.put.field("whinh5120m100","whinh520.orno", i.orno)
ret = stpapi.find("whinh5120m100", err.msg)
if ret = 1 then
stpapi.handle.subproc("whinh5120m100", "whinh5121m000", "add")
stpapi.put.field("whinh5121m000", "whinh521.orno", i.orno)
stpapi.put.field("whinh5121m000", "whinh521.item.segment.1", i.item(1;9))
stpapi.put.field("whinh5121m000", "whinh521.item.segment.2", i.item(10))
stpapi.put.field("whinh5121m000", "whinh521.adrn", i.adrn)
if is.item.lot.controlled(i.item) then
stpapi.put.field("whinh5121m000", "whinh521.clot", i.clot)
endif
stpapi.put.field("whinh5121m000", "whinh521.qvrr", str$(i.qvrr))
ret = stpapi.insert("whinh5121m000", TRUE, err.msg)
if ret then
stpapi.get.field("whinh5121m000", "whinh521.pono", line)
adj.pono = lval(strip$(line))
stpapi.end.session("whinh5121m000")
stpapi.end.session("whinh5120m100")
return(TRUE)
else
log.in.error.file(err.msg)
stpapi.recover("whinh5121m000", err.msg)
endif
stpapi.end.session("whinh5121m000")
else
log.in.error.file(err.msg)
endif
stpapi.end.session("whinh5120m100")
return(FALSE)
}

Regards,
Shashi
__________________
Regards,
Shashikant Gupta
Reply With Quote
  #13  
Old 12th February 2016, 09:13
shashig shashig is offline
Junior Member
 
Join Date: Jul 2009
Location: Jakarta, Indonesia
Posts: 15
shashig is on a distinguished road
Baan: BaaN IV c4, ERP LN 10.3, LN 10.4 - DB: Informix, Oracle, MS-SQL 2008 - OS: Windows and Unix
Try this

Code:
function extern long afs.whinh5120m000.insert.lines(domain tcorno i.orno, domain tcitem i.item,
								domain tccdis i.adrn, domain tcqst1 i.qvrr,
								domain tcclot i.clot, ref string err.msg)
{
    long ret, ret1
    string line(5), err1
    domain tcclot i.lot
    long adj.pono

    adj.pono = 0
    err.msg = ""

    stpapi.put.field("whinh5120m100","whinh520.orno", i.orno)
    ret = stpapi.find("whinh5120m100", err.msg)
    if ret = 1 then
        stpapi.handle.subproc("whinh5120m100", "whinh5121m000", "add")
        stpapi.put.field("whinh5121m000", "whinh521.orno", i.orno)
        stpapi.put.field("whinh5121m000", "whinh521.item.segment.1", i.item(1;9))
        stpapi.put.field("whinh5121m000", "whinh521.item.segment.2", i.item(10))
        stpapi.put.field("whinh5121m000", "whinh521.adrn", i.adrn)
        if is.item.lot.controlled(i.item) then
            stpapi.put.field("whinh5121m000", "whinh521.clot", i.clot)
        endif
        stpapi.put.field("whinh5121m000", "whinh521.qvrr", str$(i.qvrr))
        ret = stpapi.insert("whinh5121m000", TRUE, err.msg)
        if ret then
            stpapi.get.field("whinh5121m000", "whinh521.pono", line)
            adj.pono = lval(strip$(line))
            stpapi.end.session("whinh5121m000")
            stpapi.end.session("whinh5120m100")
            return(TRUE)
        else
            log.in.error.file(err.msg)
             stpapi.recover("whinh5121m000", err.msg)
        endif
        stpapi.end.session("whinh5121m000")
    else
        log.in.error.file(err.msg)
    endif
    stpapi.end.session("whinh5120m100")
    return(FALSE)
}
Regards,
Shashi
__________________
Regards,
Shashikant Gupta
Reply With Quote
  #14  
Old 12th February 2016, 09:23
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,313
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,

Here is a sample of creating Adjustment Order using DAL.

Code:
dal.new.object("whinh520")
	dal.set.field("whinh520.orno","5")
	dal.set.field("whinh520.cwar","003")
	dal.set.field("whinh520.adrn","XYZ")
	dal.set.field("whinh520.emno","10")
	dal.set.field("whinh520.mnad",tcyesno.yes)
	ret = dal.save.object("whinh520")
	if ret = 0 then
		
		dal.new.object("whinh521")
		dal.set.field("whinh521.orno",whinh520.orno)
		dal.set.field("whinh521.pono",10)
		dal.set.field("whinh521.cwar","1003")
		dal.set.field("whinh521.item","         123456789                            ")
		dal.set.field("whinh521.loca","21")
		dal.set.field("whinh521.clot","0000000001")
		dal.set.field("whinh521.stun","NR")
		dal.set.field("whinh521.qadr",23)
		dal.set.field("whinh521.qrvr",23)
		dal.set.field("whinh521.adrn","ATZZ")
		ret = dal.save.object("whinh521")
		if ret = 0 then
			commit.transaction()
		else
			abort.transaction()
			dal.get.error.message(err)
		endif
		
	else
		abort.transaction()
		dal.get.error.message(err)
	endif

1. How can I trigger the DAL function from my custom MMT session?
- The DAL validations(if present) will automatically get triggered if you use dal.* functions.
2. If I am inserting an adjustment order and the reason I am using AFS is there maybe validation and triggers that need to happen just using simple db.update commands. Will does trigger any DALs related to entering Adjustment orders ?
- If you use db.* functions, the DAL won't be triggered. You need to use only dal.* functions in order to trigger the standard DAL.

For processing sessions i.e. where form commands are involved, you can go fo AFS and if in case you can find the DLL/DAL Business Method related to that, you can call that.

e.g. To process an adjustment order you can call -

Code:
whinh.dll5221.process.adjustment.orders( domain tcorno i.order.from, domain tcorno i.order.to, domain tccwar i.warehouse.from, domain tccwar i.warehouse.to, domain tcemno i.employee.from, domain tcemno i.employee.to, domain tcdate i.order.date.from, domain tcdate i.order.date.to, domain tcpono i.order.line.from, domain tcpono i.order.line.to, boolean i.report.open, boolean i.with.commit, boolean i.progress.indicator, ref long o.number.of.processed.lines )
Refer ttstpbaandoc for the input and output parameters to this DLL.
e.g.

Code:
ret = whinh.dll5221.process.adjustment.orders(

						whinh521.orno,

						whinh521.orno,

						warehouse.from,

						warehouse.to,

						employee.from,

						employee.to,

						order.date.from,

						order.date.to,

						whinh521.pono,

						whinh521.pono,

						false,

						true,

						false,

						dummy.number.of.lines.processed)
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
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
Very nasty work around for an ugly problem AFS finds and updates WRONG RECORD OmeLuuk AFS/DDC/OLE: Function servers 5 17th August 2015 13:21
AFS for Insert record in tirou101 sghatge AFS/DDC/OLE: Function servers 9 21st August 2013 05:41
AFS to insert record in tfgld4582m000 session layswan AFS/DDC/OLE: Function servers 5 5th October 2012 17:42
AFS to insert record in tfgld4582m000 session layswan Tools Development 1 3rd October 2012 15:43
how to insert record in type3 form via AFS??? alibaba AFS/DDC/OLE: Function servers 5 17th September 2004 05:19


All times are GMT +2. The time now is 03:41.


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