NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

[Script 1.0]

script package cfg$phy_lib
is
--------------------------------------------------------------------------
-- @cfg$phy_lib
-- @AMI
-- @SOP
--------------------------------------------------------------------------
-- @Change history
-- @Date @AvaloqRel @Author @Issue @Change description
-- 20.04.2012 3.3 XCFKTS Creation
--------------------------------------------------------------------------
-- @description
-- Package for INTERFACE PHY
--
--------------------------------------------------------------------------

import doc_stex;
import err;
import util;
import cfg$sop_stex_def;
import native msg#;
import native msg_mgr#;
import native def_doc_role_stex;
import cfg$fix;
import cfg$fix_in;
import cfg$strup_util;
import cfg$fix_exe_rep_new_in_css;
import cfg$tre_cred_lib;

--------------------------------------------------------------------------
-- procedure get_link_exec
--------------------------------------------------------------------------
-- @description
-- get execution order
--
-- @param
-- i_doc The order
--
--------------------------------------------------------------------------
function get_link_exec(
i_doc doc_stex
) return doc_stex
is
begin

-- Identifier of linked execution orders
for i in i_doc.exec_exec_doc_id_list loop
-- session.debug('loop exec_exec_doc_id list : '||i.id);
return i.id;
end loop;

return null;

exception
when others then
err.raise_fa('cfg$phy_lib.get_link_exec'
,'i_doc' ,i_doc
);

end get_link_exec;

--------------------------------------------------------------------------
-- Soufiane KTIRI
-- procedure get_link_exec
--------------------------------------------------------------------------
-- @description
-- get execution order
--
-- @param
-- i_doc The order
--
--------------------------------------------------------------------------
function get_cfg_order_nr(
i_doc doc_stex
) return number
is

l_exec_doc_id number;
l_exec_ref_extl text;
l_cfg_exec_doc_id id doc_stex;
l_cfg_exec_doc text;
l_cfg_exec_doc_nr number;
l_cfg_order_nr number;

begin
-- session.debug('order number');
-- Identifier of linked execution orders
for i in i_doc.recti_doc.link_list loop
-- session.debug('loop Link list : '||i.id);
if i.meta_typ_id = 1 and i.doc_role_id = def_doc_role_stex.exec then
-- session.debug('Execution Order : '||i.id);
l_exec_doc_id := doc_stex(i.id).orig_doc_id;
-- session.debug('l_exec_doc_id : '||l_exec_doc_id);
end if;
end loop;

if l_exec_doc_id is not null then
l_exec_ref_extl := doc_stex(l_exec_doc_id).extl_ref_nr;
-- session.debug('l_exec_ref_extl : '||l_exec_ref_extl);
l_cfg_exec_doc := util.item(i_list => l_exec_ref_extl,
i_seq_nr => 1,
i_sep => '/');
l_cfg_exec_doc := substr(l_cfg_exec_doc,2,100);
l_cfg_order_nr := l_cfg_exec_doc;

end if;

return l_cfg_order_nr;

exception
when others then
err.raise_fa('cfg$phy_lib.get_cfg_order_nr'
,'i_doc' ,i_doc
);
end get_cfg_order_nr;


--------------------------------------------------------------------------
-- Soufiane KTIRI
-- procedure get_link_exec
--------------------------------------------------------------------------
-- @description
-- get execution order
--
-- @param
-- i_doc The order
--
--------------------------------------------------------------------------
function is_phy_processed(
i_doc doc_stex
) return boolean
is
begin

if i_doc.extn.cfg$stex_contract_num is not null then
return true;
else
-- Identifier of linked execution orders
for i in i_doc.link_list loop
if i.meta_typ_id = 9 then
if doc_settle(i.id).extn.cfg$stex_contract_num is not null then
return true;
end if;
end if;
end loop;

end if;

return false;

exception
when others then
err.raise_fa('cfg$phy_lib.is_phy_processed'
,'i_doc' ,i_doc
);
end is_phy_processed;

--------------------------------------------------------------------------
-- procedure get_order_billing
--------------------------------------------------------------------------
-- @description
-- get billing order from
--
-- @param
-- i_doc The order
-- i_m The message
--
--------------------------------------------------------------------------
function get_order_billing(
i_doc doc_stex,
i_m mem_msg_cfg$phy_transaction_new
) return id doc_stex
is
l_exec_doc id doc_stex;
begin

