tnzabo
26th June 2012, 23:39
I'm trying to use the stpapi.application.option cmd to call the Application Global option from the Maintain Deliveries session(tdsls4120m000). I first find the order I want to update then call this cmd. It only sets the confirm field to yes for the first record, not all. Any idea what I might be doing wrong? Here is the syntax for my code:

stpapi.application.option(afs.session,1,1,error.msg)
form 1 option 1

Thanks,
NikkiZ

mark_h
27th June 2012, 17:33
I wonder if the find only finds the first record and marks it as the current record. So then the application option only works on the first record. Is it possible the next.set and move thru the records doing this one at a time?

Or maybe try a change view to get the set of records and then the stpapi.application.option command?

We do not use the sls module so won't be much help on those.

tnzabo
27th June 2012, 20:11
Thanks Mark for your response as always! So far neither the next.set,first.set or change.view didn't work. I'm going to try looping through the occurances...

mark_h
27th June 2012, 20:57
Well I did have one session that next.set would not work. I had to loop through the records with a find for each occurance. I can't remember which session that was. I think it had to do with changing the MAUC, but that was a long time ago.

mark_h
27th June 2012, 23:57
Do not know if this helps or not, but this is what I had to do for one program.

stpapi.put.field("ticpr9152m00b", "ticpr952.item", adj.item)
stpapi.put.field("ticpr9152m00b", "ticpr952.cprj", adj.proj)
stpapi.put.field("ticpr9152m00b", "ticpr952.mbcs", str$(adj.mbcs))
rc = stpapi.change.view( "ticpr9152m00b" )
if(rc=1) then
rc = stpapi.browse.set( "ticpr9152m00b", "first.set" )
if(rc<>1) then
errmsg = "No CPC's found for part."
else
stpapi.get.field( "ticpr9152m00b", "mauc.qty", strqty )
rpt.qty = val(strqty)
if rpt.qty > 0 then
while rc = 1
stpapi.get.field( "ticpr9152m00b", "ticpr952.cpcp", cpc )
stpapi.get.field( "ticpr9152m00b", "ticpr952.ptyp", ptyp )
stpapi.put.field( "ticpr9152m00b", "ticpr952.amnt", str$(0) )
stpapi.put.field( "ticpr9152m00b", "ticpr952.hour.c", str$(0) )
stpapi.update( "ticpr9152m00b", 1, errmsg )
if isspace(errmsg) then
rpt.cpc = cpc
rpt.ptyp = ltoe(lval(ptyp))
rprt_send()
endif

rc = stpapi.browse.set( "ticpr9152m00b", "next.set" )
| Do this because the next set is not making the record available
| for update
if rc = 1 then
stpapi.get.field( "ticpr9152m00b", "ticpr952.cpcp", cpc )
stpapi.get.field( "ticpr9152m00b", "ticpr952.ptyp", ptyp )
stpapi.put.field("ticpr9152m00b", "ticpr952.item", adj.item)
stpapi.put.field("ticpr9152m00b", "ticpr952.cprj", adj.proj)
stpapi.put.field("ticpr9152m00b", "ticpr952.mbcs", str$(adj.mbcs))
stpapi.put.field( "ticpr9152m00b", "ticpr952.ptyp", ptyp )
stpapi.put.field( "ticpr9152m00b", "ticpr952.cpcp", cpc )
rc1 = stpapi.find( "ticpr9152m00b" )
endif
endwhile


These sessions can get kind of quirky at times.

tnzabo
28th June 2012, 23:04
The first.set, next.set thing was working pretty well for me - i did a while loop like you have above and it worked well but was sometimes skipping an order and I just couldn't figure out why. as I was debugging the order number was the one it was searching and found but then it updated the next order number. I looked in the afs.log and it returned 'found an other record' for that order instead of 'record found'.

I didn't know how to fix but found another post about entire keys being need to search sometimes. So - instead of doing the first, next.set thing I just put in a prev/curr orno field and I'm setting the position number to increments of 5 and reading through all the delivery lines to confirm deliveries. It seems to work fine and there wasn't much code to it. Thanks for all your help.