API para criar cliente – perfil e conta

Neste post irei mostrar uma API para criar o cadastro do cliente.

DECLARE
custAcccountRec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
custProfileRec HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
custOrgRec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
custPartyRec HZ_PARTY_V2PUB.PARTY_REC_TYPE;

x_cust_account_id NUMBER;
x_account_number VARCHAR2 (30);
x_party_id NUMBER;
x_party_number VARCHAR2 (30);
x_profile_id NUMBER;
x_return_status VARCHAR2 (3);
x_msg_count NUMBER;
x_msg_data VARCHAR2 (3000);
l_collector_id NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE ('In createCustomer Procedure.');
mo_global.init ('AR');
fnd_global.apps_initialize (user_id => 26801,
resp_id => 50677,
resp_appl_id => 222);

mo_global.set_policy_context ('S', 196);

SELECT collector_id
INTO l_collector_id
FROM ar_collectors
WHERE name = 'Negócio Aeroestruturas';


custAcccountRec.attribute_category := newCustRec.cust_att_category;
custAcccountRec.attribute1 := newCustRec.attribute1;
custAcccountRec.attribute2 := newCustRec.attribute2;
custAcccountRec.attribute3 := newCustRec.attribute3;
custAcccountRec.attribute4 := newCustRec.attribute4;
custAcccountRec.attribute5 := newCustRec.attribute5;
custAcccountRec.orig_system_reference := newCustRec.orig_system_reference;
custAcccountRec.customer_class_code := newCustRec.customer_class_code;
custAcccountRec.status := 'A';
custAcccountRec.customer_type := 'R';
custAcccountRec.created_by_module := 'AR';

custPartyRec.orig_system_reference := newCustRec.orig_system_reference;
custPartyRec.status := 'A';
custPartyRec.attribute1 := newCustRec.attribute1;
custPartyRec.attribute2 := newCustRec.attribute2;
custPartyRec.attribute3 := newCustRec.attribute3;
custPartyRec.attribute4 := newCustRec.attribute4;
custPartyRec.attribute5 := newCustRec.attribute5;


custOrgRec.organization_name := newCustRec.party_name;
custOrgRec.created_by_module := 'AR';
custOrgRec.party_rec := custPartyRec;


custProfileRec.profile_class_id := newCustRec.profile_class_id;
custProfileRec.collector_id := newCustRec.collector_id;
custProfileRec.credit_checking := newCustRec.credit_checking;
custProfileRec.tolerance := newCustRec.tolerance;
custProfileRec.discount_terms := newCustRec.discount_terms;
custProfileRec.dunning_letters := newCustRec.dunning_letters;
custProfileRec.interest_charges := newCustRec.interest_charges;
custProfileRec.send_statements := newCustRec.send_statements;
custProfileRec.credit_balance_statements :=
newCustRec.credit_balance_statements;
custProfileRec.credit_hold := newCustRec.credit_hold;


HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT (
p_init_msg_list => FND_API.G_TRUE,
p_cust_account_rec => custAcccountRec,
p_organization_rec => custOrgRec,
p_customer_profile_rec => custProfileRec,
p_create_profile_amt => FND_API.G_TRUE,
x_cust_account_id => x_cust_account_id,
x_account_number => x_account_number,
x_party_id => x_party_id,
x_party_number => x_party_number,
x_profile_id => x_profile_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data);

IF x_return_status = fnd_api.g_ret_sts_success
THEN
COMMIT;
ELSE
DBMS_OUTPUT.put_line (x_msg_data);
ROLLBACK;

FOR i IN 1 .. x_msg_count
LOOP
x_msg_data := oe_msg_pub.get (p_msg_index => i, p_encoded => ‘F’);
DBMS_OUTPUT.PUT_LINE (x_msg_data);
END LOOP;
END IF;

COMMIT;
END;

Deixe uma resposta

Powered by WordPress.com. Tema: Baskerville 2 por Anders Noren

Acima ↑

%d blogueiros gostam disto: