DROP VIEW LD0VAAYEXECUTIONS
;
CREATE VIEW LD0VAAYEXECUTIONS
AS
SELECT C.AEVERKNR,
C.ORGID,
C.TMARK,
C.KEDJENR,
C.AKTNR,
C.AKTPNR,
C.HAND,
C.MEDHAND,
C.ORGENHNR,
C.STARTDAT,
C.STOPDAT,
C.AEVERKTYP,
C.FMMSALDO,
C.UPDDAT,
C.UPDSIGN,
C.SAMARBRES,
C.ORGENHNR2,
C.FAMRTYP1,
C.FAMRTYP2,
C.FAMRTYP3,
C.AVSLORSAK,
C.FAMRATTNR,
C.STATUS,
C.FAMAVSLORS,
C.AVTALVAR,
C.AVTVFAST,
C.AVTVANSV,
C.AVTVDOM,
C.AVTALUMG,
C.AVTUFAST,
C.AVTUDOM,
C.AVTALBOE,
C.AVTBFAST,
C.AVTBOENDE,
C.AVTBDOM,
C.AVTALUH,
C.AVTUHFAST,
C.AVTEJFAST,
C.AVTUHBEL,
C.AVTUHENG,
C.FAMHANRACK,
C.FAMUTLAND,
C.FAMBOENDE,
C.FAMDNA,
C.FAMCIVST,
C.FAMFLERTAL,
C.FAMBETALARE,
C.FAMTEMPAVTAL,
C.FAMUTBAVTAL,
C.INGENMEDSOK, 
B.TYPNR_T AKTTYP_T, 
Q.KLARTEXT AEVERKTYP_T, 
Q.XNUM40 WORKFLOW_T,
O.NAMN ORG_T, 
H.NAMN NAMN,
A.NAMN AKTPNR_NAMN
FROM LD0VYC C 
INNER JOIN LD0VAAYB B 
ON C.AKTNR = B.AKTNR
INNER JOIN LD0V0Q01 Q 
ON Q.KODTYP = 'JOURNALTYP' 
AND Q.KOD = C.AEVERKTYP
INNER JOIN LD0V0J01 O 
ON C.ORGID = O.ORGID 
AND C.ORGENHNR = O.ORGENHNR
INNER JOIN LD0V0I H 
ON C.HAND = H.HAND
LEFT OUTER JOIN LD0V0A A 
ON C.AKTPNR = A.PNR
;