Home » Developer & Programmer » Forms » How to stop the process (merged)
How to stop the process (merged) [message #608553] Fri, 21 February 2014 00:42 Go to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi ,

I have 3 alerts and if 3 conditions are satisfied then run the next process , otherwise stop the Process

Thank You


[MERGED #1 by CM]
[MERGED #2, #3, #4, #5 and #6 by LF]

[Updated on: Wed, 05 March 2014 05:28] by Moderator

Report message to a moderator

Re: How to stop the process [message #608572 is a reply to message #608553] Fri, 21 February 2014 02:42 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
That's so vague as to be meaningless.
What process?
What does the code look like?
What's stopping you from stopping the process?
Re: How to stop the process [message #608573 is a reply to message #608572] Fri, 21 February 2014 02:47 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
I want to show the messages 'Are you sure,you want to move data into Brooklyn Warehouse?'; after all the 3 conditions satisfied.

I want to stop the next process where any one of the 3 conditions failed, other wise go to the next process and show the 'Are you sure,you want to move data into Brooklyn Warehouse?

Getting stopped the process , it was not showing me the messages when the 3 conditions satisfied.

DECLARE 
    alert_button NUMBER; 
    v_alert      NUMBER; 
    v_message    VARCHAR2(1000); 
    v_count1     NUMBER; -->Added on 14-Feb-2014 
     v_count2     NUMBER; -->Added on 14-Feb-2014 
    v_count      NUMBER := 0; 
BEGIN 
	 BEGIN
    --IF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
    Go_block('RHCLANDEDCOSTDET'); 
    first_record; 
    LOOP 
        --IF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
        SELECT Count(1) 
        INTO   v_count1 
        FROM   mtl_system_items_kfv a 
        WHERE  inventory_item_id IN(SELECT inventory_item_id 
                                    FROM   regal.regal_inv_landed_cost_tab b 
                                    WHERE  item_number = :RHCLANDEDCOSTDET.item_number 
                                           AND file_number = :RHCLANDEDCOSTHEADER.file_number) 
               --AND selected_flag = 'Y')  
               AND organization_id = '82'; 

        IF v_count1 = 0  and :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
          fnd_message.Set_string('This' ||:RHCLANDEDCOSTDET.item_number ||' Number is not assigned into the BRW'); --testing  
          fnd_message.show; 
        	 RAISE form_trigger_failure;
        ELSIF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN
 
           SELECT Count(1) 
           INTO   v_count2
           FROM   mtl_system_items_kfv a 
           WHERE  inventory_item_id IN(SELECT inventory_item_id 
                                    FROM   regal.regal_inv_landed_cost_tab b 
                                    WHERE  item_number = :RHCLANDEDCOSTDET.item_number 
                                           AND file_number = :RHCLANDEDCOSTHEADER.file_number) 
                                         --AND a.inventory_item_id=b.inventory_item_id   
                                         --AND selected_flag = 'Y')   
               AND organization_id IN( '81', '82' ) 
               AND Nvl(inventory_item_status_code, 'Active') = 'Active'; 

          IF v_count2 = 0  and :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
             fnd_message.Set_string('The' ||' ' ||:RHCLANDEDCOSTDET.item_number ||' ' || 'is in the Inactive Mode Please Active ') ; --testing  
             fnd_message.show;
        	 RAISE form_trigger_failure;
          ELSIF :RHCLANDEDCOSTDET.ONHANDQUANTITY =0 and :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN
           --IF :RHCLANDEDCOSTDET.ONHANDQUANTITY =0 and :RHCLANDEDCOSTDET.selected_flag = 'Y'  THEN 
             fnd_message.Set_string('This '||:RHCLANDEDCOSTDET.ITEM_NUMBER||' Does not have ONHANDQUANTITY in RHC'); 
             fnd_message.show;
        	 RAISE form_trigger_failure;
           END IF; 
           next_record;
           end if;
        Exit WHEN :System.last_record = 'TRUE';
        --END IF;
        --END IF;
       END LOOP; 
       first_record; 
       --RAISE form_trigger_failure;
        --END IF;
        
        --end if;

    END;
    
    BEGIN  
    v_message := 'Are you sure,you want to move data into Brooklyn Warehouse?'; 

    Set_alert_property('BRW', alert_message_text, v_message); 

    alert_button := Show_alert('BRW'); 

    IF alert_button = alert_button1 THEN 
     commit_form; 

       BEGIN 
          SELECT Count(1) 
          INTO   v_count 
          FROM   regal.regal_inv_landed_cost_tab 
          WHERE  file_number = :RHCLANDEDCOSTHEADER.file_number 
          AND selected_flag = 'Y' 
          AND brw_processed = 'Y' 
          AND orig_quantity_received = quantity_received; 
     END; 

       IF v_count != 0 THEN 
          fnd_message.Set_string('You are selecting Processed Records. Please Check '); --testing  
          fnd_message.show; 
       ELSE 
          submit_inv_request; 
       END IF; 
  END IF;
  END;
END;



I am very confusing please help
Re: How to stop the process [message #608576 is a reply to message #608573] Fri, 21 February 2014 02:54 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Which message in all that are you expecting to see but not?
Re: How to stop the process [message #608578 is a reply to message #608576] Fri, 21 February 2014 02:56 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
I want to show if the 3 conditions are satisfied that is Are you sure,you want to move data into Brooklyn Warehouse?

Is this code is correct?
Re: How to stop the process [message #608579 is a reply to message #608578] Fri, 21 February 2014 03:06 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
mist598 wrote on Fri, 21 February 2014 08:56
I want to show if the 3 conditions are satisfied that is Are you sure,you want to move data into Brooklyn Warehouse?

If the 3 conditions are satisfied for all records or just some of them?

mist598 wrote on Fri, 21 February 2014 08:56

Is this code is correct?

Haven't you tested it already? Cause if you have you should know the answer to that.
Re: How to stop the process [message #608584 is a reply to message #608579] Fri, 21 February 2014 03:19 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Means, if the any one the 3 alerts shows then stop the process, if not then show this Alert " Are you sure,you want to move data into Brooklyn Warehouse?"

1) This item_number is not assigned into the BRW'
2)'is in the Inactive Mode Please Active '
3)' Does not have ONHANDQUANTITY in RHC'

In the above 3 alerts ,if i get any one of the 3, then don't want to show the " Are you sure,you want to move data into Brooklyn Warehouse?", means stop the process after i get the any one of the 3 Alerts ,Otherwise go to the next process.that is " Are you sure,you want to move data into Brooklyn Warehouse?"
Re: How to stop the process [message #608593 is a reply to message #608584] Fri, 21 February 2014 04:28 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Please help me any one
Re: How to stop the process [message #608594 is a reply to message #608593] Fri, 21 February 2014 04:37 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
if first_condition then 
   raise form_trigger_failure
elsif second_condition then
   raise form_trigger_failure
elsif third_condition then
   raise form_trigger_failure
else
   move data
end if

[Updated on: Fri, 21 February 2014 04:37]

Report message to a moderator

Re: How to stop the process [message #608597 is a reply to message #608584] Fri, 21 February 2014 04:45 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
mist598 wrote on Fri, 21 February 2014 09:19
Means, if the any one the 3 alerts shows then stop the process, if not then show this Alert " Are you sure,you want to move data into Brooklyn Warehouse?"

1) This item_number is not assigned into the BRW'
2)'is in the Inactive Mode Please Active '
3)' Does not have ONHANDQUANTITY in RHC'

In the above 3 alerts ,if i get any one of the 3, then don't want to show the " Are you sure,you want to move data into Brooklyn Warehouse?", means stop the process after i get the any one of the 3 Alerts ,Otherwise go to the next process.that is " Are you sure,you want to move data into Brooklyn Warehouse?"


That doesn't actually answer this at any point
cookiemonster wrote on Fri, 21 February 2014 09:06
mist598 wrote on Fri, 21 February 2014 08:56
I want to show if the 3 conditions are satisfied that is Are you sure,you want to move data into Brooklyn Warehouse?

If the 3 conditions are satisfied for all records or just some of them?


I assume the answer is that the process should run only if all the selected rows satisfy all the conditions. But I shouldn't have to assume.

If I'm right then I've got to ask - have you actually tested it?
Because at a glance it appears to do what you want.
LF has given the basic code structure and it appears to be what you have.
Re: How to stop the process [message #608604 is a reply to message #608597] Fri, 21 February 2014 05:43 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi,

1) This item_number is not assigned into the BRW'
2)'is in the Inactive Mode Please Active '
3)' Does not have ONHANDQUANTITY in RHC'

I have 3 Alerts ,i want an Alerts when the above 3 conditions are check one by one , means suppose if i select the 3 records from the multi-records , then validate the 3 records and shows Alerts if the conditions are not satified.

My Requirement is if any one of the Alert is display then stop the process and if the Any one of the Alerts not show then go to the next process, means i want to show "Are you sure,you want to move data into Brooklyn Warehouse?"(This is the Alert)

I want to check the above 3 Alerts , if not display any Alerts then got to the "Are you sure,you want to move data into Brooklyn Warehouse?"

I tried with the code where Littlefoot were updated...But not shows any Alerts.
DECLARE 
    alert_button NUMBER; 
    v_alert      NUMBER; 
    v_message    VARCHAR2(1000); 
    v_count1     NUMBER; -->Added on 14-Feb-2014 
     v_count2     NUMBER; -->Added on 14-Feb-2014 
    v_count      NUMBER := 0; 
    V_ONHANDQUANTITY NUMBER;
BEGIN 
       if :RHCLANDEDCOSTDET.selected_flag = 'Y' then -->(1)
       	Go_block('RHCLANDEDCOSTDET'); 
        first_record; 
        LOOP 
        SELECT Count(1) 
        INTO   v_count1 
        FROM   mtl_system_items_kfv a 
        WHERE  inventory_item_id IN(SELECT inventory_item_id 
                                    FROM   regal.regal_inv_landed_cost_tab b 
                                    WHERE  item_number = :RHCLANDEDCOSTDET.item_number 
                                           AND file_number = :RHCLANDEDCOSTHEADER.file_number) 
               AND organization_id = '82'; 

        IF v_count1 = 0   THEN 
          fnd_message.Set_string('This' ||:RHCLANDEDCOSTDET.item_number ||' Number is not assigned into the BRW'); --testing  
          fnd_message.show;
        END IF;
	      raise form_trigger_failure;
	      next_record;
        Exit WHEN :System.last_record = 'TRUE';
        END LOOP; 
	     
        elsif :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
        	Go_block('RHCLANDEDCOSTDET'); 
          first_record; 
          LOOP 
	         SELECT Count(1) 
           INTO   v_count2
           FROM   mtl_system_items_kfv a 
           WHERE  inventory_item_id IN(SELECT inventory_item_id 
                                    FROM   regal.regal_inv_landed_cost_tab b 
                                    WHERE  item_number = :RHCLANDEDCOSTDET.item_number 
                                           AND file_number = :RHCLANDEDCOSTHEADER.file_number)   
               AND organization_id IN( '81', '82' ) 
               AND Nvl(inventory_item_status_code, 'Active') = 'Active'; 

          IF v_count2 = 0 THEN 
             fnd_message.Set_string('The' ||' ' ||:RHCLANDEDCOSTDET.item_number ||' ' || 'is in the Inactive Mode Please Active ') ; --testing  
             fnd_message.show;
          END IF; 
          RAISE form_trigger_failure;
          next_record;
         Exit WHEN :System.last_record = 'TRUE';
         END LOOP; 
          
          ELSIF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
          	Go_block('RHCLANDEDCOSTDET'); 
            first_record; 
            LOOP 
          	select sum(transaction_quantity) ONHANDQUANTITY
          	INTO V_ONHANDQUANTITY
	         from mtl_onhand_quantities
	         where inventory_item_id = :RHCLANDEDCOSTDET.inventory_item_id
          	and organization_id = 81
	         and subinventory_code = 'Vessel';
          	IF V_ONHANDQUANTITY =0 THEN
               fnd_message.Set_string('This '||:RHCLANDEDCOSTDET.ITEM_NUMBER||' Does not have ONHANDQUANTITY in RHC'); 
               fnd_message.show;
            END IF;
	          RAISE form_trigger_failure;
	          next_record;
         Exit WHEN :System.last_record = 'TRUE';
         END LOOP;
	ELSIF  v_count1>0 AND v_count2>0 AND V_ONHANDQUANTITY>0 THEN 
	   v_message := 'Are you sure,you want to move data into Brooklyn Warehouse?'; 

           Set_alert_property('BRW', alert_message_text, v_message); 

            alert_button := Show_alert('BRW'); 

           IF alert_button = alert_button1 THEN 
           commit_form; 

             BEGIN 
                SELECT Count(1) 
                INTO   v_count 
                FROM   regal.regal_inv_landed_cost_tab 
                WHERE  file_number = :RHCLANDEDCOSTHEADER.file_number 
                AND selected_flag = 'Y' 
                AND brw_processed = 'Y' 
                AND orig_quantity_received = quantity_received; 
             END; 

                IF v_count != 0 THEN 
                   fnd_message.Set_string('You are selecting Processed Records. Please Check '); --testing  
                   fnd_message.show; 
                ELSE 
                   submit_inv_request; 
                END IF; 
          END IF;
         END if;-->(1)
end;


Thank you
Re: How to stop the process [message #608608 is a reply to message #608576] Fri, 21 February 2014 06:11 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
cookiemonster wrote on Fri, 21 February 2014 08:54
Which message in all that are you expecting to see but not?

Re: How to stop the process [message #608609 is a reply to message #608604] Fri, 21 February 2014 06:13 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
My Requirement is

1) if the item_number is not assigned to BRW then show the Alert
2) if the item_number is Inactive , then show the Alerts
3) if the item_number is not having ONHANDQUANtity then, show the Alerts

In the above any one of the condition is TRUE Then stop the next processed Program.

In the above means,
1) if the item_number is assigned to BRW
2) if the item_number is Active
3) if the item_number is having ONHANDQUANtity

