You are on page 1of 3

/* Formatted on 2019/10/14 13:49 (Formatter Plus v4.8.

8) */
DECLARE
p1 CLOB;
p2 CLOB;
p3 CLOB;
num NUMBER;

CURSOR cur1
IS
SELECT MAX (message_num)
FROM rms.rib_message;

CURSOR c1
IS

SELECT a.id_itm, a.qu_itm, b.id_prty_fm_icd


FROM sim.tr_ltm_icd_mr@simprod.world a,
sim.do_ctl_inv@simprod.world b
WHERE B.ORDER_ID = '3070824887' AND a.id_icd = b.id_icd AND QU_ITM <>0 ;

CURSOR c2
IS

SELECT a.tsf_no, b.id_prty_fm_icd to_loc, b.id_prty_to_icd from_loc,


TO_CHAR (b.dc_sprc_act_shp, 'DD') DAY,
TO_CHAR (b.dc_sprc_act_shp, 'MM') MONTH,
TO_CHAR (b.dc_sprc_act_shp, 'YYYY') YEAR
FROM rms.tsfhead a, sim.do_ctl_inv@simprod.world b,
sim.do_ctl_inv@simprod.world c
WHERE tsf_no = '3070824887' AND a.tsf_no = b.id_icd and b.id_icd =
c.order_id;

BEGIN
OPEN cur1;

FETCH cur1
INTO num;

CLOSE cur1;

FOR i IN c2
LOOP
p1 :=
'<?xml version="1.0" encoding="UTF-8"?><ASNOutDesc><to_location>'
|| i.to_loc
|| '</to_location><from_location>'
|| i.from_loc
|| '</from_location><asn_nbr>'
|| i.tsf_no
||
'</asn_nbr><asn_type>C</asn_type><container_qty>1</container_qty><bol_nbr>'
|| i.tsf_no
|| '</bol_nbr><shipment_date><year>'
|| i.YEAR
|| '</year><month>'
|| i.MONTH
|| '</month><day>'
|| i.DAY
||
'</day><hour>22</hour><minute>5</minute><second>55</second></shipment_date><ship_ad
dress1></ship_address1><ship_address2></ship_address2><ship_address3></
ship_address3><ship_address4></ship_address4><ship_address5></
ship_address5><ship_city></ship_city><ship_state></ship_state><ship_zip></
ship_zip><ship_country_id></ship_country_id><trailer_nbr></
trailer_nbr><seal_nbr></seal_nbr><carrier_code></
carrier_code><transshipment_nbr></transshipment_nbr><ASNOutDistro><distro_nbr>'
|| i.tsf_no
||
'</distro_nbr><distro_doc_type>T</distro_doc_type><customer_order_nbr></
customer_order_nbr><consumer_direct></consumer_direct><ASNOutCtn><final_location>'
|| i.to_loc
|| '</final_location><container_id>'
|| i.tsf_no
||
'-1</container_id><container_weight>0</container_weight><container_length>0</
container_length><container_width>0</container_width><container_height>0</
container_height><container_cube>0</container_cube><expedite_flag></
expedite_flag><rma_nbr></rma_nbr><tracking_nbr></tracking_nbr><freight_charge>0</
freight_charge><master_container_id></master_container_id>';

FOR j IN c1
LOOP
p2 :=
'<ASNOutItem><item_id>'
|| j.id_itm
|| '</item_id><unit_qty>'
|| j.qu_itm
||
'</unit_qty><priority_level>0</priority_level><order_line_nbr>0</order_line_nbr><lo
t_nbr></lot_nbr><final_location>'
|| j.id_prty_fm_icd
||
'</final_location><from_disposition></from_disposition><to_disposition></
to_disposition><voucher_number></voucher_number><container_qty>1</container_qty></
ASNOutItem>';

SELECT CONCAT (p1, p2)


INTO p1
FROM DUAL;
END LOOP;
END LOOP;

p3 := '</ASNOutCtn></ASNOutDistro></ASNOutDesc>';

SELECT CONCAT (p1, p3)


INTO p1
FROM DUAL;

INSERT INTO rms.rib_message


(message_num, LOCATION, family,
TYPE,
rib_message_id,
publish_time,
in_queue, message_data, attempt_count, max_attempts,
next_attempt_time,
delete_pending, topic_name, thread_value, jms_queue_id,
custom_flag, reason_code
)
VALUES (num + 1, 'ewASNOutToRMS.colASNOutToRMS', 'ASNOut',
'ASNOutCre',
'12.0|RIBMessagePublisherEjb|ASNOut|2017.09.11 13:27:04.457|
101675',
TO_DATE ('09/11/2017 13:27:04', 'MM/DD/YYYY HH24:MI:SS'),
'0', p1, 4, 5,
TO_DATE ('09/11/2017 13:31:19', 'MM/DD/YYYY HH24:MI:SS'),
'0', 'etASNOutAT', 1, '172.19.98.47:25053',
'F', 'SUB'
);
END;

You might also like