Doubt in list Item (very Urgent) [message #85719] |
Sat, 24 July 2004 07:19 |
pratyusha
Messages: 8 Registered: July 2004
|
Junior Member |
|
|
Hi,
I want to transfer values from
1 list item to another to transfer all the list items
i am using a loop and adding each value into 2nd list item and deleting the same from 1st list item.
But if i want to transfer 1 list item to another how can i achieve it and also if i want to tansfer a range of values like 1-5 how can i do it..
Regards,
Pratyusha
|
|
|
Re: Doubt in list Item (very Urgent) [message #85732 is a reply to message #85719] |
Sun, 25 July 2004 23:24 |
Himanshu
Messages: 457 Registered: December 2001
|
Senior Member |
|
|
Hi,
This can be achieved with the use of When-list-activated trigger.
First of all you have to populate your Initial lst item(let's name this List feild as X).
Assume the name of Second List item is Y.
Then write following code in your When-list-activated trigger:
Declare
L_CNT Number:= nvl(TO_NUMBER(GET_LIST_ELEMENT_COUNT('BLK.X')),0);
Begin
IF :SYSTEM.CURSOR_ITEM = BLK.X' THEN
IF :BLK.X Is Not Null Then
If L_Cnt != 1 THEN
L_Cnt := L_Cnt+1;
End If;
CHK_MULTIREC1(:BLK.X,L_Cnt);
ELSE
Message('W: Bank Account must be selected for which EFT Test Sweep is to be run.',NO_ACKNOWLEDGE);
Raise Form_trigger_failure;
END IF;
END IF;
/***
** Exception Handling
***/
Exception
When Others Then
message('Xyz');
Raise Form_trigger_failure;
End;
Create the Procedure CHK_MULTIREC1
PROCEDURE CHK_MULTIREC1(P_code VARCHAR2,P_count NUMBER) IS
/***
** To polulate the Record Group with the values of the Selected values so that
** the repeatition of the value is not allowed in the list item
***/
L_rg_id1 RECORDGROUP:=FIND_GROUP('MULTIREC1');
L_col_id1 GROUPCOLUMN:=FIND_COLUMN('MULTIREC1.CODE1');
L_flag NUMBER := 0;
BEGIN
FOR I IN 1..GET_GROUP_ROW_COUNT(L_rg_id1)
LOOP
IF GET_GROUP_CHAR_CELL(L_col_id1,I) = P_code THEN
L_flag := 1;
Message('W: Value Already Exists In List.',NO_ACKNOWLEDGE);
END IF;
END LOOP;
IF L_flag = 0 THEN
ADD_GROUP_ROW(L_rg_id1,P_Count);
SET_GROUP_CHAR_CELL(L_col_id1,P_Count,P_code);
Add_List_Element('BLK.Y', P_Count, P_code,P_code);
END IF;
/***
** Exception Handling
***/
Exception
When Others Then
TEMPLATE.Show_Error('T');
End;
Rememeber that this will work when you Double click on the X list item.
Now the code to remove an item from Item Y is as follows:
Write a trigger When-list-activated on your List item Y as follows:
/***
** Remove the Current Value from the selected Values list
** if the cursor is in that list Item.
***/
DECLARE
L_rg_id1 RECORDGROUP:=FIND_GROUP('MULTIREC1');
L_col_id1 GROUPCOLUMN:=FIND_COLUMN('MULTIREC1.CODE1');
BEGIN
IF GET_GROUP_ROW_COUNT(L_rg_id1) > 0 Then
/* To remove the current Value from the Record Group */
BEGIN
FOR I IN 1.. GET_GROUP_ROW_COUNT(L_rg_id1)
LOOP
IF GET_GROUP_CHAR_CELL(L_col_id1,I) = :BLK.Y THEN
DELETE_GROUP_ROW(L_rg_id1,I);
/* Calling Remove_Item */
Remove_Item;
EXIT;
END IF;
END LOOP;
END;
END IF;
/***
** Exception Handling
***/
EXCEPTION
When Form_Trigger_Failure Then
Raise Form_Trigger_Failure;
END;
Now Create a procedure Remove_item
PROCEDURE Remove_Item IS
L_rg_id1 RECORDGROUP:=FIND_GROUP('MULTIREC1');
L_col_id1 GROUPCOLUMN:=FIND_COLUMN('MULTIREC1.CODE1');
L_List_id ITEM; /* Used to store the list item */
L_Element_Value Varchar2(50); /* Store the value of selected item */
L_Element_Value1 Varchar2(50); /* used to store the value of item in loop */
L_Index Number := 1; /* Used to store the item index */
L_List_Count Number;
BEGIN
L_List_Id := Find_Item('BLK.Y');
L_Element_Value := :BLK.Y;
L_List_Count := Get_List_Element_Count(L_List_Id);
If L_List_Count > 0 Then
Loop
L_Element_Value1 := GET_LIST_ELEMENT_VALUE('BLK.Y',L_Index);
If L_Element_Value = L_Element_Value1 Then
Delete_list_Element(L_List_Id,L_Index);
Else
L_Index := L_Index + 1;
End If;
Exit When L_Element_Value = L_Element_Value1;
End Loop;
End If;
/***
** Exception handling
***/
Exception
When Others Then
Raise Form_trigger_failure;
END;
HTH
Regards
Himanshu
|
|
|