- El excel debe tener las columnas codigo del proveedor y direccion, con la informacion correspondiente.
static void ActualizaDireccion(Args _args)
{
    container                 conSheets;
    ExcelImportADO      xlImport;
    SysDataExcelCOM   dataExcelCom;
    Filename                  strFlename;
accountnum id;
str direccion;
vendtable vend;
dirpartytable dir;
address addre;
int i = 0;
accountnum id;
str direccion;
vendtable vend;
dirpartytable dir;
address addre;
int i = 0;
    ;
    strFilename = "C:\\Users\\PC\\Desktop\\direccion.xls";
    xlImport    = new ExcelImportADO(strFilename);
    try
    {
        // abriendo solo la primera hoja de excel       if(!xlImport.openFile())
            throw error(strfmt("Error opening Excel file «%1»", strFilename));
                while(!xlImport.eof())//previo
                {
                    id              =       xlImport.getFieldValue(1);
                    direccion       =       xlImport.getFieldValue(2);
                    while select vend
                        where vend.AccountNum == id
                    {
                        while select dir
                            where dir.PartyId == vend.PartyId
                        {
                             if(!address::find(2303,dir.RecId,addresstype::None).AddrRecId)
                            {
                                addre.AddrTableId = 2303; //vendtable
                                addre.AddrRecId   = dir.RecId;
                                addre.Street      = direccion;
                                addre.Address     = direccion;
                                addre.insert();
                                i++;
                                   }}
}
xlImport.moveNext();
}
xlImport.finalize();
info("direcciones: " + num2str(i,3,2,1,1));
}
catch(Exception::Error)
{
info("error");
xlImport.finalize();
}
}
- Ejecutar el JOB.
Saludos.
No hay comentarios:
Publicar un comentario