-- Total Execution
if i_doc.bill_part_exec_doc_id_list.count = 0 then
return i_doc;
-- Partial execution
else
for bill_stex in i_doc.bill_part_exec_doc_id_list loop
l_exec_doc := get_link_exec(bill_stex);
with doc_stex(l_exec_doc) as exec_doc do
if abs(bill_stex.qty) = i_m.body_msg.qte_titre
and exec_doc.price_clt = i_m.body_msg.cours
and exec_doc.extn.cfg$stex_contract_num is null
then
return bill_stex.id;
end if;
end with;
end loop;
end if;

if i_doc.exec_is_fully_executed = '+' then
return i_doc;
else
return null;
end if;

exception
when others then
err.raise_fa('cfg$phy_lib.get_order_billing'
,'i_doc' ,i_doc
,'i_m' ,i_m
);
end get_order_billing;

--------------------------------------------------------------------------
-- procedure get_link_mem_exec
--------------------------------------------------------------------------
-- @description
-- get execution order
--
-- @param
-- i_doc The order
--
--------------------------------------------------------------------------
function get_link_mem_exec(
i_doc mem_doc_stex
) return doc_stex
is
begin

-- Identifier of linked execution orders
for i in i_doc.exec_exec_doc_id_list loop
return i.id;
end loop;

return null;

exception
when others then
err.raise_fa('cfg$phy_lib.get_link_mem_exec'
,'i_doc' ,i_doc
);

end get_link_mem_exec;

--------------------------------------------------------------------------
-- procedure update_oms_ref
--------------------------------------------------------------------------
-- @description
-- Update OMS Reference
--
-- @param
-- i_msg PHY message
--
--------------------------------------------------------------------------
procedure update_oms_ref(
i_msg msg
,i_extl_ref_nr text
)
is
l_extl_ref_nr text := null;
begin

l_extl_ref_nr := i_extl_ref_nr;
if l_extl_ref_nr is not null then
msg#.upd_extl_ref_nr(i_msg_id => i_msg.id,
i_extl_ref_nr => l_extl_ref_nr);
msg_mgr#.msg#set_extl_ref_nr(i_msg => i_msg.id,
i_extl_ref_nr => l_extl_ref_nr);
msg_mgr#.msg#commit_trx(i_msg => i_msg.id,
i_trx => null,
i_state => null);
end if;

exception
when others then
err.raise_fa('cfg$phy_lib.update_oms_ref'
,'i_msg' ,i_msg.id
);
end update_oms_ref;

--------------------------------------------------------------------------
-- procedure gen_phy_msg_recti_out
--------------------------------------------------------------------------
-- @description
-- Generate a outgoing PHY rectification
--
-- @param
-- i_doc doc_stex
--
--------------------------------------------------------------------------
procedure gen_phy_msg_recti_out(
i_doc doc_stex
,i_extl_ref_nr text
,i_cont text := null
,i_macc_rib_key text := null
,i_book_kind number := null
,i_cost_ovr_type number := null
,i_cost number := null
)
is
l_netw_phy_id number := lookup.code('code_netw', 'cfg$phy');
l_meta_msg_id number;
l_avq_ref_order text;
l_oms_ref_order text;
l_link_exec_doc number;
l_exec_ref_extl_nr text;
l_cfg_order_nr number;
begin

l_meta_msg_id := lookup.meta_msg_id(netw_id => l_netw_phy_id,
name => 'cfg$phy_transaction_recti_out',
dir => 'o');

l_avq_ref_order := util.item(i_list => i_extl_ref_nr,
i_seq_nr => 1,
i_sep => ',');
l_oms_ref_order := util.item(i_list => i_extl_ref_nr,
i_seq_nr => 2,
i_sep => ',');

-- session.debug('l_avq_ref_order : '||l_avq_ref_order);
-- session.debug('l_oms_ref_order : '||l_oms_ref_order);
-- session.debug('doc.id : '||i_doc.id);

