
-- Offene Maßnahmenliste aus dem Reklamationsmanagement
-- 05.10.2020
ALTER PROC sp_rek_massnahmen_offen AS
BEGIN
SET NOCOUNT ON;
SELECT
Massnahme = REKM_BEZ,
Termin = REKM_ERL_TERMIN,
RekNr = RIGHT('0000000000' + CAST(REK_NR AS varchar(10)),10),
FehlerNr = (SELECT TOP 1 FE_NR FROM FE_STM WHERE FE_ID = (SELECT TOP 1 REKF_FE_ID FROM REK_FEHL WHERE REKMR_REKF_ID = REKF_ID)),
Verantwortlich = REKM_ERL_MA_NAME
FROM 
REK_STM
INNER JOIN REK_MASS_REL ON REKMR_REK_ID = REK_ID
INNER JOIN REK_MASS ON REKM_ID = REKMR_REKM_ID
WHERE (ISNULL(REKM_ERL_FERTIG,'') <> 'Y' AND REKM_ERL_DATUM IS NULL)
ORDER BY Termin
END
