KFNS#90080 Afmelden BES/Van DAILY naar PRE_PUTORDERS en toch weer AUTOCLOSE-export (tijdelijk)

svn path=/Customer/trunk/; revision=70169
This commit is contained in:
Maarten van der Heide
2025-09-01 16:48:04 +00:00
parent 1169ae9367
commit 0a311d8a55

View File

@@ -2976,6 +2976,94 @@ END;
CREATE OR REPLACE PROCEDURE kfns_select_autoclose (p_applname IN VARCHAR2,
p_applrun IN VARCHAR2)
*/
/* TIJDELIJK TOCH NOG EVEN NIET VERVALLEN, WANT KFNS NOG 2024.3! */
CREATE OR REPLACE PROCEDURE kfns_select_autoclose (p_applname IN VARCHAR2,
p_applrun IN VARCHAR2)
AS
-- Cursor loopt over alle bestelopdracht-items met status 'In bestelling';
-- deze worden verondersteld te zijn geleverd!
CURSOR cboi
IS
SELECT DISTINCT boi.bes_bestelopdr_key, bo.bes_bestelopdr_status
FROM bes_bestelopdr bo,
bes_bestelopdr_item boi,
bes_bestelling_item bi,
bes_srtdeel sd,
bes_srtgroep sg
WHERE bo.bes_bestelopdr_status IN (3, 4) -- In behandeling/bestelling
AND bo.bes_bestelopdr_key = boi.bes_bestelopdr_key
AND boi.bes_bestelopdr_item_key = bi.bes_bestelopdr_item_key
AND bi.bes_srtdeel_key = sd.bes_srtdeel_key
AND sd.bes_srtgroep_key = sg.bes_srtgroep_key
AND sg.ins_discipline_key IN (401, 402); -- Ontvangst/Uitgifte
-- Cursor loopt over alle bestelling-items met status 'Besteld' waarvan
-- de bijbehorende bestelopdracht-items zijn geleverd; deze worden dan ook
-- gesloten!
CURSOR cbi
IS
SELECT DISTINCT bi.bes_bestelling_key
FROM bes_bestelling b,
bes_bestelling_item bi,
bes_srtdeel sd,
bes_srtgroep sg,
bes_bestelopdr_item boi
WHERE b.bes_bestelling_status = 5 -- Besteld
AND b.bes_bestelling_key = bi.bes_bestelling_key
--AND bi.bes_bestelling_item_aantal != COALESCE (bi.bes_bestelling_item_aantalontv, 0)
AND bi.bes_srtdeel_key = sd.bes_srtdeel_key
AND sd.bes_srtgroep_key = sg.bes_srtgroep_key
AND sg.ins_discipline_key IN (401, 402) -- Ontvangst/Uitgifte
AND bi.bes_bestelopdr_item_key = boi.bes_bestelopdr_item_key
AND boi.bes_bestelopdr_item_aantal = boi.bes_bestelopdr_item_aantalontv;
v_errormsg VARCHAR2 (1000);
oracle_err_num NUMBER;
oracle_err_mes VARCHAR2 (200);
v_count NUMBER;
BEGIN
v_errormsg := 'Fout leveren bestelopdracht';
FOR rec IN cboi
LOOP
IF rec.bes_bestelopdr_status = 3 -- In behandeling
THEN
UPDATE bes_bestelopdr
SET bes_bestelopdr_status = 4 -- In bestelling
WHERE bes_bestelopdr_key = rec.bes_bestelopdr_key;
END IF;
-- Zeg dat alles geleverd is wat besteld is.
UPDATE bes_bestelopdr_item
SET bes_bestelopdr_item_aantalontv = bes_bestelopdr_item_aantal
WHERE bes_bestelopdr_key = rec.bes_bestelopdr_key;
bes.updatebestelopdrstatus (rec.bes_bestelopdr_key, NULL);
END LOOP;
v_errormsg := 'Fout sluiten bestelaanvraag';
FOR rec IN cbi
LOOP
-- Sluit alle aanvraagregels die nu compleet geleverd zijn.
UPDATE bes_bestelling_item
SET bes_bestelling_item_aantalontv = bes_bestelling_item_aantal
WHERE bes_bestelling_key = rec.bes_bestelling_key;
bes.updatebestellingstatus (rec.bes_bestelling_key, NULL);
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
oracle_err_num := SQLCODE;
oracle_err_mes := SUBSTR (SQLERRM, 1, 200);
v_errormsg := v_errormsg || ' ORACLE (error ' || oracle_err_num || '/' || oracle_err_mes || ')';
fac.writelog (p_applname, 'E', v_errormsg, 'Proces AUTOCLOSE afgebroken!');
END kfns_select_autoclose;
/
/* Formatted on 12-9-2014 17:42:24 (QP5 v5.136.908.31019) */
CREATE OR REPLACE VIEW kfns_v_imp_bes_artikel_sync
(