adi28_rai
26th October 2010, 15:16
hi
I am inserting data into standard session using AFS and the standard session is sychronized to another maintain session.When i insert data into standard session through AFS by using Synchronize dialog ,then as the first field of standard session is Auto no generation i get an error:
"Change the value of Address code field.\\n\\n Reason:For First Free Number Group ADD, a defined series of length 3 must be entered"
mark_h
26th October 2010, 15:23
This is the correct forum for AFS code. Post the sessions and maybe the code someone might see what is wrong. Having said that - not all sessions are AFS friendly sometimes you have to try different things to get them to work or, in worst case scenarios, actually have to change source code. Do you own source to where you could debug is what is happening?
adi28_rai
26th October 2010, 15:53
choice.insert:
on.choice:
afs=insert_record(tcmsl820.cadr,tcmsl820.name,tcmsl820.dsca,tcmsl820.ccty,tcmsl820.pstc,tcmsl820.seak,tcmsl820.telp,tcmsl820.ccit,tcmsl820.tzid)
if afs=1 then
message("Record Inserted successful")
else
message("Insertion Failed")
endif
===============================
dal coding for auto generation and field validation
function extern long before.open.object.set()
{
return(0)
}
function extern long before.save.object(long type)
{
if not isspace(tcmsl820.cadr) then
tcmsl820.cadr= strip$(tcmsl820.cadr)
select tcmcs050.ffno
from tcmcs050 for update
where tcmcs050._index1 = {"ADD",:tcmsl820.cadr}
selectdo
str.iid=strip$(tcmsl820.cadr) & sprintf$("%@999999@",str$(tcmcs050.ffno))
tcmsl820.cadr=str.iid
tcmcs050.ffno = tcmcs050.ffno + 1
db.update(ttcmcs050,DB.RETRY)
commit.transaction()
selectempty
endselect
else
skip.io("",e)
endif
return(0)
}
function extern long tcmsl820.cadr.make.valid()
{
if strip$(tcmsl820.cadr)<>"ADD" then
tcmsl820.cadr="ADD"
endif
return(0)
}
function extern long tcmsl820.dsca.check()
{
select tccom139.dsca from tccom139
where tccom139.dsca={:tcmsl820.dsca}
selectdo
selectempty
dal.set.error.message("tcCOM")
return(DALHOOKERROR)
endselect
return(0)
}
function extern long tcmsl820.ccty.check()
{
select tccom139.ccty from tccom139
where tccom139.ccty={:tcmsl820.ccty}
selectdo
selectempty
dal.set.error.message("tcCOM")
return(DALHOOKERROR)
endselect
return(0)
}
function extern long tcmsl820.pstc.check()
{
select tccom136.pstc from tccom136
where tccom136.pstc={:tcmsl820.pstc}
selectdo
selectempty
dal.set.error.message("tcCOM")
return(DALHOOKERROR)
endselect
return(0)
}
================================================
Afs in dll:
function extern long insert_record(domain tccom.cadr cadr,domain tcnama nama ,domain tcdsca dsca,
domain tcmcs.st25 ccty,domain tcpstc pstc,domain tcseak seak,domain tctelp telp,domain tccity city,domain tczone tmzn)
{
long ret,ret1,ret2
ret2= stpapi.synchronize.dialog("tccom4530m000","add",error.msg)
if ret2 then
stpapi.put.field("tccom4130s000", "tccom130.cadr", "ADD999999")
stpapi.put.field("tccom4130s000", "tcmcs130.nama", nama)
stpapi.put.field("tccom4130s000", "tcmcs130.dsca", dsca)
stpapi.put.field("tccom4130s000", "tcmcs130.ccty", ccty)
stpapi.put.field("tccom4130s000", "tcmcs130.pstc", pstc)
stpapi.put.field("tccom4130s000", "tcmcs130.seak", seak)
stpapi.put.field("tccom4130s000", "tcmcs130.telp", telp)
stpapi.put.field("tccom4130s000", "tcmcs130.ccit", city)
stpapi.put.field("tccom4130s000", "tcmcs130.tzid", tmzn)
| stpapi.continue.process("tcmcs0510m000", error.msg)
ret = stpapi.insert("tccom4130s000", true, error.msg)
if not ret then
ret1= stpapi.recover("tccom4530m000", recover.msg)
endif
endif
stpapi.end.session("tccom4530m000")
return(ret)
}
mark_h
26th October 2010, 19:07
Well first question - is I know on LN they recommend Dal2 over AFS, but that is your call. I can't help a lot since I do not use LN. The first thing I noticed was the insert command - it should be on the main session. So instead of insert on tccom4130s000 it should be on tccom4530m000. See the example from the baan documentation. The other thing I am not clear on is the main session - I guess I expected a find on it or something before the insert. Also I can only assume all the fields are entered correctly as strings.
stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))
ret = stpapi.find("dtfsa1501m000", error.msg)
if ret then
ret = stpapi.synchronize.dialog("dtfsa1501m000", "modify", error.msg)
if ret then
stpapi.put.field("dtfsa1101s000", "dtfsa101.name", new.name)
ret = stpapi.update("dtfsa1501m000", true, error.msg)
endif
endif