DECLARE
l_return_status VARCHAR2(1);
l_msg_count NUMBER;
l_msg_data VARCHAR2(240);
l_pm_product_code VARCHAR2(30) := 'AMW';
l_event_rec pa_event_pub.event_rec_in_type;
l_event_in_tbl_type pa_event_pub.event_in_tbl_type;
l_event_out_tbl_type pa_event_pub.event_out_tbl_type;
BEGIN
fnd_global.apps_initialize(user_id => 0
,resp_id => 51429
,resp_appl_id => 275);
mo_global.set_policy_context('S'
,106);
fnd_profile.put(NAME => 'PA_DEBUG.MODE'
,val => 'Y');
fnd_profile.put(NAME => 'PA_DEBUG_MODE'
,val => 'Y');
--后台导入、产品来源和事件参考要求必输
l_event_rec := NULL;
l_event_rec.p_pm_event_reference := '2'; --事件参考
l_event_rec.p_task_number := '1'; --任务编号
l_event_rec.p_event_number := '2'; --事件编号
l_event_rec.p_event_type := '开票13%销项'; --事件类型
l_event_rec.p_agreement_number := NULL; --协议编号
l_event_rec.p_agreement_type := NULL; --协议类型
l_event_rec.p_customer_number := NULL; --客户编码
l_event_rec.p_description := NULL; --摘要
l_event_rec.p_bill_hold_flag := 'N'; --开单暂挂
l_event_rec.p_completion_date := NULL;
l_event_rec.p_desc_flex_name := NULL;
l_event_rec.p_attribute_category := NULL;
l_event_rec.p_attribute1 := NULL;
l_event_rec.p_attribute2 := NULL;
l_event_rec.p_attribute3 := NULL;
l_event_rec.p_attribute4 := NULL;
l_event_rec.p_attribute5 := NULL;
l_event_rec.p_attribute6 := NULL;
l_event_rec.p_attribute7 := NULL;
l_event_rec.p_attribute8 := NULL;
l_event_rec.p_attribute9 := NULL;
l_event_rec.p_attribute10 := NULL;
l_event_rec.p_project_number := '120101010284';
l_event_rec.p_organization_name := 'OU_中艺生态';
l_event_rec.p_inventory_org_name := NULL;
l_event_rec.p_inventory_item_id := NULL;
l_event_rec.p_quantity_billed := NULL;
l_event_rec.p_uom_code := NULL;
l_event_rec.p_unit_price := NULL;
l_event_rec.p_reference1 := NULL;
l_event_rec.p_reference2 := NULL;
l_event_rec.p_reference3 := NULL;
l_event_rec.p_reference4 := NULL;
l_event_rec.p_reference5 := NULL;
l_event_rec.p_reference6 := NULL;
l_event_rec.p_reference7 := NULL;
l_event_rec.p_reference8 := NULL;
l_event_rec.p_reference9 := NULL;
l_event_rec.p_reference10 := NULL;
l_event_rec.p_bill_trans_currency_code := 'CNY'; --币种
l_event_rec.p_bill_trans_bill_amount := 10000; --开单额
l_event_rec.p_bill_trans_rev_amount := 0; --收入额
l_event_rec.p_project_rate_type := NULL;
l_event_rec.p_project_rate_date := NULL;
l_event_rec.p_project_exchange_rate := NULL;
l_event_rec.p_projfunc_rate_type := NULL;
l_event_rec.p_projfunc_rate_date := NULL;
l_event_rec.p_projfunc_exchange_rate := NULL;
l_event_rec.p_funding_rate_type := 'Corporate';
l_event_rec.p_funding_rate_date := NULL;
l_event_rec.p_funding_exchange_rate := NULL;
l_event_rec.p_adjusting_revenue_flag := NULL;
l_event_rec.p_event_id := NULL;
l_event_rec.p_deliverable_id := NULL;
l_event_rec.p_action_id := NULL;
l_event_rec.p_context := NULL;
l_event_rec.p_record_version_number := 1;
l_event_rec.p_bill_group := NULL;
l_event_rec.p_revenue_hold_flag := 'N';
l_event_in_tbl_type(1) := l_event_rec;
pa_event_pub.create_event(p_api_version_number => 1
,p_commit => fnd_api.g_false
,p_init_msg_list => fnd_api.g_true
,p_pm_product_code => l_pm_product_code
,p_event_in_tbl => l_event_in_tbl_type
,p_event_out_tbl => l_event_out_tbl_type
,p_msg_count => l_msg_count
,p_msg_data => l_msg_data
,p_return_status => l_return_status);
IF l_return_status = fnd_api.g_ret_sts_success THEN
dbms_output.put_line('创建事件项目成功!');
COMMIT;
ELSE
ROLLBACK;
dbms_output.put_line('创建事件项目失败!');
IF l_msg_count = 1 THEN
dbms_output.put_line('eror_message:' || l_msg_data);
fnd_msg_pub.delete_msg();
ELSIF l_msg_count > 1 THEN
FOR i IN 1 .. l_msg_count LOOP
dbms_output.put_line('eror_message[' || i || ']:' || substr(fnd_msg_pub.get(fnd_msg_pub.g_next
,fnd_api.g_false)
,1
,250));
END LOOP;
fnd_msg_pub.delete_msg();
ELSE
dbms_output.put_line('eror_message:' || fnd_message.get);
END IF;
END IF;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
dbms_output.put_line('sqlerrm =' || SQLERRM);
END;