Then go to the next program.
Re: How to stop the process [message #608610 is a reply to message #608608] Fri, 21 February 2014 06:15 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
Which message in all that are you expecting to see but not?

This message'Are you sure,you want to move data into Brooklyn Warehouse?'
Re: How to stop the process [message #608611 is a reply to message #608610] Fri, 21 February 2014 06:34 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This code doesn't do anything if :RHCLANDEDCOSTDET.selected_flag <> 'Y'. If it is 'Y', it very soon hits RAISE FORM_TRIGGER_FAILURE and stops execution.

You really need to switch your brain on, or consider changing your profession as programming seems to be very difficult for you.
Re: How to stop the process [message #608612 is a reply to message #608610] Fri, 21 February 2014 06:41 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) learn to indent your code properly, it's hard to see what if's match to what.
2) Why are you checking :RHCLANDEDCOSTDET.selected_flag before going to the first record in the block?
3) You appear to have this structure:
if :RHCLANDEDCOSTDET.selected_flag = 'Y' then 
<do a check>
elsif :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
<do a another check>
ELSIF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
<do yet a another check>
ELSIF  v_count1>0 AND v_count2>0 AND V_ONHANDQUANTITY>0 THEN 
<ask if the user wants to move data>
END IF;


I have no idea how you dreamed that up.
When the code reaches an if/elsif combo it will only ever execute the first if/elsif that evaluates to true.
So it will never, ever execute the 1st and 2nd elsif. The above is equivalent to:
if :RHCLANDEDCOSTDET.selected_flag = 'Y' then 
<do a check>
ELSIF  v_count1>0 AND v_count2>0 AND V_ONHANDQUANTITY>0 THEN 
<ask if the user wants to move data>
END IF;

And those variables are only set inside the other IF's so that elsif is never true, leaving you with:
if :RHCLANDEDCOSTDET.selected_flag = 'Y' then 
<do a check>
END IF;


The conditions you're checking there are not what LF meant at all.
Again, your original code appears to do what you want, are you sure it doesn't work?
Re: How to stop the process [message #608614 is a reply to message #608612] Fri, 21 February 2014 06:50 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
if :RHCLANDEDCOSTDET.selected_flag = 'Y' then 
<do a check>
elsif :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
<do a another check>
ELSIF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
<do yet a another check>
ELSIF  v_count1>0 AND v_count2>0 AND V_ONHANDQUANTITY>0 THEN 
<ask if the user wants to move data>
END IF;


1st i took one file_number and click on the QUERY Button and it displays the Data at the Databaseblock(Multi record Block)
and i selected the records suppose 3 records(selected_flag=N by default) and click and another Button.

Quote:
2) Why are you checking :RHCLANDEDCOSTDET.selected_flag before going to the first record in the block?


What code to add here , can you please help, i am getting confused.
Re: How to stop the process [message #608616 is a reply to message #608614] Fri, 21 February 2014 07:05 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
You've got a block of records.
You need to loop through the block of records.
For each record that's selected you need to do 3 checks.
If any of the 3 checks fails you need to stop the process by raising form_trigger_failure.
Otherwise, after looping through all the records you need to display the alert asking them if they want to move the data.

As far as I can tell (which is difficult since a) it's badly formatted and b) I can't run it) your original code does that.
It's certainly far closer to what you need than your latest attempt.

I presume the orginal code doesn't quite work. That doesn't mean that the basic structure is wrong, just that there's a bug somewhere.
So do this:
1) Format it properly, check that the if/elsif/end if line up correctly and that the correct code is inside the correct if.
2) Go through in your head what it does. It's not complicated, you only have three checks. Ask yourself what will happen at each stage.
If you still can't spot where you've gone wrong then you need to debug it.
So put messages in the code to display the values being checked at each point. Ensure it does all three checks for each selected record.
You will then be able to easily spot where it's going wrong and fix it.
Re: How to stop the process [message #608672 is a reply to message #608616] Fri, 21 February 2014 23:29 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
I selected one item_Number and clicked on the button
1)is not assigned to BRW
2)is in Inactive
3)not having ONHANDQUANtity

