cancel
Showing results for 
Search instead for 
Did you mean: 

Multiselect Listbox (iBrowser Applet)

Former Member
0 Kudos

Hi,

I am working with multiselect listboxes (ibrowser applets). Listbox1 and Listbox2. I need to move information to an from Listbox1. I use <remove item> and <add item> to do this without affecting the underlying database table. This works fine.

My question is this. When the user is finally done manipulating the listboxes and selects <Save Changes>, how do I update the underlying database? Should I store the original listbox info in an array and then store the final listbox entries in another array, compare and determine a <Insert> or <Delete> to the database accordingly? Should I use a XACUTE? If so, how does that work? I am new to xMII. XACUTE seems to be much for such a simple evolution. Another xMII developer within my company seems to think XACUTE. Unfortunately that person is unavailable right now.

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kelly,

Where do you want this data to be updated? SAP or non-SAP database?

If you are updating SAP, you must use Xacute query which in turn calls a business logic transaction that executes a remoted enabled function to update the database.

If the case of non-SAP database, SQL query will do the task for you.

In your case, since you have to make multiple updates I would reccomend you to use a stored procedure and pass the insert/update values as parameters (comma separated strings or so).

Steps:

1) Create the stored procedure

2) Create a fixed query that calls the stored procedure

3) Create an icommand applet in your web page (set size as 1) using the above fixed query and with InitialUpdate set to false,

4) Perform the update by using executeCommand()

Example:

if(document.<<appletname>>.executeCommand()) {

alert("Success"); // Display a message if required

} else {

alert(document.<<appletname>>.getLastError());

}

John

Answers (1)

Answers (1)

Former Member
0 Kudos

John,

Good insight. Thank you.

I am updated a non-SAP database. My update will be as follows. Determine whether the user role has been added to the listbox then perform a SQL <Insert via a SQL Query> or determine whether a user role has been deleted <Delete via a SQL Query>.

Maybe my question is more geared towards javascript. Load the initial roles in an array. Then load the final roles in an array. Do some sort of comparison between arrays and perform the SQL function (Insert or Delete). I just wasn't sure whether I should do all this in javascript or some sort of transaction. Seems doing it in javascript may be cleaner. I'm relatively new to xMII and wasn't sure of all the tools I have available to me and what the best approach would be.

Thank you.

Former Member
0 Kudos

Kelly,

I understand that you have created arrays for 'delete' and 'insert' from the javascript itself by doing the comparison.

You are still leaning towards transaction. You don' have to call a Xacute/Transaction to do this. It is like if the only tool you have is a hammer, every problem looks like a nail.

If you want to update those changes directly to the database from the javascript using an iCommand, you will have to call the INSERT and DELETE statements multiple times (that means you have to kick-off the executeCommand() several times). Calling multiple SQL statements directly from the front end has a disadvantage because if one of these statement fails, it is cumbersome do a rollback of everything . That is why I was suggesting to handle this through the stored procedure and by making a single execution of iCommand from the JavaScript.

Let me know if you have any questions.

John