View Single Post
  #1  
Old 10th February 2016, 20: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