If it is in the above conditions ,Then show the all the 3 Alerts and stop the next process.That means , i want to check the all the 3 conditions one one by for this item_number

If it is,
1)assigned to BRW
2)Active
3)having ONHANDQUANtity

Then got to the next process.


DECLARE 
    alert_button NUMBER; 
    v_alert      NUMBER; 
    v_message    VARCHAR2(1000); 
    v_count1     NUMBER; -->Added on 14-Feb-2014 
    v_count2     NUMBER; -->Added on 14-Feb-2014 
    v_count      NUMBER := 0;
    v_flag       VARCHAR2(1) := 'Y';
    V_ONHANDQUANTITY NUMBER;
BEGIN 
  BEGIN
    IF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
    Go_block('RHCLANDEDCOSTDET'); 
    --first_record; 
    --LOOP 
      BEGIN   	        
        SELECT Count(1) 
        INTO   v_count1 
        FROM   mtl_system_items_kfv a 
        WHERE  inventory_item_id IN(SELECT inventory_item_id 
                                    FROM   regal.regal_inv_landed_cost_tab b 
                                    WHERE  item_number = :RHCLANDEDCOSTDET.item_number 
                                           AND file_number = :RHCLANDEDCOSTHEADER.file_number)  
               AND organization_id = '82'; 
      END;
        IF v_count1 = 0 THEN
          v_flag := 'N';        
          fnd_message.Set_string('This' ||:RHCLANDEDCOSTDET.item_number ||' Number is not assigned into the BRW'); --testing  
          fnd_message.show;
          --GO_ITEM(:RHCLANDEDCOSTDET.item_number);
          RAISE FORM_TRIGGER_FAILURE;
        END IF;  
          BEGIN
           SELECT Count(1) 
           INTO   v_count2
           FROM   mtl_system_items_kfv a 
           WHERE  inventory_item_id IN(SELECT inventory_item_id 
                                    FROM   regal.regal_inv_landed_cost_tab b 
                                    WHERE  item_number = :RHCLANDEDCOSTDET.item_number 
                                           AND file_number = :RHCLANDEDCOSTHEADER.file_number)   
               AND organization_id IN( '81', '82' ) 
               AND Nvl(inventory_item_status_code, 'Active') = 'Active'; 
	        END;

          IF v_count2 = 0 THEN
             v_flag := 'N';          
             fnd_message.Set_string('The' ||' ' ||:RHCLANDEDCOSTDET.item_number ||' ' || 'is in the Inactive Mode Please Active ') ; --testing  
             fnd_message.show;
             GO_ITEM(:RHCLANDEDCOSTDET.item_number);
             RAISE FORM_TRIGGER_FAILURE;
          END IF; 
          
          BEGIN
	           SELECT SUM(transaction_quantity) ONHANDQUANTITY 
              INTO   V_ONHANDQUANTITY 
              FROM   mtl_onhand_quantities 
              WHERE  inventory_item_id = :RHCLANDEDCOSTDET.inventory_item_id 
              AND organization_id = 81 
              AND subinventory_code = 'Vessel'; 
	       END;
           IF V_ONHANDQUANTITY =0  THEN
             v_flag := 'N';           
             fnd_message.Set_string('This '||:RHCLANDEDCOSTDET.ITEM_NUMBER||' Does not have ONHANDQUANTITY in RHC'); 
             fnd_message.show;
             --GO_ITEM(:RHCLANDEDCOSTDET.item_number);
             RAISE FORM_TRIGGER_FAILURE;
           END IF; 
           --next_record;
        --Exit WHEN :System.last_record = 'TRUE';
       --END LOOP; 
   END IF;
  END;
  
  IF v_flag = 'Y' THEN
    v_message := 'Are you sure,you want to move data into Brooklyn Warehouse?'; 

    Set_alert_property('BRW', alert_message_text, v_message); 

    alert_button := Show_alert('BRW'); 

    IF alert_button = alert_button1 THEN 
     commit_form; 

       BEGIN 
          SELECT Count(1) 
          INTO   v_count 
          FROM   regal.regal_inv_landed_cost_tab 
          WHERE  file_number = :RHCLANDEDCOSTHEADER.file_number 
          AND selected_flag = 'Y' 
          AND brw_processed = 'Y' 
          AND orig_quantity_received = quantity_received; 
     END; 

       IF v_count != 0 THEN 
          fnd_message.Set_string('You are selecting Processed Records. Please Check '); --testing  
          fnd_message.show; 
       ELSE 
          submit_inv_request; 
       END IF; 
  END IF;
 END IF;
 FIRST_RECORD;