-- SKT 15/11/2012 Rectify Unsolicited Pre allocated
if l_avq_ref_order is not null and l_oms_ref_order is null then
if l_avq_ref_order = i_doc.id then
l_cfg_order_nr := get_cfg_order_nr(i_doc);
if l_cfg_order_nr is not null then
l_avq_ref_order := l_cfg_order_nr;
end if;
end if;
end if;

with new mem_msg_cfg$phy_transaction_recti(l_meta_msg_id) as m do

m.head.rcv_bp_id := lookup.bp_id('BU.CFG');
m.head.prty(code_msg_prty.ami_intl_route_rcv_bu_id) := lookup.bp_id('BU.CFG');

-- Fill the Mandatory Parameter (données bidons)
m.body_msg.taille_corps := 100;
m.body_msg.type_msg := '03';
m.body_msg.num_seq := 10000;
m.body_msg.date_gen_msg := sysdate;
m.body_msg.heure_gen_msg := '000000';

---- FILL IN MESSAGE BODY ----
m.body_msg.num_contrat := null;
m.body_msg.libelle_valeur := i_cont;
m.body_msg.marche := null;
m.body_msg.qte_titre := i_book_kind;
m.body_msg.cours := i_cost;
m.body_msg.sens := null;
m.body_msg.volume := i_cost_ovr_type;
-- m.body_msg.libelle_sdb := null;
m.body_msg.contre_partie := null;
m.body_msg.ref_ordre := l_oms_ref_order;
m.body_msg.code_mcl := l_avq_ref_order;
-- m.body_msg.code_sdb := null;
m.body_msg.heure_transaction := '00000000';
m.body_msg.rectify_info := i_macc_rib_key;

---- LINK MESSAGE TO CLIENT ORDER ----
m.head.doc_id := i_doc.id;

---- SEND OUT THE MESSAGE ----

m.send;

end with;

exception
when others then
err.raise_fa('cfg$phy_lib.gen_phy_msg_recti_out'
,'i_doc' ,i_doc.order_nr
);
end gen_phy_msg_recti_out;

--------------------------------------------------------------------------
-- procedure gen_phy_msg_recti_fm_out
--------------------------------------------------------------------------
-- @description
-- Generate a outgoing PHY rectification for FM message
--
-- @param
-- i_doc doc_stex
--
--------------------------------------------------------------------------
procedure gen_phy_msg_recti_fm_out(
i_doc doc_stex
)
is
l_netw_phy_id number := lookup.code('code_netw', 'cfg$phy');
l_meta_msg_id number;
l_doc_id number;
l_num_contrat text;
l_libelle_valeur text;
l_marche text;
l_qte_titre text;
l_cours text;
l_sens text;
l_volume text;
l_libelle_sdb text;
l_contre_partie text;
l_ref_ordre text;
l_code_mcl text;
l_code_sdb text;
l_heure_transaction text;
begin

l_meta_msg_id := lookup.meta_msg_id(netw_id => l_netw_phy_id,
name => 'cfg$phy_transaction_recti_out',
dir => 'o');
with new mem_msg_cfg$phy_transaction_recti(l_meta_msg_id) as m do

m.head.rcv_bp_id := lookup.bp_id('BU.CFG');
m.head.prty(code_msg_prty.ami_intl_route_rcv_bu_id) := lookup.bp_id('BU.CFG');

-- Fill the Mandatory Parameter (données bidons)
m.body_msg.taille_corps := 100;
m.body_msg.type_msg := '03';
m.body_msg.num_seq := 10000;
m.body_msg.date_gen_msg := sysdate;
m.body_msg.heure_gen_msg := '000000';

with doc_stex(i_doc) as stex do
l_doc_id := stex.id;
l_num_contrat := stex.order_nr;
l_libelle_valeur := stex.asset.extn.asset_isin;
l_marche := 'MC';
l_qte_titre := abs(stex.qty);
l_cours := abs(stex.price_avrg);
if stex.order_type_grp_id = cfg$sop_stex_def.c_buy_id then
l_sens := 'A';
else
l_sens := 'V';
end if;
l_volume := null;
l_libelle_sdb := null;
l_contre_partie := null;
l_ref_ordre := stex.extn.cfg$oms_ref_nr;
l_code_mcl := null;
l_code_sdb := null;
l_heure_transaction := sysdate;
end with;

