DECLARE
vSession NUMBER;
xReturnStatus VARCHAR2(1);
xMsgCount NUMBER := 0;
xMsgData VARCHAR2(2000);
vCount NUMBER;
xErrorCount NUMBER;
vSourcingRuleRec MRP_SOURCING_RULE_PUB.SOURCING_RULE_REC_TYPE;
VSourcingRuleValRec MRP_SOURCING_RULE_PUB.SOURCING_RULE_VAL_REC_TYPE;
vReceivingOrgTbl MRP_SOURCING_RULE_PUB.RECEIVING_ORG_TBL_TYPE;
vReceivingOrgValTbl MRP_SOURCING_RULE_PUB.RECEIVING_ORG_VAL_TBL_TYPE;
vShippingOrgTbl MRP_SOURCING_RULE_PUB.SHIPPING_ORG_TBL_TYPE;
vShippingOrgValTbl MRP_SOURCING_RULE_PUB.SHIPPING_ORG_VAL_TBL_TYPE;
xSourcingRuleRec MRP_SOURCING_RULE_PUB.SOURCING_RULE_REC_TYPE;
xSourcingRuleValRec MRP_SOURCING_RULE_PUB.SOURCING_RULE_VAL_REC_TYPE;
xReceivingOrgTbl MRP_SOURCING_RULE_PUB.RECEIVING_ORG_TBL_TYPE;
xReceivingOrgValTbl MRP_SOURCING_RULE_PUB.RECEIVING_ORG_VAL_TBL_TYPE;
xShippingOrgTbl MRP_SOURCING_RULE_PUB.SHIPPING_ORG_TBL_TYPE;
xShippingOrgValTbl MRP_SOURCING_RULE_PUB.SHIPPING_ORG_VAL_TBL_TYPE;
BEGIN
fnd_message.clear;
vSourcingRuleRec := MRP_SOURCING_RULE_PUB.G_MISS_SOURCING_RULE_REC;
vSourcingRuleRec.sourcing_rule_name := 'CAMEO RULE'; --SR Name
vSourcingRuleRec.Organization_Id := 954;
vSourcingRuleRec.planning_active := 1;
vSourcingRuleRec.status := 1; -- Update New record
vSourcingRuleRec.sourcing_rule_type := 1; -- (1) Sourcing Rule (2) Bill of
vSourcingRuleRec.operation := 'CREATE'; --Create / Update / Delete
vReceivingOrgTbl := MRP_SOURCING_RULE_PUB.G_MISS_RECEIVING_ORG_TBL;
vShippingOrgTbl := MRP_SOURCING_RULE_PUB.G_MISS_SHIPPING_ORG_TBL;
vReceivingOrgTbl(1).effective_date := trunc(SYSDATE);
vReceivingOrgTbl(1).disable_date := trunc(SYSDATE) + 7;
vReceivingOrgTbl(1).receipt_organization_id := 00;
vReceivingOrgTbl(1).operation := 'CREATE';
vShippingOrgTbl(1).rank := 1;
vShippingOrgTbl(1).allocation_percent := 100;
vShippingOrgTbl(1).source_type := 3; -- Make / Transfer / Buy
vShippingOrgTbl(1).vendor_id := 00;
vShippingOrgTbl(1).receiving_org_index := 1; --Foreign key to the receipt organization PL/SQL table , Default Value: FND_API.G_MISS_NUM
vShippingOrgTbl(1).operation := 'CREATE';
dbms_output.put_line('Before call');
dbms_output.put_line('Operation before call => ' || vSourcingRuleRec.operation);
mrp_sourcing_rule_pub.process_sourcing_rule(p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_return_status => xReturnStatus,
x_msg_count => xMsgCount,
x_msg_data => xMsgData,
p_sourcing_rule_rec => vSourcingRuleRec,
p_sourcing_rule_val_rec => VSourcingRuleValRec,
p_receiving_org_tbl => vReceivingOrgTbl,
p_receiving_org_val_tbl => vReceivingOrgValTbl,
p_shipping_org_tbl => vShippingOrgTbl,
p_shipping_org_val_tbl => vShippingOrgValTbl,
x_sourcing_rule_rec => xSourcingRuleRec,
x_sourcing_rule_val_rec => xSourcingRuleValRec,
x_receiving_org_tbl => xReceivingOrgTbl,
x_receiving_org_val_tbl => xReceivingOrgValTbl,
x_shipping_org_tbl => xShippingOrgTbl,
x_shipping_org_val_tbl => xShippingOrgValTbl);
dbms_output.put_line('API Retrun Status => ' || xReturnStatus);
IF xReturnStatus = fnd_api.g_ret_sts_success THEN
dbms_output.put_line('Success!');
dbms_output.put_line('Source Rule ID => ' || xSourcingRuleRec.Sourcing_Rule_Id);
ELSE
dbms_output.put_line('Error Count:' || xMsgCount);
IF xMsgCount > 0 THEN
FOR l_index IN 1 .. xMsgCount
LOOP
xMsgData := fnd_msg_pub.get(p_msg_index => l_index,
p_encoded => FND_API.G_FALSE);
dbms_output.put_line(substr(xMsgData, 1, 250));
END LOOP;
END IF;
dbms_output.put_line('Failure!');
END IF;
END;
沒有留言:
張貼留言