END;



Please help me.
Error [message #608683 is a reply to message #608553] Sat, 22 February 2014 01:31 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi all,

I am getting an error at 1st ELSE Condition as Expecting the one of the following ( begin case declare end exit for goto if loop mod null pragma raise return select update while with <an identifier>
 BEGIN
      IF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN --(1)
        Go_block('RHCLANDEDCOSTDET'); 
        first_record; 
        LOOP 
        SELECT Count(1) 
        INTO   v_count1 
        FROM   mtl_system_items_kfv a 
        WHERE  inventory_item_id IN(SELECT inventory_item_id 
                                    FROM   regal_inv_landed_cost_tab b 
                                    WHERE  item_number = :RHCLANDEDCOSTDET.item_number 
                                           AND file_number = :RHCLANDEDCOSTHEADER.file_number)  
               AND organization_id = '82'; 

        IF v_count1 = 0 and :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
             v_flag := 'N'; 
          fnd_message.Set_string('This' ||:RHCLANDEDCOSTDET.item_number ||' Number is not assigned into the BRW'); --testing  
          fnd_message.show; 
        END IF; 
      ELSE
           SELECT Count(1) 
           INTO   v_count2 
           FROM   mtl_system_items_kfv a 
           WHERE  inventory_item_id IN(SELECT inventory_item_id 
                                    FROM   regal_inv_landed_cost_tab b 
                                    WHERE  item_number = :RHCLANDEDCOSTDET.item_number 
                                           AND file_number = :RHCLANDEDCOSTHEADER.file_number)  
               AND organization_id IN( '81', '82' ) 
               AND Nvl(inventory_item_status_code, 'Active') = 'Active'; 

          IF v_count2 = 0 and :RHCLANDEDCOSTDET.selected_flag = 'Y'  THEN 
               v_flag := 'N'; 
             fnd_message.Set_string('The' ||' ' ||:RHCLANDEDCOSTDET.item_number ||' ' || 'is in the Inactive Mode Please Active ') ; --testing  
             fnd_message.show;
          END IF;
        ELSE 
             begin
               SELECT SUM(transaction_quantity) ONHANDQUANTITY 
              INTO   v_onhandquantity 
              FROM   mtl_onhand_quantities 
              WHERE  inventory_item_id = :RHCLANDEDCOSTDET.inventory_item_id 
              AND organization_id = 81 
              AND subinventory_code = 'Vessel';
             end;
             IF v_onhandquantity =0  THEN 
                v_flag := 'N'; 
             fnd_message.Set_string('This '||:RHCLANDEDCOSTDET.ITEM_NUMBER||' Does not have ONHANDQUANTITY in RHC'); 
             fnd_message.show;
             END IF; 
          Exit WHEN :System.last_record = 'TRUE';
          next_record; 
          END LOOP; 
          first_record; 

         END IF;
END;
Re: Error [message #608686 is a reply to message #608683] Sat, 22 February 2014 02:04 Go to previous messageGo to next message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
Hi,

the problem is in the nesting of LOOP and IF statements. Your code flow looks like this:
IF (condition) THEN
  ...
  LOOP
    ...
ELSE
    ...
    EXIT WHEN (condition);
    ...
  END LOOP
  ...
END IF;

Does not make much sense, does it? Just imagine that you should interpret this code.
What would you do when reaching ELSE inside the LOOP? Skip to END IF? But, you will miss END LOOP then. Follow to the ELSE clause? But, the condition is not filled to enter that branch.
Or, another possible code flow, when running the ELSE branch from the beginning and reaching END LOOP there (there was no start of LOOP)?
Re: How to stop the process [message #608693 is a reply to message #608616] Sat, 22 February 2014 04:30 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
I've merged your two threads, do not start a new thread for the same problem, as just confuses matters.

As I pointed out earlier checking selected_flag before going to the first record in the block is just pointless.

Furthermore I've already described the code structure:

cookiemonster wrote on Fri, 21 February 2014 13:05
You've got a block of records.
You need to loop through the block of records.
For each record that's selected you need to do 3 checks.
If any of the 3 checks fails you need to stop the process by raising form_trigger_failure.
Otherwise, after looping through all the records you need to display the alert asking them if they want to move the data.
not in query [message #608809 is a reply to message #608553] Tue, 25 February 2014 02:09 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi all,

I have custom table having org_id=81 records only. I have items table that is mtl_systems_itmes_kfv having 81,82 org_id data.

I want a query , what items(From Custom Table) are not in the 82 org_id in the mtl_systems_itmes_kfv

Please provide sample query.

Thank
Re: not in query [message #608810 is a reply to message #608809] Tue, 25 February 2014 02:18 Go to previous messageGo to next message
Michel Cadot
Messages: 68644
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Not clear.
Post what is usually requested.

Re: not in query [message #608815 is a reply to message #608810] Tue, 25 February 2014 03:35 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
SQL> select item_number ,organization_id ,inventory_item_id from regal.regal_inv_landed_cost_tab
  2  where item_number='AID200.JCP.5484.BL'
  3  and file_number='SEP849'
  4  /

ITEM_NUMBER                                        ORGANIZATION_ID INVENTORY_ITEM_ID
-------------------------------------------------- --------------- -----------------
AID200.JCP.5484.BL                                              81             27425

SQL> select concatenated_segments,organization_id
  2  FROM mtl_system_items_kfv
  3  where concatenated_segments='AID101.JCP.5495.BE'
  4  /

CONCATENATED_SEGMENTS           ORGANIZATION_ID                                                                        
---------------------           ----------------
AID101.JCP.5495.BE                   81                                                                                     
AID101.JCP.5495.BE                   82                                                                                    



If the AID101.JCP.5495.BE this item not available then, means what items are not in the 82 in the mtl_system_items_kfv table.
Re: not in query [message #608817 is a reply to message #608815] Tue, 25 February 2014 03:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68644
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Still not clear.
From your output "AID101.JCP.5495.BE" IS in the " 82 in the mtl_system_items_kfv table", so what should be the result from what you showed us?
What is the relation between 81 and 82? (Why these numbers?)

Re: not in query [message #608818 is a reply to message #608817] Tue, 25 February 2014 03:48 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
AID101.JCP.5495.BE" IS in the " 81 in the regal_inv_landed_cost_tab",


AID101.JCP.5495.BE" IS in the " 81 &  82 in the mtl_system_items_kfv table",



AID101.JCP.5495.BE" IS Exists in the " 81 in the regal_inv_landed_cost_tab & AID101.JCP.5495.BE" IS Not Exists in the " 82 in the mtl_system_items_kfv table


Means, exists in the 81 only in the mtl_system_items_kfv table


81 & 82 are the Org_id's

I want check thei AID101.JCP.5495.BE(Item from regal_inv_landed_cost_tab) not exists in the 82 in the mtl_system_items_kfv table

[Updated on: Tue, 25 February 2014 03:52]

Report message to a moderator

Re: not in query [message #608819 is a reply to message #608818] Tue, 25 February 2014 04:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68644
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
what should be the result from what you showed us?


Re: not in query [message #608829 is a reply to message #608819] Tue, 25 February 2014 05:23 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
AID101.JCP.5495.BE" IS in the " with org_id's 81 & 82 in the mtl_system_items_kfv table"

AID101.JCP.5495.BE" IS in the " with org_id 81 in the regal-inv_landed_cost table" and i have only org_id data in this table.

Ok. items are exists in the regal-inv_landed_cost table with org_id 81, but not in the org_id=82 in the mtl_system_items_kfv table

For example:

I have regal_inv_landed_cost table

Item_number org_id
---------- ------
12 81

In the mtl_system_items_kfv table.

Item_number org_id
---------- ------
12 81
12 82-->No records, means Same item not exists in this org_id(82).

I want this query where not exists in the org_id=82
Re: How to stop the process (merged) [message #608832 is a reply to message #608553] Tue, 25 February 2014 05:36 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Some records are moved from regal_inv_landed_cost table (81 ) to 82 organization means stores that data into the mtl_system_items_kfv(in the 82), so here so data are not moved from the 81 to 82 in the mtl_system_items_kfv. How to check please help
Re: How to stop the process (merged) [message #608833 is a reply to message #608832] Tue, 25 February 2014 06:04 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
How to find rows in one table that have no corresponding row in another table
Re: How to stop the process (merged) [message #608835 is a reply to message #608833] Tue, 25 February 2014 06:10 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
SELECT * FROM <table>
WHERE <linking column> NOT IN (SELECT <linking column>
                               FROM <other table>
                              )
Re: How to stop the process (merged) [message #608842 is a reply to message #608835] Tue, 25 February 2014 07:02 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Or, possibly,
select blabla from table1
minus
select blabla from table2
Re: not in query [message #608843 is a reply to message #608829] Tue, 25 February 2014 07:06 Go to previous messageGo to next message
Michel Cadot
Messages: 68644
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
I have regal_inv_landed_cost table...

And what is the expected output?
Is this a so difficult question that you can SHOW what should be the output; just that, no more explanation, just the result.



How to validates the records using Loop [message #608853 is a reply to message #608553] Tue, 25 February 2014 08:56 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi all,

I selected file-number and clicked on the QUERY Button and it displayed records(Multiple Records means 10 records)at the Database Block(RHCLANDEDCOSTDET) , in the Database block i have selected_flag,file_number,item_number . I check the Selected_flag and click on the MOVE Button...

In the below code , i don't want to add " AND item_number = :RHCLANDEDCOSTDET.item_number" this line in the code , but how can i validate records and in the table selected_flag='N', how can i validate and process this Alert..

If i pass the file_number it shows me the count, if count=0 then show me the Alert..

But i don't want to add item_number....Please Help
 /****Checking for Item Number is Active or Not*******/
    BEGIN 
    Go_block('RHCLANDEDCOSTDET'); 
    v_itemnumber:=NULL;
    first_record; 
    LOOP 
        IF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN 
          SELECT Count(1) 
          INTO   v_count2 
          FROM   regal_inv_landed_cost_tab a1 
          WHERE  organization_id = 81 
                 AND inventory_item_id IN (SELECT inventory_item_id 
                                           FROM   mtl_system_items_kfv a2 
                                           WHERE a1.item_number = a2.concatenated_segments 
                                           AND a2.organization_id = 82 
                                           AND Nvl(a2.inventory_item_status_code, 'Active' ) = 'Active') 
                 AND file_number = :RHCLANDEDCOSTDET.file_number 
                 AND item_number = :RHCLANDEDCOSTDET.item_number; 

          IF v_count2 = 0 THEN v_incrval := 1; 
            v_itemnumber := v_itemnumber ||:RHCLANDEDCOSTDET.item_number ||','; 
          END IF; 
        END IF; 
        next_record; 
        EXIT WHEN :SYSTEM.last_record = 'TRUE'; 
    END LOOP;
    first_record; 

    IF v_incrval = 1 THEN 
      fnd_message.Set_string('This' ||Rtrim(v_itemnumber) ||' is in the Inactive Mode Please Active '); --testing  
      fnd_message.show; 
    END IF; 
end;
Re: How to validates the records using Loop [message #608855 is a reply to message #608853] Tue, 25 February 2014 09:25 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Can any one please help, how to validate the selected records,
Messages [message #608905 is a reply to message #608553] Wed, 26 February 2014 09:23 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi all,

I have a custom table & i want to check the records of custom table in the another table.Means i have only 81 Org_id data and in the Standard table i am having 81&82 , means both the means custom tale data also.

And i have a selected_flag in the database block this column is a Database Column and in the table it is in the "N"
(By Default)

But below code is shows the current positioned record only (in the message).How can i show the records where i selected , suppose i selected 3 records like 1,2,3...i want to show in the Messages like "1,2,3 are not Active or something..."

I am getting only one that is current positioned record message.But in my table Selected_flag='N'.

Declare
     v_count1  Number;
     v_file_number varchar2(60):=:RHCLANDEDCOSTHEADER.file_number;
     v_item_list varchar2(4000);
     alert_button     NUMBER; 
    v_alert          NUMBER; 
    v_message        VARCHAR2(1000);
    v_count          NUMBER := 0; 
     
   cursor c_get_notassigned(c_file_number in varchar2) is
   SELECT a1.item_number
   FROM   regal.regal_inv_landed_cost_tab a1
   WHERE  organization_id = 81
   AND  exists(SELECT a2.inventory_item_id
               FROM   mtl_system_items_kfv a2
               where    a1.inventory_item_id =a2.inventory_item_id and  a2.organization_id = 82)
   and item_number=:RHCLANDEDCOSTDET.item_number
   AND file_number = c_file_number;
Begin
SELECT Count(1)
INTO v_count1
FROM   regal.regal_inv_landed_cost_tab a1
--WHERE  organization_id = 81
where exists(SELECT a2.inventory_item_id
            FROM   mtl_system_items_kfv a2
            where    a1.inventory_item_id =a2.inventory_item_id and  a2.organization_id = 82)
           AND file_number =v_file_number;
   If  v_count1 > 0 then
    fnd_message.Set_string('The following Items are not assigned to BRW Org'); --testing  
    fnd_message.show; 
    v_item_list := null;
  for c_get_notassigned_rec in c_get_notassigned(v_file_number) loop
   v_item_list := v_item_list||'   ,  '||c_get_notassigned_rec.item_number;
   --v_item_list := v_item_list ||c_get_notassigned_rec.item_number ||',';          
  End Loop; 
      fnd_message.Set_string('This' ||Rtrim(v_item_list) ||' is in not assigned to BRW Org');
      fnd_message.show; 
  END if;
end;


I tried with this code, it is working fine, but i don't want to take -- AND item_number = :RHCLANDEDCOSTDET.item_number; Line & Display the items as in the one line , "1,2,3 are inactive" in the message, if i remove item_number line then it is not worked for me and in the table, selected_flag=N, then how to validate the records if i am not use both the item_number and selected_flag, if i use selected_flag then how can i use?, i don't want to update this column,it updated as Y at the last stage...
EGIN 
    Go_block('RHCLANDEDCOSTDET'); 
    first_record; 
    LOOP 
        IF :RHCLANDEDCOSTDET.selected_flag = 'Y' THEN  
          SELECT Count(1) 
          INTO   v_count 
          FROM   regal.regal_inv_landed_cost_tab a1 
          WHERE  organization_id = 81 
                 AND inventory_item_id IN (SELECT inventory_item_id 
                                           FROM   mtl_system_items_kfv a2 
                                           where  a2.organization_id = 82)
                 AND file_number = :RHCLANDEDCOSTDET.file_number 
                -- AND item_number = :RHCLANDEDCOSTDET.item_number; 

          IF v_count = 0 THEN v_incrval := 1; 
            v_itemnumber := v_itemnumber ||:RHCLANDEDCOSTDET.item_number ||','; 
          END IF; 
        END IF; 
        next_record; 
        EXIT WHEN :SYSTEM.last_record = 'TRUE'; 
    END LOOP; 
    first_record; 

    IF v_incrval = 1 THEN 
      fnd_message.Set_string('This' ||Rtrim(v_itemnumber) ||' Number is not assigned into the BRW'); --testing  
      fnd_message.show; 
    END IF;   
END; 


Thank You

[Updated on: Wed, 26 February 2014 09:29]

Report message to a moderator

Re: Messages [message #608907 is a reply to message #608905] Wed, 26 February 2014 09:29 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
What does this bit of the cursor where clause do:
   and item_number=:RHCLANDEDCOSTDET.item_number
Re: Messages [message #608908 is a reply to message #608907] Wed, 26 February 2014 09:31 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
RHCLANDEDCOSTDET.item_number this the Database Block Coulmn and Block ,it fetches only one record.
Re: Messages [message #608909 is a reply to message #608908] Wed, 26 February 2014 09:38 Go to previous messageGo to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
As per usual:
We don't know anything about your tables or how they relate to each other or how they relate to the records in the form.
We can't know this unless you tell us.
So we're not really in a position to tell you what the code should be unless you supply more information.

However, what was wrong with your original approach of looping through the records in the datablock?
Previous Topic: CALENDAR ON FORM 6 i
Next Topic: Save Employees' Images From Forms
Goto Forum:
  


Current Time: Wed Apr 24 06:13:47 CDT 2024