---- FILL IN MESSAGE BODY ----
m.body_msg.num_contrat := l_num_contrat;
m.body_msg.libelle_valeur := l_libelle_valeur;
m.body_msg.marche := l_marche;
m.body_msg.qte_titre := l_qte_titre;
m.body_msg.cours := l_cours;
m.body_msg.sens := l_sens;
m.body_msg.volume := l_volume;
-- m.body_msg.libelle_sdb := l_libelle_sdb;
m.body_msg.contre_partie := l_contre_partie;
m.body_msg.ref_ordre := l_ref_ordre;
m.body_msg.code_mcl := l_code_mcl;
-- m.body_msg.code_sdb := l_code_sdb;
m.body_msg.heure_transaction := l_heure_transaction;

---- LINK MESSAGE TO CLIENT ORDER ----
m.head.doc_id := l_doc_id;

---- SEND OUT THE MESSAGE ----
m.send;

end with;

exception
when others then
err.raise_fa('cfg$phy_lib.gen_phy_msg_recti_fm_out'
,'i_doc' ,i_doc.order_nr
);
end gen_phy_msg_recti_fm_out;


procedure gen_stex_order(
i_m mem_msg_cfg$phy_transaction_new
)
is

l_asset_id id obj_asset;
l_mkt_id id obj_mkt;
l_qty text;
l_cont_id id obj_cont;
l_bp_id id obj_bp;
l_order_type_id number;
l_wfa_open_tp_id number;
l_wfa_store_tp_id number;
l_limit number;
l_extl_ref_nr text;
l_price_cmtd_id number;
l_exec_type_id number;
l_medium_id number;
l_macc_id id obj_pos;
l_num_contrat text;


begin

require(i_m is not null, 'i_m is not null');

-- session.debug('MSG PHY : BEGIN GENERATION OF IPO ORDER');

l_mkt_id := lookup.mkt_id(key_val => 'IP', key_type => 'mkt_id', ign_multi_val_excp => '+');
l_order_type_id := lookup.code('code_order_type', 'stex_sell_cnt'); --cfg$base_par_intf_fix.sell_close_cnt_ot_id;
l_cont_id := cfg$fix.c_dflt_cont_id;
l_qty := i_m.body_msg.qte_titre;
l_asset_id := lookup.asset_id (key_val => i_m.body_msg.code_mcl, key_type => cfg$fix.c_asset_obj_key_id, eff_date => session.today, restr_bu => iff(cfg$fix.c_do_restr_lookup, '+'));
l_limit := i_m.body_msg.cours;
l_extl_ref_nr := 'CFG'||obj_asset(l_asset_id).key(obj_key => 'cfg$asset_ticker_key')||'SELL';
l_num_contrat := i_m.body_msg.num_contrat;
l_bp_id := cfg$fix.c_dflt_bp_id;
l_price_cmtd_id := lookup.code('code_stex_price_cmtd', 'normal');
l_exec_type_id := lookup.code('code_order_sub_type', 'cfg$stex_exec_lob');
l_medium_id := lookup.code('code_medium', 'cfg$oth_medium');
l_macc_id := 375878;

-- session.debug('parametre rempli');

l_wfa_open_tp_id := cfg$sop_stex_def.c_wfa_open_tp_exec_id;
l_wfa_store_tp_id := cfg$sop_stex_def.c_wfa_store_tp_exec_id;
with new mem_doc_stex(l_wfa_open_tp_id) as stex do
stex.do_calc := '-';
stex.order_type_id := l_order_type_id;
stex.cont_id := l_cont_id;
stex.qty := l_qty;
stex.asset_id := l_asset_id;
stex.price_fix := l_limit;
stex.limit := l_limit;
stex.extl_ref_nr := l_extl_ref_nr;
stex.mkt_id := l_mkt_id;
stex.extn.cfg$stex_contract_num := l_num_contrat;
stex.val_date := session.today;
stex.perf_date := session.today + 5;
stex.bp_id := l_bp_id;
stex.price_cmtd_id := l_price_cmtd_id;
stex.exec_type_id := l_exec_type_id;
stex.medium_id := l_medium_id;
stex.macc_id := l_macc_id;

