Wednesday, March 27, 2019

Oracle Create Role responsibility API



DECLARE
    p_role_responsibility_rec   hz_cust_account_role_v2pub.role_responsibility_rec_type;
    x_responsibility_id         NUMBER;
    x_return_status             VARCHAR2(2000);
    x_msg_count                 NUMBER;
    x_msg_data                  VARCHAR2(2000);
    CURSOR c1 IS SELECT
        customer_number,
        cust_account_role_id
                 FROM
        ar_customers ac,
        hz_cust_account_roles hcar
                 WHERE
        ac.status = 'A'
        AND   ac.customer_id = hcar.cust_account_id
        AND   NOT EXISTS (
            SELECT
                responsibility_id
            FROM
                hz_role_responsibility hrr
            WHERE
                hrr.cust_account_role_id = hcar.cust_account_role_id
        )
        ;
BEGIN
   --  fnd_global.apps_initialize(0,000000,222); (user_id, responsibility_id, application_id)
    FOR i IN c1 LOOP
        p_role_responsibility_rec.cust_account_role_id := i.cust_account_role_id;
        p_role_responsibility_rec.responsibility_type := 'BILL_TO';
        p_role_responsibility_rec.created_by_module := 'HZ_CPUI';
        p_role_responsibility_rec.primary_flag := 'N';
        hz_cust_account_role_v2pub.create_role_responsibility('T',p_role_responsibility_rec,x_responsibility_id,x_return_status,x_msg_count
,x_msg_data);
        COMMIT;
        dbms_output.put_line('***************************');
        dbms_output.put_line('Output information ....');
        dbms_output.put_line('***************************');
        dbms_output.put_line('x_responsibility_id: '
        || x_responsibility_id);
        dbms_output.put_line('x_return_status: '
        || x_return_status);
        dbms_output.put_line('x_msg_count: '
        || x_msg_count);
        dbms_output.put_line('x_msg_data:
'
        || x_msg_data);
        dbms_output.put_line(' *************************** ');
        IF
            x_msg_count > 1
        THEN
            FOR i IN 1..x_msg_count LOOP
                dbms_output.put_line(i
                || '
.'
                || substr(fnd_msg_pub.get(p_encoded => fnd_api.g_false),1,255) );
            END LOOP;
        END IF;
    END LOOP;
END;

No comments:

Post a Comment