heartbeat
5th August 2016, 06:07
stpapi.put.field("tccom4130s000","tccom130.cadr",str$(p.cadr))
stpapi.put.field("tccom4130s000","tccom130.nama",str$(f.addr.nama))
stpapi.put.field("tccom4130s000","tccom130.ccty",str$(f.ccty))
stpapi.put.field("tccom4130s000","tccom130.pstc",str$(f.pstc))
stpapi.put.field("tccom4130s000","tccom130.cste",str$(f.cste))
stpapi.put.field("tccom4130s000","tccom130.ccit",str$(f.ccit))
stpapi.put.field("tccom4130s000","tccom130.tzid",str$(f.tzid))
stpapi.put.field("tccom4130s000","tccom130.telp",str$(f.telp))
stpapi.put.field("tccom4130s000","tccom130.tefx",str$(f.tefx))
stpapi.put.field("tccom4130s000","tccom130.vatl",str$(f.vatl))
stpapi.put.field("tccom4130s000","tccom130.coaf",str$(f.coaf))
stpapi.put.field("tccom4130s000","tccom130.ln01",str$(f.ln01))
stpapi.put.field("tccom4130s000","tccom130.ln02",str$(f.ln02))
stpapi.put.field("tccom4130s000","tccom130.ln03",str$(f.ln03))
stpapi.put.field("tccom4130s000","tccom130.ln04",str$(f.ln04))
stpapi.put.field("tccom4130s000","tccom130.ln05",str$(f.ln05))
stpapi.put.field("tccom4130s000","tccom130.ln06",str$(f.ln06))
result = stpapi.insert("tccom4130s000",true,error.msg)
if result = 1 then
result = stpapi.enum.answer("tccom4130s000","tccom4130.1",tcyesno.yes)
else
result = stpapi.recover("tccom4130s000",error.msg)
endif


I want to add new address but the telephone is duplicate. Please recommend click ok for dailog.

bhushanchanda
5th August 2016, 14:42
Hi,

Try DAL wherever possible ->


dal.new.object("tccom130")
dal.set.field("tccom130.cadr",str$(p.cadr))
dal.set.field("tccom130.nama",str$(f.addr.nama))
dal.set.field("tccom130.ccty",str$(f.ccty))
dal.set.field("tccom130.pstc",str$(f.pstc))
dal.set.field("tccom130.cste",str$(f.cste))
dal.set.field("tccom130.ccit",str$(f.ccit))
dal.set.field("tccom130.tzid",str$(f.tzid))
dal.set.field("tccom130.telp",str$(f.telp))
dal.set.field("tccom130.tefx",str$(f.tefx))
dal.set.field("tccom130.vatl",str$(f.vatl))
dal.set.field("tccom130.coaf",str$(f.coaf))
dal.set.field("tccom130.ln01",str$(f.ln01))
dal.set.field("tccom130.ln02",str$(f.ln02))
dal.set.field("tccom130.ln03",str$(f.ln03))
dal.set.field("tccom130.ln04",str$(f.ln04))
dal.set.field("tccom130.ln05",str$(f.ln05))
dal.set.field("tccom130.ln06",str$(f.ln06))

ret = dal.save.object("tccom130")
if ret = 0 then
commit.transaction()
else
dal.get.error.message(error.msg)
abort.transaction()
endif

bhushanchanda
5th August 2016, 15:12
And, in case if you need to have AFS, you need to trick the session script to go with DAL flow. To do that, just answer the question before putting any fields and use a second insert if the first one fails->

stpapi.enum.answer("tccom4130s000","tccom4130.1",tcyesno.yes)
stpapi.put.field("tccom4130s000","tccom130.cadr",str$(p.cadr))
stpapi.put.field("tccom4130s000","tccom130.nama",str$(f.addr.nama))
stpapi.put.field("tccom4130s000","tccom130.ccty",str$(f.ccty))
stpapi.put.field("tccom4130s000","tccom130.pstc",str$(f.pstc))
stpapi.put.field("tccom4130s000","tccom130.cste",str$(f.cste))
stpapi.put.field("tccom4130s000","tccom130.ccit",str$(f.ccit))
stpapi.put.field("tccom4130s000","tccom130.tzid",str$(f.tzid))
stpapi.put.field("tccom4130s000","tccom130.telp",str$(f.telp))
stpapi.put.field("tccom4130s000","tccom130.tefx",str$(f.tefx))
stpapi.put.field("tccom4130s000","tccom130.vatl",str$(f.vatl))
stpapi.put.field("tccom4130s000","tccom130.coaf",str$(f.coaf))
stpapi.put.field("tccom4130s000","tccom130.ln01",str$(f.ln01))
stpapi.put.field("tccom4130s000","tccom130.ln02",str$(f.ln02))
stpapi.put.field("tccom4130s000","tccom130.ln03",str$(f.ln03))
stpapi.put.field("tccom4130s000","tccom130.ln04",str$(f.ln04))
stpapi.put.field("tccom4130s000","tccom130.ln05",str$(f.ln05))
stpapi.put.field("tccom4130s000","tccom130.ln06",str$(f.ln06))
error.msg = ""

result = stpapi.insert("tccom4130s000",true,error.msg)
if not isspace(error.msg) then
result = stpapi.insert("tccom4130s000",true,error.msg)
endif

if result = 1 then
result = stpapi.end.session("tccom4130s000",error.msg)
else
result = stpapi.recover("tccom4130s000",error.msg)
endif

heartbeat
8th August 2016, 10:38
Hi,

Try DAL wherever possible ->


dal.new.object("tccom130")
dal.set.field("tccom130.cadr",str$(p.cadr))
dal.set.field("tccom130.nama",str$(f.addr.nama))
dal.set.field("tccom130.ccty",str$(f.ccty))
dal.set.field("tccom130.pstc",str$(f.pstc))
dal.set.field("tccom130.cste",str$(f.cste))
dal.set.field("tccom130.ccit",str$(f.ccit))
dal.set.field("tccom130.tzid",str$(f.tzid))
dal.set.field("tccom130.telp",str$(f.telp))
dal.set.field("tccom130.tefx",str$(f.tefx))
dal.set.field("tccom130.vatl",str$(f.vatl))
dal.set.field("tccom130.coaf",str$(f.coaf))
dal.set.field("tccom130.ln01",str$(f.ln01))
dal.set.field("tccom130.ln02",str$(f.ln02))
dal.set.field("tccom130.ln03",str$(f.ln03))
dal.set.field("tccom130.ln04",str$(f.ln04))
dal.set.field("tccom130.ln05",str$(f.ln05))
dal.set.field("tccom130.ln06",str$(f.ln06))

ret = dal.save.object("tccom130")
if ret = 0 then
commit.transaction()
else
dal.get.error.message(error.msg)
abort.transaction()
endif

Thank you very much.