-- session.debug('valeur : ' || num_contrat || ' rempli dans stex ' || stex.extn.cfg$stex_contract_num );

-- session.debug('before calc');
stex.do_calc := '+';
-- session.debug('after calc');
stex.calc_all;
-- session.debug('calc all : ' || stex.doc_id);
stex.do_wfc_action(
wfc_action_id => l_wfa_store_tp_id
,no_commit => '-'
);
end with;

-- session.debug('done i think');
-- session.debug('After generation');

-- session.debug('Created client / market order with id ' || l_clt_doc_id || ' estim ' || l_price_estim);
end gen_clt_doc;


-- xcfaba && xcfben
procedure gen_stex_order_bloc(
i_m mem_msg_cfg$phy_transaction_new
,i_sens text
)
is
l_asset_id id obj_asset;
l_mkt_id id obj_mkt;
l_qty text;
l_cont_id id obj_cont;
l_bp_id id obj_bp;
l_order_type_id number;
l_wfa_open_tp_id number;
l_wfa_store_tp_id number;
l_limit number;
l_extl_ref_nr text;
l_price_cmtd_id number;
l_exec_type_id number;
l_medium_id number;
l_macc_id id obj_pos;
l_num_contrat text;
begin
require(i_m is not null, 'i_m is not null');
session.debug('in gen_stex_order_bloc');
-- Market Bloc
l_mkt_id := cfg$sop_stex_def.c_mkt_bcv_bloc_id;

-- Order type according to sens
if i_sens = 'V' then
l_order_type_id := cfg$sop_stex_def.c_ot_stex_sell_cnt_id;
elsif i_sens = 'A' then
l_order_type_id := cfg$sop_stex_def.c_ot_stex_buy_cnt_id;
end if;

l_cont_id := cfg$fix.c_dflt_cont_id;
l_qty := i_m.body_msg.qte_titre;
l_asset_id := lookup.asset_id(
key_val => i_m.body_msg.code_mcl,
key_type => cfg$fix.c_asset_obj_key_id,
eff_date => session.today,
restr_bu => iff(cfg$fix.c_do_restr_lookup, '+')
);
l_limit := i_m.body_msg.cours;
l_num_contrat := i_m.body_msg.num_contrat;
l_bp_id := cfg$fix.c_dflt_bp_id;
l_price_cmtd_id := lookup.code('code_stex_price_cmtd', 'normal');
l_exec_type_id := lookup.code('code_order_sub_type', 'PM');
--l_exec_type_id := lookup.code('code_order_sub_type', 'cfg$stex_exec_lob');
l_medium_id := lookup.code('code_medium', 'cfg$oth_medium');
l_macc_id := 375878; -- NOT SURE

l_extl_ref_nr :=
'CFG'
|| obj_asset(l_asset_id).key(obj_key => 'cfg$asset_ticker_key')
|| case when i_sens = 'V' then 'SELLBLOC' else 'BUYBLOC' end;


l_wfa_open_tp_id := cfg$sop_stex_def.c_wfa_open_tp_exec_id;
l_wfa_store_tp_id := cfg$sop_stex_def.c_wfa_store_tp_exec_id;

with new mem_doc_stex(l_wfa_open_tp_id) as stex do
stex.do_calc := '-';
stex.order_type_id := l_order_type_id;
stex.cont_id := l_cont_id;
stex.qty := l_qty;
stex.asset_id := l_asset_id;
stex.price_fix := l_limit;
stex.limit := l_limit;
stex.extl_ref_nr := l_extl_ref_nr;
stex.mkt_id := l_mkt_id;
stex.extn.cfg$stex_contract_num := l_num_contrat;
stex.val_date := session.today;
stex.perf_date := session.today + 5;
stex.bp_id := l_bp_id;
stex.price_cmtd_id := l_price_cmtd_id;
stex.exec_type_id := l_exec_type_id;
stex.medium_id := l_medium_id;
stex.macc_id := l_macc_id;

stex.do_calc := '+';
stex.calc_all;

stex.do_wfc_action(
wfc_action_id => l_wfa_store_tp_id,
no_commit => '-'
);
session.debug('stex created id : ' || stex.doc_id);
end with;
end gen_stex_order_bloc;

end cfg$phy_lib;
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.