Set Selection for a grid

jdesmm

Well Known Member
We have an application that we'd like to be able to filter by multiple instances of the same field. For instance, we'd like to be able to include multiple branch plants in the grid data returned:

I've set up the find/browse form header as:

Branch Plant 1 [______]
Branch Plant 2 [______]
Branch Plant 3 [______]

Obviously, to use default filtering, you can only add one instance of a business view column, i.e BC Business Unit. So I began looking into the Set Selection system function. However, I can't get it to do anything!

I added three MCU data dictionary fields to the form header as you see in the layout above. I then tried creating the Set Selection statement. Specifically, I did a Clear Selection, then Set Selection Append Flag = "Yes", then the Set Selection statement itself. One thing I was confused about was the Table parameter. It's not clear to me from the JDE documentation what that one should be. I set it to the BC Business Unit column and then set the Alias parameter to the GC Business Unit column, but I'm not sure at all that I'm on the right track. My comparison is to the FC DD Business Unit field and the type is OR. I basically perform the Set Selection 3 times, for each FC field. I've tried placing the code both in the FC Exit & Changed Asycn and the Find Button - Button Clicked ER with no errors but no successful results.

Can anyone give me an example of how to successfully do what I'm trying to do, or is there some reason it can't be done?

Thanks!
--Shelley M. Maas
--Apio, Inc.

*----------------------*
* Shelley M. Maas *
* Development Manager *
* Apio, Inc. *
*----------------------*
 
Shelley,

Here is what I did to select address book fields on the search type (Alias AT1). The value that I select on is entered on the form (FC Search Type - TEST). I place the following instruction in the "Button Clicked" event on the FIND button:

Set Selection Append Flag(FC Grid, <Yes>)
Set Selection(FC Grid, "F0101", "AT1", <Equal To>, FC Search Type - TEST, <None>)

So it seems that the Table field refers to the Table Name (F0101 in my case) and the Alias is the Alias of the field used for the selection (AT1 here).


Hope this helps

Cheers

Philippe

One World B7333 SP18 AS400
 
I haven't tried it personally, but there is a document on doing multiple
filters using the same bsvw column.
Ott-99-0179
 
Hi Shelley,

Please, check the OneWorld On-Line Help about the mentioned System Function. If you haven't browsed this help at all then you will find this help helpfull in other issues too, e.g. about other system functions and about event.

Please, see on the Tips & Traps board on this JDEList Forum about how to acces this help (it is a bit tricky).

I will copy the SetSelection (Interactive) part of this help here for you.

Hope, could be a bit of help.

Regards,

Zoltán
==================================
SetSelection

SetSelection allows you to effect the select that will fill the grid. Each time SetSelection is called, one WHERE clause is created that will be included in the JDB_SetSelection. The database call will not be made at the time the system function is called. Calling the system function only creates the WHERE clause. The information will be stored and used at the time the Find button is clicked.

Parameters

Parameter Description I/O Required Notes
Grid Grid Control I Y
Table Table Name I Y The table and alias parameters are related, together they should describe a field from the grid business view.
Alias Data Dictionary Alias I Y The table and alias parameters are related, together and they should describe a field from the grid business view.
Comparison Type Comparison to be made I Y Type of comparison to be made, for example, equal, not equal, or greater than.
Comparison Value Value to be compared against I Y Value to compare the business view item (table/alias) against. This should be the same type as the business view column.
And/Or Relation to other clauses I Y Yes, No, or None. This defines how this where clause is connected to other where clauses.
Special Handling Instructions and Prerequisites

In general, this System Function should not be used in cases where the user can affect the select (QBE, and filter fields are ways the user can effect the select). If the user can affect the select then the user’s select information should always be taken into consideration. This system function is used in conjunction with SetSelectionAppendFlag to either append or replace the QBE/filter selection with the system function selection.

See Also

Function Name  Function Description  Source Name  Description 
Set Selection Append Flag Appends or replaces the QBE and filter select information with the system function select information.
Clear Selection Removes all system function defined where clauses for the select.
Set Lower Limit Another System Function that can affect the select. Results in a call to JDB_SetLowerLimit instead of JDB_SetSelection.
See Also

SetSequencing
==================================

B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 
Re: RE: Set Selection for a grid

