Tuesday, December 21, 2010

Script for Creating sales person(CRM)

DECLARE
CURSOR get_credit_id(v_name VARCHAR2)
IS
select sales_credit_type_id
FROM oe_sales_credit_types
WHERE name = v_name;

l_Credit_id NUMBER;
l_salesrep_id NUMBER;
l_msg_count NUMBER;
l_msg_Data varchar2(2000);
l_return_status varchar2(1);
l_msg_index_out  NUMBER;

BEGIN
OPEN get_credit_id('Quota Sales Credit');  ----Pass the Sales Quota Type
FETCH get_Credit_id INTO l_credit_id;
CLOSE get_Credit_id;
dbms_application_info.set_client_info('240'); ---Set the ORG if being run from SQLPLUS
jtf_rs_salesreps_pub.CREATE_SALESREP(
 P_API_VERSION                  => 1.0,
 P_INIT_MSG_LIST                => 'T',
 P_COMMIT                       => 'T',
 P_RESOURCE_ID                  => 100000020,          ----Get the resource id from JTF_RS_RESOURCE_EXTNS
 P_SALES_CREDIT_TYPE_ID         => l_credit_id,
 P_NAME                         => 'Kanti Jinger',  ----Name of the resource
 P_STATUS                       => NULL,
 P_START_DATE_ACTIVE            => sysdate,
 P_END_DATE_ACTIVE              => NULL,
 P_GL_ID_REV                    => NULL,
 P_GL_ID_FREIGHT                => NULL,
 P_GL_ID_REC                    => NULL,
 P_SET_OF_BOOKS_ID              => 1001,          ------Replace with your set of Books ID
 P_SALESREP_NUMBER              => 'ABCD00991',
 P_EMAIL_ADDRESS                =>  ----Replace with Email ID of the user
 P_WH_UPDATE_DATE               => sysdate,
 P_SALES_TAX_GEOCODE            => NULL,
 P_SALES_TAX_INSIDE_CITY_LIMITS => NULL,
 X_RETURN_STATUS                => l_return_status,
 X_MSG_COUNT                    => l_msg_count,
 X_MSG_DATA                     => l_msg_data,
 X_SALESREP_ID                  => l_salesrep_id);

dbms_output.put_line('return status is ' || l_return_Status);
 FND_MSG_PUB.GET(p_msg_index     => 1,
                 p_encoded       => 'F',          
                 p_data          => l_msg_data,
                 p_msg_index_out => l_msg_index_out);  
                         
 DBMS_OUTPUT.put_line('API Error Message : '||l_msg_data);
dbms_output.put_line('msg data is  ' || l_msg_data);
dbms_output.put_line('Sales Rep id is ' || l_salesrep_id);
END;

No comments:

Post a Comment