Tuesday 26 September 2017

Script to Update Preparer/ Requester in Requisitions using API

Get data to be modified from customer and load it into a staging table. Use this table in the below script to update Preparer/ Requester for PO Requisitions.

DECLARE
l_msg_data          VARCHAR2(2000);
     l_msg_count         NUMBER;
     l_return_status     VARCHAR2(1);
     l_update_person     VARCHAR2(200);  
     l_old_personid      NUMBER;  
     l_new_personid      NUMBER;  
     l_document_type     VARCHAR2(200);  
     l_document_no_from  VARCHAR2(200);  
     l_document_no_to    VARCHAR2(200);    
     l_date_from         VARCHAR2(200);        
     l_date_to           VARCHAR2(200);
     l_commit_interval   NUMBER;
     x_date_from         DATE;
     x_date_to           DATE;
   
cursor c1 is
(
select * from  XX_req_prep_chg /*use the table with the loaded data*/

);

BEGIN
 
fnd_global.apps_initialize (/*Pass the values*/);
mo_global.set_policy_context ('S', /*Pass the value*/);
 
for r in c1
loop

   DBMS_OUTPUT.put_line ('Calling API');
 
   l_update_person      := 'ALL';  
    l_old_personid       := /*Assign the value*/;  
    l_new_personid       := /*Assign the value*/;  
    l_document_type      := NULL;  
    l_document_no_from   := r.requisition;
    l_document_no_to     := r.requisition;
    l_commit_interval    := 100;
   
   
     
             
        PO_Mass_Update_Req_GRP.Update_Persons(p_update_person    => l_update_person,
                              p_old_personid     => l_old_personid,
                                      p_new_personid     => l_new_personid,
                          p_document_type    => l_document_type,
                                      p_document_no_from => l_document_no_from,
                              p_document_no_to   => l_document_no_to,
                                      p_date_from        => x_date_from,
                              p_date_to          => x_date_to,
                                      p_commit_interval  => l_commit_interval,
                                      p_msg_data         => l_msg_data,
                                  p_msg_count        => l_msg_count,
                          p_return_status    => l_return_status);


   DBMS_OUTPUT.put_line ('API Return status: ' || l_return_status);
 
   DBMS_OUTPUT.put_line ('API p_msg_count: ' || l_msg_count);
 
   DBMS_OUTPUT.put_line ('Requisition ' || r.requisition);

commit;
 
end loop;


exception
when others then
DBMS_OUTPUT.put_line ('Inside Exception');
 
END;

2 comments: