Thursday, 2 May 2024

API to Assign Salesperson in Another Operating Unit in Oracle APPS R12

 


CREATE OR replace PROCEDURE xx_assign_salesrep_api(p_org_id      NUMBER,
                                                   p_salesrep_id NUMBER)
AS
  x_return_status VARCHAR2(30);
  x_msg_count     NUMBER;
  x_msg_data      VARCHAR2(2000);
  x_salesrep_id   jtf_rs_salesreps.salesrep_id%TYPE;
BEGIN
    fnd_global.Apps_initialize(0, <RESP_ID>, 222);

    mo_global.Set_policy_context('S', p_org_id);

    FOR c1 IN (SELECT *
               FROM   apps.jtf_rs_salesreps
               WHERE  salesrep_id = p_salesrep_id) LOOP
        jtf_rs_salesreps_pub.Create_salesrep_migrate 

        (p_api_version => 1.0,
        p_init_msg_list => fnd_api.g_true, 
        p_resource_id => c1.resource_id,
        p_sales_credit_type_id => c1.sales_credit_type_id,
        p_set_of_books_id => c1.set_of_books_id,
        p_start_date_active => c1.start_date_active,
        p_name => c1.name, 
        p_email_address => c1.email_address,
        p_status => c1.status,
        p_salesrep_number => c1.salesrep_number, 
        p_salesrep_id => c1.salesrep_id,
        p_org_id => p_org_id, 
        x_return_status => x_return_status,
        x_msg_count => x_msg_count, 
        x_msg_data => x_msg_data,
        x_salesrep_id => x_salesrep_id);

        COMMIT;

        dbms_output.Put_line('SALESREP ID->'||x_salesrep_id);
        dbms_output.Put_line(' RETURN STATUS->'||x_return_status);
        dbms_output.Put_line('MSG DATA->' ||x_msg_data);

    END LOOP;
END; 

No comments:

Post a Comment