halvorn
25th February 2002, 16:10
Hi,
I know about the possibility of using Enumerated domains as the domain for form fields, to get List boxes.
But is it possible to use List boxes that have their "list items" populated from a table, not from a static domain ?

Best regards
Halvor

Smiffy
25th February 2002, 17:18
I have done this many times. You need to create a new table for the required field(s). You then need a maintain session (if you wish users to update the entries) & you need a display session based on the table (remember to use 's' in the name instead of 'm')

You can then set a zoom to this new display session on the field (in your form).


cheers

steveauckly
25th February 2002, 18:42
You may use 3GL to accomplish this. It is a lot to learn if you haven't used it before, but you get a LOT more control of your programs. It is too much to explain in this forum, but it is well documented in Baan's help.

~Vamsi
26th February 2002, 00:25
Untried code. Please share your finished code for everyone to use.
table ttcmcs003

domain tccwar cwar(999)
domain tcdsca cwar.dsca(999)
domain tcmcs.long total.cwar

extern domain tccwar mycwar |formfield
|* setup the above field to zoom to tcmcs0503m000 with a return
|* value of tcmcs003.cwar. This is the field which has the listbox!

field.mycwar:
before.zoom:
long listbox.choice, i

for i = 1 to total.cwar
cwar(1, i) = ""
cwar.dsca(1, i) = ""
endfor
total.cwar = 0

select tcmcs003.*
from tcmcs003
where tcmcs003.typw = tctypw.normal | FTS!!!
selectdo
total.cwar = total.cwar + 1
cwar(1, total.cwar) = tcmcs003.cwar
cwar.dsca(1, total.cwar) = tcmcs003.dsca
endselect

listbox.choice = handle.listbox(0, 0, total.cwar, cwar.dsca)
|Use the warehouse description in the list box

if listbox.choice > 0 then
mycwar = cwar(1, listbox.choice)
| Use the warehouse code here!
input.again()
endif


If the code does not compile (very likely on Baan IV), put this line in the code:

#pragma used dll ottdllxxxxxxxx

where xxxxxx is something like "handlistbox". Go looking for a file which matches $BSE/tools/ttB*/ottdll/odll* where the second * is "handlistbox" or something close.

tsanchez
26th February 2002, 10:45
Please if any of you finds out which name the object has, post
it here and share it with us. I'll try the trick as soon as I get a
spare moment at work. I've browsed through the object files
and no one resembled what our friend suggested.

Thanks in advance.

Tomas Sanchez Tejero
deckard@encomix.es

halvorn
26th February 2002, 13:03
Hi, thanks for answering.
Do you have more information about the handle.listbox function. The session hangs/crashes when calling it.

halvorn
27th February 2002, 10:02
that works,

declaration:

table ttccom020 | Customers
string suno.no(6,100)
string suno.nama(35,100)
domain tcmcs.long suno.total
domain tcnama suno.selected
long listbox.choice
long i


field.frm.transporter:
before.zoom:

PutSomeCustomerInListBox()



Function PutSomeCustomerInListBox()
{

FOR i = 1 to suno.total STEP 1
suno.no(1,i) = ""
suno.nama(1,i) = ""
ENDFOR

suno.total = 0

select tccom020.suno,tccom020.nama
from tccom020
where tccom020.cbrn = " X/2"
selectdo
suno.total = suno.total + 1
suno.no(1,suno.total) = tccom020.suno
suno.nama(1,suno.total) = tccom020.nama
endselect
|message(str$(suno.total))

|Use the Supplier name in the list box
listbox.choice = handle.listbox(0, 0, suno.total, suno.nama)
frm.transporter=suno.nama(1, listbox.choice)
if listbox.choice > 0 then
|suno.selected = suno.no(1, listbox.choice)
input.again()
endif

}

shah_bs
27th February 2002, 17:27
Just for my education here - why so much coding?

Would it not suffice to just generate a BAAN sub-session with the desired fields and attach it to the field in the (target) session where it is required to query on the code? I would think it would have many advantages, not the least of which are there is no code!

