showstuff11
22nd March 2015, 11:32
my quest is to find the missing number in a series using baan
lets say i have a series of 1-100 and assuming 99, 26, 56 are the missing numbers.
how can i program this?
using this table
tfgld018.ttyp,|Transaction Type
tfgld018.docn, | Document # (in this example this fields "skips" like 1,2,3,4,6)
tfgld018.dcdt, | Document Date
tfgld018.stat | Document Status
table ttfgld018 |document history
select tfgld018.ttyp, tfgld018.docn, tfgld018.dcdt, tfgld018.stat
from tfgld018
where tfgld018.stat <> "Used"
selectdo
endselect
in light of this i have device a solution but i can only explain it and i cannot translate it to code yet
so here goes:
lastdocnumber = tfgld018.docn(last used doc #)
status
while counter <= lastdocnumber
if counter = tfgld018.docn then
status = "Found"
else
status = "Missing"
endif
counter = counter + 1
Loop
Display tfgld018.docn where status = "Missing"
i hope you understand!!
TIA!
Thanks BAANBOARD!! my learning is much easier with people helping in this community/forum
mark_h
23rd March 2015, 17:23
Are you looking to write a report or a display session?
showstuff11
24th March 2015, 01:55
Sorry did not mention it...
I am writing a report..
thanks!
bhushanchanda
24th March 2015, 10:23
Hi,
Try this -
domain tfgld.docn first.docn
domain tfgld.docn last.docn
string status(10)
|Lets assign the smallest value to first.docn
first.docn = 13000001
|Lets assign the biggest value to last.docn
last.docn = last_used_document | This can be taken from table tfgld017
while(first.docn <= last.docn)
select tfgld018.*
from tfgld018
where tfgld018._index1 = {:your_document_type,:first.docn}
selectdo
status = "Found"
selectempty
status = "Not found"
endselect
rprt_send()
first.docn = first.docn + 1
endwhile
You can put fields, your_document_type,first.docn and status on your report.
mark_h
24th March 2015, 13:55
Bhusan posted something along the lines of what I was thinking. You can also get the first.docn from querying tfgld018. You could use a sort on document number(not sure that is needed not familiar enough with tfgld018) and as set with 1 rows - that would get the first document for the document type.
showstuff11
25th March 2015, 03:46
@bhushan
i tried your code
first.docn = 0
last.docn = tfgld017.docn
while first.docn <= last.docn
select tfgld018.*
from tfgld018
where tfgld018._index1 = {:transtype,:first.docn}
selectdo
if tfgld018.stat = tfgld.dstt.used then
status = "deleted"
docnumber = tfgld018.docn
endif
selectempty
status = "missing"
docnumber = tfgld018.docn
endselect
rprt_send()
first.docn = first.docn + 1
endwhile
but the problem is the compiler does now read the while loop
it just skips then end go to endwhile
and ending it with a message "no data within selection"
but i have 78 records present in my table tfgld018 with a status of "used"
does program script don't allow loop in it?
bhushanchanda
25th March 2015, 10:08
Hi,
Debug your code and check what is the value for tfgld017.docn before going to while condition. Make sure its not 0. Debugging is the best way to identify the problems in your code.
vamsi_gujjula
25th March 2015, 10:28
Here is the script , i had similar requirement for ecedi702.bano of a particular BP .
i have just queried ecedi702 and handled it in the report script
you can check the logic below
| ****************************** declaration section ***************************
declaration:
domain tcmcs.str35 bano, bano.t, prev.bano ,org.bano ,format
long bano.l.f ,bano.l.t , leng
domain tcbool called.aft.lay , data.prensent
before.program:
bano.t = ""
prev.bano = ""
called.aft.lay = false
data.prensent = false
detail.1:
before.layout:
if not called.aft.lay then
org.bano = ecedi702.bano
bano.l.f = 0
bano.l.t = 0
if lval(org.bano) <> 0 then
bano.l.f = lval(org.bano)
select ecedi702.bano:bano.t
from ecedi702
where ecedi702._index1 = {:ecedi702.bpid}
| and ecedi702.orno = :ecedi702.orno
and ecedi702.bano > :org.bano
order by ecedi702.bano
selectdo
if lval(bano.t) <> 0 then
bano.l.t = lval(bano.t)
break
endif
selectempty
lattr.print = false
endselect
if bano.l.t <> 0 then
if bano.l.t - bano.l.f > 1 then
bano.l.f = bano.l.f + 1
set.mem(format,"9",len(trim$(bano.t)))
ecedi702.bano = edit$ (bano.l.f,format)
data.prensent = true
else
lattr.print = false
endif
else
lattr.print = false
endif
else
lattr.print = false
endif
else
bano.l.f = bano.l.f + 1
set.mem(format,"9",len(trim$(bano.t)))
ecedi702.bano = edit$ (bano.l.f,format)
data.prensent = true
endif
after.layout:
if lval(org.bano) <> 0 then
if bano.l.f < bano.l.t-1 then
called.aft.lay = true
layout.again()
else
called.aft.lay = false
endif
endif
after.report.1:
before.layout:
long info(PSMAXSIZE)
string progname(25)
if not data.prensent then
pstat(PID,progname,info)
if trim$(progname) = "rgbsqlecedi7020" then
kill(pid)
endif
endif