The referred document's TITLE is SOOOOOOOOOOO misleading! Actually it explains how to do multiple INSTANCES of a business column!
" ... You can actually have multiple instances of a Business View Column on a form as long as all but one of them is a filter field."

Xe U3 SP17, Oracle 806, Citrix, HTML, FormScape 2.1 Ent RS/6000, AIX 4.2, Dep NT4
 
Zoltan,

Yes, I had found the system function documentation (thanks to past experience with the tips & tricks section), but did not realize from their description that what they meant by table and alias was the literal values. Phillipe's e-mail cleared that up for me.

*----------------------*
* Shelley M. Maas *
* Development Manager *
* Apio, Inc. *
*----------------------*
 
Re: RE: Set Selection for a grid

Very interesting article. I set up a test application and found that yes, I could add the business column multiple times - so I added my three instances of it and then tried to run the application. It returns no data if I actually fill out more than one of the fields. I've placed a call to JDE on this, because if it could work, this would be a less intrusive solution than having to write the set selection code. Thanks very much for the reference, and I'll let you know if we can get it to work!

*----------------------*
* Shelley M. Maas *
* Development Manager *
* Apio, Inc. *
*----------------------*
 
Re: RE: Set Selection for a grid

But multiple instances is what I'm looking for...the same business view column that can be filtered in multiple ways, i.e.

Business Unit: [3020]
Business Unit: [3040]
Business Unit: [3060]

Grid would then show records for any of the 3 business units above. Are you saying that this is *not* what the article describes?

*----------------------*
* Shelley M. Maas *
* Development Manager *
* Apio, Inc. *
*----------------------*
 
Thank you so much, Phillipe! I didn't understand from the JDE documentation that the table and alias were intended to be literals. That's what I was missing in the equation, and I've now been able to get the Set Selection to work.

*----------------------*
* Shelley M. Maas *
* Development Manager *
* Apio, Inc. *
*----------------------*
 
Shelley,

Glad to hear that you have a solution to your problem.

I had a look at the Multiple Instances of a BSVW column, and found out that if i had twice the same field and filter on it, only the first condition is used:
I inserted AN8 twice on the form and set the filter as "=" for both fields.
Now, at runtime, I enter "4242" on the first field and "4343" on the second one. When I click FIND, I only get "4242" in the Grid.
This seems to be different from the result you get on your side... it may be that we have different SP levels.

Cheers

Philippe

One World B7333 SP18 AS400
 
Shelley,

Silly me, i forgot to explain what I was trying to test with the mutiple instance thing...
It might be that the runtime will try to use the multiple Conditions with and "AND" in between. Obviously what you want is "OR".
And that could explain why you are not getting anything on the Grid.

Could you change your filter conditions your test application and validate that (if you use only 2 filters, one with ">" and one with "<", yiou should be able to select a range of MCUs...)?

Hope this helps

Cheers

Philippe


One World B7333 SP18 AS400
 
In my opinion the filter field on the form always AND with other filter fields in same form in the WHERE clause of the SELECT. if multiple instance of same fields AND with each other then no records will be fetch

Example 1
==========
If form has F4211’s DOCO, DCTO and KCOO as filter fields on the form and user input DOCO = 1234 and DCTO = “SO” and KCOO = “*”
The SELECT statement generated by middleware when Find Button is pressed will be

SELECT ………. FROM F4211 WHERE SDDOCO = 1234 and SDDCTO = “SO”

Example 2
==========
If form has F4211’s DOCO, two instance of DCTO and KCOO as filter fields on the form and user input DOCO = 1234 and DCTO1 = “SO”, DCTO2 = “ST” and KCOO = “*”
The SELECT statement generated by middleware when Find Button is pressed will be

SELECT ………. FROM F4211 WHERE SDDOCO = 1234 and SDDCTO = “SO” and SDDCTO = “ST”

No records will be return by Example 2 as we can’t have same fields AND with each other for equality.

The purpose of allowing same fields more than once on the form for filtering anything except for equality.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

The way around is to use Set Selection and Set Selection Append System function on the grid on Find Button Press event.

In case of Set Selection we have choice of putting OPERATOR between two conditions like OR, AND, NOT but if you use automated filter fields they are always AND by middleware
 
Back
Top