~Vamsi
27th February 2002, 19:04
I guess I should have asked the question myself. It is not Baan standard to use listboxes within a session. There are a few exceptions.

I posted the code as a demonstration of the feature. If there is a main table available, I would do what Shah recommends.

There was an instance where I toyed with the idea of using the listbox though. I had a field almost 1000 characters long. This held a bunch of email addresses separated by "," or ";". I wanted the ability to see them each on their own line like in a list box. I did some investigation at that time. But the session was not for endusers but only for sysadmins and the effort did not seem worth it.

halvorn
28th February 2002, 09:19
Hi
Coding is fun
and
in this case only 9 customers have the relevant "Line Of business", so I think that it is faster to Pick one out of nine from a listbox rather than start a session, clik the "Move record" button or perform a search.

~Vamsi
28th February 2002, 19:24
Halvor,

I don't deny that coding is fun :). Just to keep with Baan standard look and feel, one should use sessions to zoom to. To the point that only a few customers meet the criteria, one can use the query.extension (called session) in Baan IV and query.extend.where.in.zoom (calling session) in BaanERP to filter out the unwanted records.

I wish Baan back-ported query.extend.* functions to Baan IV.

RobertB
21st August 2002, 17:15
Hi Halvor,

I read your thread while looking for some help on creating listboxes. Not being able to find much, I decided to try this myself on a simple Report form and, after a couple of days(!) effort, came up with the following, which you may find interesting:

string a.months(20, 12), lb.title(30)
long lb.x.pos, lb.y.pos, lb.width, lb.height, ii, num.days, ignore.val, list.box
long year.num, month.num, day.num, hours, mins, secs, sel.item
long color.red, color.neutral.old, color.neutral.new

#pragma used dll otctaddll0002 | This is the listbox dll (see below)...

form.1:
init.form:

lb.title(1) = "Monat:"
for ii = 1 to 12
num.days = date.to.num(2002, ii, 1)
a.months(1, ii) = sprintf$("%D(%10H)", num.days)
endfor

ignore.val = utc.to.date(utc.num(), year.num, month.num, day.num, hours, mins, secs)
sel.item = month.num
lb.x.pos = 10
lb.y.pos = 60
lb.width = 215
lb.height = 45

color.red = rgb(255, 0, 0)
color.neutral.old = rgb(192, 192, 192)
color.neutral.new = rgb(214, 211, 206)

list.box = tctaddll0002.create.dropdown.listbox(lb.title, a.months, sel.item, lb.x.pos, lb.y.pos, lb.width, lb.height, color.neutral.new)

get.screen.defaults()

|****************************** choice section ********************************

choice.cont.process:
on.choice:
execute(print.data)

choice.print.data:
on.choice:
month.num = 0
| Get the return index from the listbox...
if get.object(list.box, DsNselectedId, month.num) then
if rprt_open() then
| Do something with the result, like.....
read.main.table()
rprt_close()
else
choice.again()
endif
else
message("Cannot access listbox object %d", list.box)
choice.again()
endif

Now, you need to create a new DLL (I called mine tctaddll0002, "Object Functions"), and paste the following in it:

