Creating route and routeline

static void testroute(Args _args)
{
    SysExcelApplication             application;
    SysExcelWorkbooks               workbooks;
    SysExcelWorkbook                workbook;
    SysExcelWorksheets              worksheets;
    SysExcelWorksheet               worksheet;
    SysExcelCells                   cells;
    COMVariantType                  type;
    System.DateTime                 ShlefDate;
    FilenameOpen                    filename;
    dialogField                     dialogFilename;
    Dialog                          dialog;
    int                             row;
    str 50 id;
    RouteTable                      routetab;
    Testroute                       tmproute,tmprouteloc,tmp;
    Route                           route;
    NumberSeq                       NumberSeq;
    //field declaration starts
    RouteOprId              _oprid;
    RouteId                 rid;
    Name                    name;
    ItemGroupId             itemgroupid;
    OprNum                  _oprnum;
    //field declaration ends

    ;
    dialog          =   new Dialog("Upload excel file");
    dialogFilename  =   dialog.addField(typeId(FilenameOpen));
    dialog.filenameLookupTitle("Upload from Excel");
    dialog.caption("Excel");
    dialogFilename.value(filename);
    if(!dialog.run())
        return;
    filename    =   dialogFilename.value();
    info(filename);
    application =   SysExcelApplication::construct();
    workbooks   =   application.workbooks();
    try{
     workbooks.open(filename);
    }
    catch(Exception::Error){
     throw error("Cannot open the file. Check if file exists in location ");
    }
    workbook = workbooks.item(1);
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    row = 1;
    ttsbegin;
    do
    {
   ttsbegin;
    row++;
     breakpoint;
    name=cells.item(row,1).value().bStr();
    itemgroupid=cells.item(row,2).value().bStr();
    _oprnum=cells.item(row,3).value().double();
   // _oprid=cells.item(row,4).value().bStr();
    //creating header
     NumberSeq = NumberSeq::newGetNumFromCode(RouteParameters::numRefRouteId().numberSequence);
     routetab.RouteId=NumberSeq.num();
     routetab.Name=name;
     routetab.ItemGroupId=itemgroupid;
     routetab.insert();
     info(routetab.RouteId);
     id=routetab.RouteId;

     //creating lines
    select firstonly route where route.RouteId==id && route.OprNum==_oprnum;
    if(!route.RecId)
    {

    route.OprNum=_oprnum;
    route.OprId=cells.item(row,4).value().bStr();
    route.RouteId=id;
    route.insert();
    }
    type= cells.item(row+1,1).value().variantType();
    ttscommit;
    }
     while(type != COMVariantType::VT_EMPTY);
    application.quit();
             ttscommit;

   }





I’m trying to create route header and line through excel file.

This is my excel file fields

pastedimage1512479125096v1.png

I can’t create lines for the route, May I know where I’m doing mistake?

thanks.,

Have you tried to debug? Do you get the value in _oprnum?
It could be an issue here,
select firstonly route where route.RouteId==id && route.OprNum==_oprnum;
if(!route.RecId)
{

route.OprNum=_oprnum;
route.OprId=cells.item(row,4).value().bStr();