drop view LD0VAA0SearchPDFDocuments
;
CREATE VIEW LD0VAA0SEARCHPDFDOCUMENTS
AS
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, H.PNR H_PNR, ' ' C_PNR, ' ' C20_PNR, ' ' B_PNR, ' ' N90_PNR, ' ' U90_PNR, ' ' A70_PNR, ' ' A700_PNR, ' ' U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, A.ADRESS, 
                         A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0H H ON T43.AGARNR = H.AKTUALNR AND T43.AGARTYP = 7040 JOIN
                         LD0V0A A ON A.PNR = H.PNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, C.AKTPNR C_PNR, ' ' C20_PNR, ' ' B_PNR, ' ' N90_PNR, ' ' U90_PNR, ' ' A70_PNR, ' ' A700_PNR, ' ' U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, 
                         A.ADRESS, A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0VLC C ON T43.AGARNR = C.AEVERKNR AND T43.AGARTYP = 7017 JOIN
                         LD0V0A A ON A.PNR = C.AKTPNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, C20.AKTPNR C20_PNR, ' ' B_PNR, ' ' N90_PNR, ' ' U90_PNR, ' ' A70_PNR, ' ' A700_PNR, ' ' U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, 
                         A.ADRESS, A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0VLC20 C20 ON T43.AGARNR = C20.INSNR AND T43.AGARTYP = 7083 JOIN
                         LD0V0A A ON A.PNR = C20.AKTPNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, ' ' C20_PNR, B.AKTPNR B_PNR, ' ' N90_PNR, ' ' U90_PNR, ' ' A70_PNR, ' ' A700_PNR, ' ' U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, 
                         A.ADRESS, A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0B B ON T43.AGARNR = B.AKTNR AND T43.AGARTYP = 7027 JOIN
                         LD0V0A A ON A.PNR = B.AKTPNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, ' ' C20_PNR, ' ' B_PNR, N90.PNR N90_PNR, ' ' U90_PNR, ' ' A70_PNR, ' ' A700_PNR, ' ' U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, A.ADRESS, 
                         A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0N90 N90 ON T43.AGARNR = N90.UPPDRAGNR AND T43.AGARTYP = 28059 JOIN
                         LD0V0A A ON A.PNR = N90.PNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, ' ' C20_PNR, ' ' B_PNR, ' ' N90_PNR, U90.PNR U90_PNR, ' ' A70_PNR, ' ' A700_PNR, ' ' U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, A.ADRESS, 
                         A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0U90 U90 ON T43.AGARNR = U90.LNUPPDRAGNR AND T43.AGARTYP = 28098 JOIN
                         LD0V0A A ON A.PNR = U90.PNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, ' ' C20_PNR, ' ' B_PNR, ' ' N90_PNR, ' ' U90_PNR, A70.PNR A70_PNR, ' ' A700_PNR, ' ' U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, A.ADRESS, 
                         A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0A70 A70 ON T43.AGARNR = A70.FLYKTNR AND T43.AGARTYP = 7136 JOIN
                         LD0V0A A ON A.PNR = A70.PNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, ' ' C20_PNR, ' ' B_PNR, ' ' N90_PNR, ' ' U90_PNR, ' ' A70_PNR, A700.PNR A700_PNR, ' ' U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, A.ADRESS, 
                         A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0A700 A700 ON T43.AGARNR = A700.FLYKTNR AND T43.AGARTYP = 28122 JOIN
                         LD0V0A A ON A.PNR = A700.PNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, ' ' C20_PNR, ' ' B_PNR, ' ' N90_PNR, ' ' U90_PNR, ' ' A70_PNR, ' ' A700_PNR, U10.PERSONNR U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, 
                         A.ADRESS, A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0U10 U10 ON T43.AGARNR = U10.INSKRIVNINGSNR AND T43.AGARTYP = 7405 JOIN
                         LD0V0A A ON A.PNR = U10.PERSONNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, ' ' C20_PNR, ' ' B_PNR, ' ' N90_PNR, ' ' U90_PNR, ' ' A70_PNR, ' ' A700_PNR, ' ' U10_PNR, U01.PERSONNR U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, 
                         A.ADRESS, A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0U01 U01 ON T43.AGARNR = U01.KARTLAGGNR AND T43.AGARTYP = 28145 JOIN
                         LD0V0A A ON A.PNR = U01.PERSONNR
UNION
SELECT        T43.INFOGANR, T43.AGARTYP, T43.AGARNR, T43.INFOGADATUM, T43.INFDOKTYP, T43.INFDOKTYPTXT, T43.INFANVTYP, T43.INFANVTYPTXT, T43.FILEID, T43.UPDDAT, T43.UPDSIGN, T43.DOKTYPTXT, 
                         T43.INFANVTYPTEXT, ' ' H_PNR, ' ' C_PNR, ' ' C20_PNR, ' ' B_PNR, ' ' N90_PNR, ' ' U90_PNR, ' ' A70_PNR, ' ' A700_PNR, U10.PERSONNR U10_PNR, ' ' U01_PNR, A.PNR, A.NAMN AS PERSONNAME, A.ORT, 
                         A.ADRESS, A.FODDAT, A.POSTNR, A.COADR AS PERSONCOADDRESS, A.KON, A.GRUPP, A.KUNDNUMMER
FROM            LD0VAA0T43 T43 LEFT JOIN
                         LD0V0U34 U34 ON T43.AGARNR = U34.PLANAKTIVITETNR AND T43.AGARTYP = 7441 JOIN
                         LD0P0U30 U30 ON U34.PLANNR = U30.PLANNR AND U34.VERSIONNR = U30.VERSIONNR JOIN 
                         LD0P0U10 U10 ON U30.INSKRIVNINGSNR = U10.INSKRIVNINGSNR JOIN
                         LD0V0A A ON A.PNR = U10.PERSONNR
						 ;

