timb25
12th April 2005, 17:02
I am trying to maintain outbound using afs. The current problem I have is that once I get to the line -- stpapi.update("tdilc4102s000",1,error.msg), the error.msg indicates "Available inventory is 0.000". However, if I manually enter the same values, the record is saved without any error messages. Any suggestions? Code is below:


error.msg = ""
stpapi.handle.subproc("tdilc4101m000","tdilc4102s000","add")
stpapi.put.field("tdilc4101m000","runnumber", ptilc400.runn)
stpapi.enum.answer("tdilc4101m000","k.o.order", tdilc.kofr.outbound)
stpapi.put.field("tdilc4101m000","ordernr", str$(ptilc400.pdno))
stpapi.continue.process("tdilc4101m000", error.msg)
if not isspace(error.msg) then
stpapi.end.session("tdilc4101m000")
return
endif

stpapi.insert("tdilc4102s000",1,error.msg)
stpapi.enum.answer("tdilc4102s000","tdilc401.koor",tdilc.koob.act.sfc)
stpapi.put.field("tdilc4102s000","tdilc401.orno",str$(ptilc400.pdno))
stpapi.put.field("tdilc4102s000","tdilc401.pono",str$(ptilc400.pono))
seq.num = 0
stpapi.put.field("tdilc4102s000","tdilc401.sera",str$(seq.num))
get.next.seq.num()
stpapi.put.field("tdilc4102s000","tdilc401.serb",str$(seq.num))
stpapi.put.field("tdilc4102s000","tdilc401.item",ptilc400.item)
get.available.lot.location()
stpapi.put.field("tdilc4102s000","tdilc401.clot",tdilc101.clot)
stpapi.put.field("tdilc4102s000","tdilc401.loca",tdilc101.loca)
stpapi.put.field("tdilc4102s000","tdilc401.stun",tdilc101.stun)
stpapi.put.field("tdilc4102s000","tdilc401.qstr",str$(ptilc400.quan))
stpapi.put.field("tdilc4102s000","tdilc401.qsts",str$(ptilc400.quan))
stpapi.continue.process("tdilc4102s000", error.msg)
if not isspace(error.msg) then
stpapi.end.session("tdilc4102s000")
return
endif

stpapi.update("tdilc4102s000",1,error.msg) |<<<--error message occurs here
stpapi.end.session("tdilc4102s000")
stpapi.end.session("tdilc4101m000")


Thanks,
-Tim

mark_h
12th April 2005, 17:31
I really do not understand the first insert or stpapi.enum.answer. My routine is a little different and I hope this helps.


function extern insert_outbound( domain tcmcs.str12 runnumber,
domain tdilc.kooa order.type,
domain tcorno order.number,
domain tcpono order.position,
domain tdilc.loca order.location,
domain tccuni order.stun,
domain tcqiv1 order.qty,
domain tdltc.clot order.lot,
domain tcdate order.date,
ref string strsera(),
ref string strserb(),
ref string msg())
{
msg = ""
stpapi.handle.subproc("tdilc4101m000","tdilc4102s000","add")
stpapi.put.field("tdilc4101m000","runnumber",runnumber)
stpapi.put.field("tdilc4101m000","k.o.order",str$(order.type))
stpapi.put.field("tdilc4101m000","ordernr",str$(order.number))
stpapi.continue.process("tdilc4101m000",msg)
if not isspace(msg) then
stpapi.end.session("tdilc4101m000")
return
endif
stpapi.enum.answer("tdilc4102s000","tdilc4102.1",tcyesno.no)
stpapi.put.field("tdilc4102s000","tdilc401.pono",str$(order.position))
stpapi.put.field("tdilc4102s000","tdilc401.loca",order.location)
| 092404.st - Add lot and date to insert outbound.
stpapi.put.field("tdilc4102s000","tdilc401.clot",order.lot)
stpapi.put.field("tdilc4102s000","tdilc401.date",str$(order.date))
| 092404.end
stpapi.put.field("tdilc4102s000","tdilc401.stun",order.stun)
stpapi.put.field("tdilc4102s000","tdilc401.qstr",str$(order.qty))
rc = stpapi.insert("tdilc4102s000",1,msg)
if isspace(msg) then
stpapi.get.field( "tdilc4102s000", "tdilc401.sera", strsera )
stpapi.get.field( "tdilc4102s000", "tdilc401.serb", strserb )
endif
stpapi.end.session("tdilc4513s000")
stpapi.end.session("tdilc4102s000")
stpapi.end.session("tdilc4101m000")
}

timb25
12th April 2005, 18:30
The first insert was placed there to act as it would be when manually entering a record. Looking at your example, I have it in the wrong place.

The enum.answer (tdilc.koob.act.sfc) might be redundant??

I moved my insert to the same place in your code and now I receive an error message "Position number not allowed."

mark_h
12th April 2005, 19:39
Several things I noticed.

One you should not have to put the order number again. It should already be there in the sub-session. The same for sera and serb - I just let these default. Last I could not even find a question called "tdilc401.koor" on my system - is it really a question on your system? I also do not think you need the continue on tdilc4201s000. Not sure about the update - I have had to do that before. Also validate that the ptilc400.pono is valid.

Another thing to keep in mind - my outbound sessions may be different from yours. Not sure, but you may need new session code.

lbencic
12th April 2005, 19:52
I think the set.enum.answers should be put fields, they are just trying to fill the form fields. set.enum.answer is just for actual questions raised in the script. To just do the put field on an enum field, use (as shown in the API Manual):

stpapi.put.field("tdilc4101m000","k.o.order", str$(etol(tdilc.kofr.outbound)))

Paul P
15th September 2006, 13:21
Hi Mark,
In your code above and in another discussion thread, I saw that you didn't have to manually send tdilc401.sera to tdilc4102m000. In my client's installation (they're on 4.0c4 sp 6), BaanIV asks me to fill that field manually, which requires annoying trial-and-error when done manually. Of course I can find what tdilc402.sera has the line status "Maintain deliveries" first and use that, but if BaanIV can intelligently fill that field in automatically, it'd be a lot easier. Are you working on newer tdilc4203m000 object or did you modify the object on your own so that tdilc402.sera is filled in automatically? Thanks, Mark

Rgds,
Paul

mark_h
15th September 2006, 16:40
We are on 4c4 SP19 A&D 1. To me it looks like sera is always 0 on our system and it skips over the field. I am not sure if this is an A&D feature or what. Some old 4c3 code leaves me to believe that we would not have to input this field. So I am not sure if I answered your question.

Paul P
18th September 2006, 13:16
O, probably you guys always deliver the ordered qty in one go. When multiple partial deliveries are made against an SO line, the tdilc401.sera must be incremented in line with the automatically incrementing tdsls041.srnb. But, thanks, Mark
Rgds,
Paul