|******************************************************************************
function extern long tctaddll0002.create.dropdown.listbox(ref string i.title, ref string i.list(,),
long i.sel.item, long i.x.pos, long i.y.pos,
long i.width, long i.height, long i.bkg.color)
{

dllusage
purpose: Enables a dropdown listbox to be created and shown at a certain position on a Baan form.

in: i.title --> Title, to be displayed as a label to the left of the listbox.
i.list --> List of elements.
i.sel.item --> Element to be selected when the listbox first shows.
i.x.pos --> X-position in pixels from the left-hand edge of the form
i.y.pos --> Y-position in pixels from the bottom of the form title-bar
i.width --> Width of the listbox in pixels
i.height --> Height of the listbox in pixels
i.bkg.color --> background color of the containing graphical window object
(to be used when setting-up, since the exact extent of the
container can then be established; once the correct size has
been decided on, this color should be set to some neutral shade).

out: list.box --> object-ID of the listbox.
enddllusage


long ignore.val, g.win, row.col, list.box, nr.dims, dim.array(4), obj.label, lbl.width
long ii, space.len, max.index.len, this.index.len, insert.pos, list.len
string list.items(1000), this.item(50), this.index(3)
double max.len, this.len


| Create a graphical window object to act as container for all subsequent objects......
g.win = create.object(DsCgwindow, current.mwindow(),
DsNbackground, i.bkg.color,
DsNx, i.x.pos,
DsNy, i.y.pos,
DsNwidth, i.width,
DsNheight, i.height )

| Create the RowCol object as container for the label and listbox....
row.col = create.object(DsCrowColumn, g.win,
DsNvspace, 10,
DsNhspace, 10,
DsNnumColumns, 2,
DsNfixedDimension, DSHORIZONTAL )

| Create the label.....
obj.label = create.object(DsClabel, row.col,
DsNstring, i.title )

| Create the listbox........
array.info(i.list, nr.dims, dim.array)
if (nr.dims = 2) then | OK...
| Reference : dim.array(1): length of strings
| dim.array(2): no. of strings in the list
if ((dim.array(1) > 0) and (dim.array(2) > 0)) then

| First find the longest string in the array.....
max.len = 0
for ii = 1 to dim.array(2)
this.len = len(strip$(i.list(1, ii)))
max.len = max(max.len, this.len)
endfor

| Build the long items string with "-"'s as placeholders.............
list.items = ""
max.index.len = len(shiftl$(strip$(str$(dim.array(2)))))
for ii = 1 to dim.array(2)

| Item...
this.item = shiftl$(strip$(i.list(1, ii)))
this.len = len(this.item)
space.len = max.len - this.len
this.item = this.item & ((space.len > 0) ? string.set$(" ", space.len) : "") & "-"

| Item Index...
this.index = shiftl$(strip$(str$(ii)))
this.index.len = len(this.index)
space.len = max.index.len - this.index.len
this.index = this.index & ((space.len > 0) ? string.set$(" ", space.len) : "") & "-"

| Long String.....
list.items = list.items & this.item & this.index

endfor
list.len = len(list.items)

| Insert the "null bytes" at the place-holder positions...........
insert.pos = 0
for ii = 1 to dim.array(2)
insert.pos = insert.pos + max.len + 1
store.byte(0, list.items(insert.pos))
if (ii < dim.array(2)) then
insert.pos = insert.pos + max.index.len + 1
store.byte(0, list.items(insert.pos))
endif
endfor


| Finally, create the listbox........
list.box = create.object(DsCdDListBox, row.col,
DsNminWidth, 50,
DsNminWindowSize, 1,
DsNmaxWindowSize, dim.array(2),
DsNx, i.x.pos,
DsNy, i.y.pos,
DsNstringArray, list.items, list.len,
DsNselectedId, i.sel.item )
update.object(g.win)

else

endif
else

endif


return(list.box) | Return value is the listbox-ID or zero.......

}

This DLL code can be improved on - there's still some stuff in there from testing but, as you say, coding is fun, and I'm sure you can come up with some other ideas!

HTH,
RobertB

jaapzwaan
21st August 2002, 17:39
Look http://www.baanboard.com/programmers_manual_baanerp_help_functions_form_and_form_field_operations_set_list_values_for_field

~Vamsi
21st August 2002, 18:00
Jaap,

Any possibility that the cool features in 5.2 will be back-ported, esp. into Baan IVc4?

RobertB
21st August 2002, 18:02
Yep - that's how it should be! However, 5.2 is still a year away for us :(
But this was, for me, just a first exploration in the Wonderful World of Baan Objects :D - and, as you can see, the user only has to issue a one-line call to a function to get the listbox.

lwnkor0
16th March 2005, 11:38
Hello,

i can not find the object handle.listbox in our system.
In $BSE/tools/ttB*/ottdll/odll* there is no file like handle.listbox!
Where can i find or get it????

Thank you!

greats