1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
| DECLARE
v_insert number := 0;
v_errbuf varchar2(1000):= '';
v_retcode varchar2(10) := 0;
v_tot_recs number := 0;
e_traitement EXCEPTION;
v_count number := 0;
l_inventory_item_id MTL_SYSTEM_ITEMS_B.INVENTORY_ITEM_ID%TYPE;
l_account MTL_GENERIC_DISPOSITIONS.DISTRIBUTION_ACCOUNT%TYPE;
l_uom MTL_TRANSACTIONS_INTERFACE.TRANSACTION_UOM%TYPE;
l_f_locator_id MTL_ITEM_LOCATIONS.INVENTORY_LOCATION_ID%TYPE;
l_f_subinventory_code MTL_ITEM_LOCATIONS.SUBINVENTORY_CODE%TYPE;
l_to_locator_id MTL_ITEM_LOCATIONS.INVENTORY_LOCATION_ID%TYPE;
l_to_subinventory_code MTL_ITEM_LOCATIONS.SUBINVENTORY_CODE%TYPE;
l_transaction_interface_id MTL_TRANSACTIONS_INTERFACE.TRANSACTION_INTERFACE_ID%TYPE;
l_request_id fnd_concurrent_requests.request_id%TYPE;
l_step VARCHAR2(1000);
l_prog_application_id fnd_concurrent_programs.application_id%TYPE;
l_prog_application_short_name fnd_application.application_short_name%TYPE;
l_program_id fnd_concurrent_programs.concurrent_program_id%TYPE;
BEGIN
go_block('B_TRANSF_MAG');
go_item('B_TRANSF_MAG.NUM_LOT');
last_record;
v_tot_recs := to_number(name_in('SYSTEM.CURSOR_RECORD'));
go_record(1);
for i in 1..v_tot_recs loop
if i <= v_tot_recs then
go_record(i);
go_item('B_TRANSF_MAG.NUM_LOT');
end if;
go_block('B_TRANSF_MAG');
SELECT msi.inventory_item_id
,primary_uom_code
INTO l_inventory_item_id
,l_uom
FROM mtl_system_items_B msi
WHERE msi.segment1 = :B_TRANSF_MAG.REFERENCE
AND organization_id = :PARAMETER.ORG_ID;
SELECT distribution_account
INTO l_account
FROM mtl_generic_dispositions
WHERE organization_id = :PARAMETER.ORG_ID
AND segment1 = 'AJUSTE_PF';
select inventory_location_id,
subinventory_code
into l_f_locator_id,
l_f_subinventory_code
from mtl_item_locations
where organization_id = :PARAMETER.ORG_ID
and segment1 = :B_TRANSF_MAG.EMPLACEMENT
and subinventory_code = substr(:B_TRANSF_MAG.EMPLACEMENT, 1, 3);
select inventory_location_id,
subinventory_code
into l_to_locator_id,
l_to_subinventory_code
from mtl_item_locations
where organization_id = :PARAMETER.ORG_ID
and segment1 = :B_TRANSF_MAG.VERS_EMPLACEMENT
and subinventory_code = substr(:B_TRANSF_MAG.VERS_EMPLACEMENT, 1, 3);
l_step := 'Insertion des donnees dans MTL_TRANSACTIONS_INTERFACE';
XXX_TRANSF_MAG.XXX_INSERT_MTI(v_errbuf,
v_retcode,
'TRANSF_MAG',
-1,
-1,
l_inventory_item_id,
:PARAMETER.ORG_ID,
l_f_subinventory_code,
l_f_locator_id,
:B_TRANSF_MAG.QTE,
l_uom,
sysdate,
2, --transaction_type_id
null,
l_account,
l_to_locator_id
l_to_subinventory_code
);
select max(transaction_interface_id)
into l_transaction_interface_id
from mtl_transactions_interface;
l_step := 'Insertion des donnees dans MTL_TRANSACTION_LOTS_INTERFACE';
-- Insertion dans MTL_TRANSACTION_LOTS_INTERFACE
XXX_TRANSF_MAG.XXX_INSERT_MTLI(p_errbuf,
p_retcode,
:B_TRANSF_MAG.NUM_LOT,
:B_TRANSF_MAG.QTE,
l_transaction_interface_id);
end loop;
message('Nombre de lignes: '||v_tot_recs);
message(' ');
commit;
select count(*)
into v_insert
from mtl_transactions_interface
where transaction_type_id = 2
and trunc(last_update_date) = trunc(sysdate)
and error_code is null;
if v_insert > 0 then
l_step := 'Rcupration des identifiants programme';
SELECT fcp.application_id,
fa.application_short_name,
fcp.concurrent_program_id
INTO l_prog_application_id,
l_prog_application_short_name,
l_program_id
FROM fnd_concurrent_programs fcp,
fnd_application fa
WHERE fcp.concurrent_program_name = 'INCTCM' --Lancer l'importation des mouvements
AND fa.application_id = fcp.application_id;
FND_FILE.PUT_LINE (fnd_file.log,'Lancement du traitement d''import standard');
l_step := 'Lancement du traitement d''import standard';
-- Lancement du traitement d'import standard
l_request_id := fnd_request.submit_request(l_prog_application_short_name, --APPLICATION PROPRIETAIRE DU TRAITEMENT
'INCTCM', --SHORT_NAME du TRAITEMENT
NULL, --PROGRAM_NAME
NULL, --START
FALSE, --SUB_REQUEST
'','','','','','','',
'','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','');
END IF; --v_insert > 0
commit;
go_record(1);
--message('Nombre de lignes cochees: '||v);
--message(' ');
EXCEPTION
WHEN e_traitement THEN
v_retcode := 2;
rollback;
v_errbuf := 'Erreur MAIN (Import standard) - '||SQLERRM||' - '||v_errbuf;
message('Erreur a '||l_step);
message(v_errbuf);
message(' ');
WHEN OTHERS THEN
rollback;
v_retcode := 2;
v_errbuf := 'Erreur MAIN - '||SQLERRM;
message('Erreur a '||l_step);
message(v_errbuf);
message(' ');
END; |
Partager