/* RECORRER TABLA*/
/*for each Endeds:
    display Endeds.
end.*/

/*BUSCAR PRIMER REGISTRO*/
/*find first Endeds
     no-lock no-error.*/

/*BUSCAR ULTIMO REGISTRO*/
/*find last Endeds
     no-lock no-error.*/

/*RECORRER TABLA CON CONDICION*/   
/*for each Endeds
    where Endeds.Ended = «1»:
   
    display Endeds.Ended
            Endeds.Description.
end.           
*/

/*CREAR REGISTRO*/
/*create Endeds.
assign Endeds.Ended = «50»
       Endeds.Description = «prueba 50».     */

/*BUSCAR UN REGISTRO CONCRETO*/     
/*find Endeds
     where Endeds.ended = «50»
     no-lock no-error.
   
     display Endeds .
*/     

/*ELIMINAR REGISTRO*/   
/*   
find Endeds
     where Endeds.ended = «50»
     no-error.
   
     delete Endeds .
*/

/*ANIDAR TABLAS*/
/*for each TipFamiliy
    where TipFamiliy.tipFamiliy   = 1
    no-lock,
    each Families
    where Families.enterprise = 1 and
          Families.tipFamiliy  =   TipFamiliy.TipFamiliy
    no-lock:
   
    display TipFamiliy.Description
            Families.Description
            Families.Familiy.
   
end.   
*/         

/*CLAUSULAS BREAK BY*/
/*def var xcont as int.

for each TipFamiliy
    no-lock,
    each Families
    where Families.enterprise = 1 and
          Families.tipFamiliy  =   TipFamiliy.TipFamiliy
    no-lock
    break by Families.tipFamiliy:

    if first-of (Families.tipFamiliy) then
    do:
        XCONT = 0.
    end.
   
    XCONT = XCONT + 1.
   
    if LAST-OF (Families.tipFamiliy) then
    do:
        DISPLAY XCONT
                Families.tipFamiliy.
    end.
end.
*/

/*tablas temporales + exportaci¢n a fichero*/
def var xcont as int.

DEFINE TEMP-TABLE TMPJORDI
    FIELD TIPFAMILIA AS INT
    FIELD CONTADOR   AS INT
    INDEX IDX01
          TIPFAMILIA.

FOR EACH TMPJORDI:
    DELETE TMPJORDI.
END.

for each TipFamiliy
    no-lock,
    each Families
    where Families.enterprise = 1 and
          Families.tipFamiliy  =   TipFamiliy.TipFamiliy
    no-lock
    break by Families.tipFamiliy:

    if first-of (Families.tipFamiliy) then
    do:
        XCONT = 0.
    end.

    XCONT = XCONT + 1.

    if LAST-OF (Families.tipFamiliy) then
    do:
        CREATE TMPJORDI.
        ASSIGN TMPJORDI.TIPFAMILIA = FAMILIES.TIPFAMILIY
               TMPJORDI.CONTADOR = XCONT.
    end.
end.

output to «c:tmpdatosjordi.txt».
FOR EACH TMPJORDI
    NO-LOCK:
    export TMPJORDI.
END.
output close.

&SCOPED-DEFINE TableToExport CatTipoTramiteIsai
output to «c:tmp {&TableToExport}.txt».
FOR EACH {&TableToExport} NO-LOCK:
    EXPORT DELIMITER «|»   {&TableToExport}.
END.
output close.

output to «c:tmpCatalogoServicios.txt».
FOR EACH CatalogoServicios
    NO-LOCK:
    EXPORT DELIMITER «|»  CatalogoServicios.
END.
output close.