soumya093
8th March 2016, 12:22
Hello there
I am getting a problem while deleting lines from a session
I am getting the message at stpapi.find()
Screen shot attached

Ajesh
8th March 2016, 13:25
Hi Soumya

It looks to me a Multi Occurence Session with a View Field,I may be wrong but could you confirm?

And secondly, Are you sure that the error message has come at stpapi.find and not at stpapi.mark.occur?

I think you should use stpapi.change.view instead of stpapi.find..............change.view is used when we are dealing with the view fields ..



stp.api.put.field()
|The Three put field statements and then change view
ret = stpapi.change.view("timfc0101m100,error.message)



And then proceed.

soumya093
8th March 2016, 13:52
Yes I am sure its coming on find ()

mark_h
8th March 2016, 14:50
I have found with 4c4 you have to try both change view and find at times to make sure you get the correct record to modify or delete. Once that is done then the delete,update, etc. tend to work. In this case it looks like it was a synchronized session started. I do not really know enough about the other versions of baan.

PS - Moved to the correct forum.

mark_h
8th March 2016, 14:53
Here is another thread on this topic - http://www.baanboard.com/baanboard/showthread.php?t=67087&highlight=timfc0101 - so take a look at it. Dal might be the way to go - I did not read the whole thread.

soumya093
8th March 2016, 15:29
HI mark

Already tried with DAL but it gives me an error of reference exist with whinh211.

And I want to delete all the lines of timfc001

|******************************************************************************
|* timsl0201m100 0 VRC B61U a7 live
|* Delete Production Order lines with Outstanding Inventory
|* Installation user
|* 2016-03-05
|******************************************************************************
|* Main table timfc001 Production Warehouse Orders, Form Type 1
|******************************************************************************

|****************************** declaration section ***************************
declaration:

table ttimfc001 | Production Warehouse Orders
table ttisfc001

extern domain tcorno prno.f
extern domain tcorno prno.t
extern domain tcdate pdat.f
extern domain tcdate pdat.t

extern domain tcmcs.str80 er.ms
extern domain tcmcs.str60 error
extern domain tcpono count.no

extern domain tcmcs.s132m err.mess mb
#pragma nowarnings
#include <bic_dam>
#pragma used dll ottdllbw
#pragma used dll ottstpapihand
|****************************** program section ********************************


|****************************** group section **********************************

group.1:
init.group:
get.screen.defaults()

|********************************** Field section ***********************

field.prno.f:

when.field.changes:
prno.t = prno.f

before.zoom:
query.extend.where.in.zoom("tisfc001.osta = " & "tcosta.completed")

check.input:
if prno.f(1;3) <> "YDY" then
message("Production Order should be of YDY series")
set.input.error("")
endif
field.prno.t:

before.zoom:
query.extend.where.in.zoom("tisfc001.osta = " & "tcosta.completed")

field.pdat.f:

when.field.changes:
pdat.t = pdat.f

check.input:
if prno.t(1;3) <> "YDY" then
message("Production Order should be of YDY series")
set.input.error("")
endif

|******************************** Choice Section **********************

choice.Update:
before.choice:
check.all.input()
on.choice:
update.data()
if count.no > 1 then
message("Updated")
endif



|******************************* Function Section ******************

functions:

function update.data()
{
long i, rt1, retval, ret_val,ret
count.no = 0
select tisfc001.*
from tisfc001
where tisfc001._index1 inrange {:prno.f} and {:prno.t}
and tisfc001.cmdt between {:pdat.f} and {:pdat.t}
and tisfc001.osta = tcosta.completed
and tisfc001.pdno(1;3) = "YDY"
order by tisfc001._index1
selectdo
select timfc001.*
from timfc001 for update
where timfc001._index1 = {:tisfc001.pdno}
order by timfc001._index1
selectdo
ret_val = dal.destroy.object("timfc001")
if ret_val = 0 then
commit.transaction()
count.no = count.no + 1
| close.prod.order()
| message("Record Deleted")
else
rt1 = dal.count.error.messages()
for i = 1 to rt1
ret_val = dal.get.error.message(error)
er.ms = error

endfor
abort.transaction()
endif
endselect
| close.prod.order()
| ret = close.production.order(tisfc001.pdno,
| utc.num(),
| tcyesno.no,
| tcyesno.no,
| tcyesno.no,
| tcyesno.no,
| #LND-10206.so
| tcyesno.no, |#214831.n
| #LND-10206.eo
| tiusec.home.ref,
| "INR")
selectempty
message("No data within selection")
endselect

}

function close.prod.order()
{

| long ret
| stpapi.put.field("tisfc0501m000","tisfc001.pdno",str$(tisfc001.pdno))
| ret = stpapi.find("tisfc0501m000",err.mess)
| if ret = 1 then
| ret = stpapi.mark("tisfc0501m000",err.mess)
| if ret = 1 then
| stpapi.handle.subproc("tisfc0501m000","ticst0201m000","modify")
|stpapi.form.command("tisfc0501m000",2,"ticst0201m000",err.mess)
| if isspace(err.mess) then
| stpapi.continue.process("ticst0201m000",err.mess)
| stpapi.put.field("ticst0201m000","pdno.f",tisfc001.pdno)
| stpapi.put.field("ticst0201m000","pdno.t",tisfc001.pdno)
| stpapi.set.report("ticst0201m000","rticst020102000","D", err.mess)

| stpapi.set.report("ticst0202m000","rticst020102000","T", err.mess)
| stpapi.form.command("ticst0201m000",5,"continue.process",err.mess)

| stpapi.continue.process("ticst0201m000",err.mess)
| stpapi.print.report("ticst0201m000", err.mess)
| endif
| stpapi.end.session( "ticst0201m000" )
|endif
|endif
| stpapi.end.session( "tisfc0501m000" )

}

| function extern long close.production.order(
| domain tcpdno i.prod.order,
| domain tcutcs i.closing.date,
| domain tcyesno i.print.report,
| domain tcyesno i.simulate.only,
| domain tcyesno i.res.without.closing,
| domain tcyesno i.calc.off.var,
| #LND-10206.so
| domain tcyesno i.eff.var.wip.trans, |#214831.n
| #LND-10206.eo
| domain tiusec i.print.usec,
| domain tcccur i.print.ccur)
| {
| DllUsage
| Expl. : This BM closes the Production Order financially.
| It is also possible to simulate the Closure of the
| Production Order. Also, it is possible to calculate
| the results without actually closing the Production
| Order, in which case the estimates are corrected to
| the extent of the actuals.
| Pre : If ORDER-CLOSURE, tisfc001 record should be current
| and delayed lock must have been issued on it, since
| its order status and Closing Date is updated in
| this dll.
| If ORDER_CLOSURE is to be simulated, Simulation
| Report must be open, and i.print.ccur must
| be filled.
| Post : Commit should be given after the call to this BM
| if SUCCESSFUL
| Error Report Printing is possible by popping
| the dal.set.error.messages.
| Possible Financial Transactions are printed if
| Order Closing is simulated.
| Input : i.prod.order - Production Order.
| i.closing.date - Closing Date.
| i.print.report - Print Report.
| i.simulate.only - Simulate Closing and Print the
| possible Financial Transactions if
| actually closed.
| i.res.without.closing - Log financial Transactions without
| closing the Production Order.
| i.calc.off.var - if i.res.w/o.closing = Yes:
| No: only determine price and eff.var.
| Yes: also determine calc. office var.
| #214831.sn |#LND-10206.so
| i.eff.var.wip.trans - if i.res.w/o.closing = Yes:
| No: only determine price and eff.var.
| Yes: also determine eff.var.wip.trans.
| #214831.en |#LND-10206.eo
| i.print.usec - User Currency.
| i.print.ccur - Currency used to print Totals
| if closing is simulated.
| Output : -
| Return : 0 - Closing/Simulation done Successfully.
| DALHOOKERROR - Order cannot be Closed.
| Order Closure: dal.err.messages are
| set here stating why Order cannot
| be closed. The calling program
| should trap DALHOOKERROR and can
| pop the error messages to display
| them onto the error report.
| EndDllUsage

| RETIFNOK(ticst.dll0004.close.production.order.or.operation(
| i.prod.order,
| false,
| 0,
| i.closing.date,
| i.print.report,
| i.simulate.only,
| i.res.without.closing,
| i.calc.off.var,
| #LND-10206.so
| i.eff.var.wip.trans, |#214831.n
| #LND-10206.eo
| i.print.usec,
| i.print.ccur)


| RETURN(0)
| }

Ajesh
9th March 2016, 03:38
Did you try it with stpapi.change.view?

soumya093
9th March 2016, 10:38
Yes I tried
look at the code

select tisfc001.*
from tisfc001
where tisfc001._index1 inrange {:prno.f} and {:prno.t}
and tisfc001.cmdt between {:pdat.f} and {:pdat.t}
and tisfc001.osta = tcosta.completed
and tisfc001.pdno(1;3) = "YDY"
order by tisfc001._index1
selectdo

select timfc001.*
from timfc001
where timfc001._index1 = {:tisfc001.pdno}
| and timfc001.pono <> 0
order by timfc001._index1
selectdo
stpapi.put.field("timfc0101m100","timfc001.pdno",tisfc001.pdno)
stpapi.put.field("timfc0101m100","timfc001.pono",str$(timfc001.pono))
stpapi.put.field("timfc0101m100","timfc001.seqn",str$(timfc001.seqn))

ret = stpapi.find("timfc0101m100",err.mess)
ret = stpapi.change.view("timfc0101m100",err.mess)
if ret = 1 then

ret = stpapi.mark("timfc0101m100",err.mess)

if ret = 1 then
ret = stpapi.delete("timfc0101m100",true,err.mess)
if not ret then
stpapi.recover("timfc0101m100",err.mess)
endif

endif
endif

endselect
stpapi.end.session("timfc0101m100")

soumya093
9th March 2016, 10:43
Here is the screen shot I got

Ajesh
9th March 2016, 11:11
You need to comment out stapi.find...Just use stpapi.change.view("tisfc0101m100",err.mess)

mark_h
9th March 2016, 15:50
One of the things I find helpful is to run ttstpcreatdll on a session. This gives me an idea of what all commands baan thinks will work on the session. As mentioned try just the change.view first and confirm the return value is 1. Have to get past that first. And yes there was one case where I had to do change.view followed by a find to make sure I had the right record.

Then after that if you want to delete all the records - try a stpapi.browse.set(session name, "first.set",err.message). To try to get the first record and move thru the records one at a time.

Ajesh
10th March 2016, 08:08
Yes,even I think it makes sense to do a stapi.find after stapi.change.view. The ideal way to go about should be put the fields of the Index in the session and then do stpapi.change.view and then go to the exact record using stpapi.find and then perform stpapi.mark.occur and then perform stpapi.delete.

But before all that,understanding the structure of tables is very necessary. Is it a Multi Occurence with view Field? Please copy paste the Multi-occurence Session first. There is not a quick fix to some problems as many people believe.