
  CREATE OR REPLACE FORCE EDITIONABLE VIEW "AB03B"."AB03B46V00" ("IDFASE", "IDTRAMITE", "IDPROV", "IDANO", "IDNUMEXP", "IDHIST", "IDCOMUNICACION", "TIPOORG", "IDORGANISMO", "DESCES", "DESCEU", "EMAILES", "EMAILEU", "ESTADO", "TIPOTRAMITE", "FECHACOMUNICACIONC", "FECHACOMUNICACIONE") AS 
  SELECT T14.ID_001_FASE,    t14.ID_002_TRAMITE,    t14.ID_PROV_010,    t14.ID_ANO_010,    t14.ID_010_NUM_EXP,    T14.ID_014,    t46.ID_046,
    'E',    t10.ID_047_EMPRESA,  'Empresa' , 'Enpresa', 'Mis Gestiones', 'Nire Kudeaketak',  NVL(ESTADO_046,'0') ESTADO_046,    t02.ENT_SAL_002,
    TO_CHAR(t46.FEC_COMUNIC_046, 'dd/mm/yyyy'),    TO_CHAR(t46.FEC_COMUNIC_046, 'yyyy/mm/dd')
  FROM ab03b14t00 t14
  INNER JOIN ab03b10t00 t10  ON t10.ID_PROV_010 = t14.ID_PROV_010  AND t10.ID_ANO_010 = t14.ID_ANO_010  AND t10.ID_010     = t14.ID_010_NUM_EXP
  INNER JOIN ab03b46t00 t46  ON t46.ID_014_HISTO_TRAM = t14.ID_014  AND t46.ID_047_EMPRESA   = t10.ID_047_EMPRESA
  INNER JOIN ab03b02t00 t02  ON t02.ID_001_FASE = t14.ID_001_FASE  AND t02.ID_002     = t14.ID_002_TRAMITE
  UNION
  SELECT T14.ID_001_FASE,    t14.ID_002_TRAMITE,    t14.ID_PROV_010,    t14.ID_ANO_010,    t14.ID_010_NUM_EXP,    T14.ID_014,
    T46.ID_046,    'O',    t45.ID_045,    t45.DESC_ES_045,    t45.DESC_EU_045 ,    T39.EMAIL_039,  T39.EMAIL_039, NVL(ESTADO_046,'0') ESTADO_046,
    t02.ENT_SAL_002,    TO_CHAR(t46.FEC_COMUNIC_046, 'dd/mm/yyyy'),    TO_CHAR(t46.FEC_COMUNIC_046, 'yyyy/mm/dd')
  FROM ab03b14t00 t14
  INNER JOIN ab03b46t00 t46  ON t46.ID_014_HISTO_TRAM = t14.ID_014
  INNER JOIN ab03b39t00 t39  ON t39.ID_PERFIL_039 = t14.ID_PROV_010 and t46.ID_039_ORGAN = t39.ID_045_ORG
  INNER JOIN ab03b45t00 t45  ON t45.ID_045 = t39.ID_045_ORG
  INNER JOIN ab03b02t00 t02  ON t02.ID_001_FASE = t14.ID_001_FASE  AND t02.ID_002 = t14.ID_002_TRAMITE;
  
  
  CREATE OR REPLACE FORCE EDITIONABLE VIEW "AB03B"."AB03B50V00" ("IDFASE", "IDTRAMITE", "IDPROV", "IDANO", "IDNUMEXP", "IDHIST", "IDCOMUNICACION", "TIPOORG", "IDORGANISMO", "DESCES", "DESCEU", "EMAILES", "EMAILEU", "ESTADO", "TIPOTRAMITE", "FECHACOMUNICACIONC", "FECHACOMUNICACIONE") AS 
  SELECT T28.ID_017_FASE,
    T28.ID_018_TRAMITE,
    T28.ID_PROV_024,
    T28.ID_ANO_024,
    T28.ID_024_NUM_EXP,
    T28.ID_028,
    t50.ID_050,
    'E',
    t24.ID_047_EMPRESA,
    'Empresa' ,
    'Enpresa', 
    'Mis Gestiones', 
    'Nire Kudeaketak',
    NVL(ESTADO_050,'0') ESTADO_050,
    t18.ENT_SAL_018,
    TO_CHAR(t50.FEC_COMUNIC_050, 'dd/mm/yyyy'),
    TO_CHAR(t50.FEC_COMUNIC_050, 'yyyy/mm/dd')
  FROM ab03b28t00 T28
  INNER JOIN ab03b24t00 t24
  ON t24.ID_PROV_024 = T28.ID_PROV_024
  AND t24.ID_ANO_024 = T28.ID_ANO_024
  AND t24.ID_024     = T28.ID_024_NUM_EXP
  INNER JOIN ab03b50t00 t50
  ON t50.ID_028_HISTO_TRAM = T28.ID_028
  AND t50.ID_047_EMPRESA   = t24.ID_047_EMPRESA
  INNER JOIN ab03b18t00 t18
  ON t18.ID_017_FASE = T28.ID_017_FASE
  AND t18.ID_018     = T28.ID_018_TRAMITE
  UNION
  SELECT T28.ID_017_FASE,
    T28.ID_018_TRAMITE,
    T28.ID_PROV_024,
    T28.ID_ANO_024,
    T28.ID_024_NUM_EXP,
    T28.ID_028,
    T50.ID_050,
    'O',
    t49.ID_049,
    t48.DESC_ES_048,
    t48.DESC_EU_048 ,
    t49.EMAIL_049,
    t49.EMAIL_049,
    NVL(ESTADO_050,'0') ESTADO_050,
    t18.ENT_SAL_018,
    TO_CHAR(t50.FEC_COMUNIC_050, 'dd/mm/yyyy'),
    TO_CHAR(t50.FEC_COMUNIC_050, 'yyyy/mm/dd')
  FROM ab03b28t00 T28
  INNER JOIN ab03b50t00 t50
  ON t50.ID_028_HISTO_TRAM = T28.ID_028
  INNER JOIN ab03b49t00 t49 ON t49.ID_PERFIL_049 = T28.ID_PROV_024 and t49.ID_048_ORG = t50.ID_049_ORGAN
  INNER JOIN ab03b48t00 t48
  ON t48.ID_048 = t49.ID_048_ORG
  INNER JOIN ab03b18t00 t18
  ON t18.ID_017_FASE = T28.ID_017_FASE
  AND t18.ID_018     = T28.ID_018_TRAMITE;

  