Hello,
I tried to import data from excel file. And I created Report for import.
The primary thing is to import data into "Item Import Line" table (created by developers from another company) and after that with another function to import data into Item and some other tables.
The problem is in the Import data from excel.
When I run report, first thing is Open Choose File Dialog, and after I choose I got following message:
" The Item Import Line Does not exist. Identification fields and values: Document No.="docNo";Jumbo Code='jmboCode'; Barcode='1254787788887'; Store Code='' "
Primary key of "Item Import Line" table is that 4 fields, and "Jumbo Code" field is key for own.
If Jumbo Code does not exist into table I can't import, but if exist I can.
The point is that I 'must' import records whatever "Jumbo Code" exists or not.
This is my import function.
ExcelBuf.SETCURRENTKEY("Row No.","Column No."); ExcelBuf.SETRANGE("Row No.",1); ExclBufferFirstRow.COPY(ExcelBuf); ExcelBuf.SETFILTER("Row No.",'>1'); RowNo := 0; IF ExcelBuf.FINDSET THEN BEGIN REPEAT IF RowNo <> ExcelBuf."Row No." THEN BEGIN IF ExclBufferFirstRow.FINDSET THEN BEGIN REPEAT IF ExcelBuf.GET(ExcelBuf."Row No.",ExclBufferFirstRow."Column No.") THEN BEGIN CASE ExclBufferFirstRow."Cell Value as Text" OF JumboCode: BEGIN ItemImportLine.INIT; ItemImportLine."Jumbo Code" := ItemImportLine."Jumbo Code"; ItemImportLine."Document No." := ItemImportHeader."No."; ItemImportLine."Jumbo Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.INSERT; END; Barcode: BEGIN //ItemImportLine.INIT; //ItemImportLine."Document No." := ItemImportHeader."No."; ItemImportLine.Barcode := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemDescription: BEGIN ItemImportLine."Item Description" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; SuppliersCode: BEGIN ItemImportLine."Suppliers Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; RetailPrice: IF EVALUATE(ItemImportLine."Retail Price",ExcelBuf."Cell Value as Text") THEN ItemImportLine.MODIFY; BaseUnitofMeasure: BEGIN ItemImportLine."Base Unit of Measure" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; Type: BEGIN ItemImportLine.Type := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; TypeDescription: BEGIN ItemImportLine."Type Description" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemCategoryCode: BEGIN ItemImportLine."Item Category Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemCategoryDescription: BEGIN ItemImportLine."Item Category Description" := ExcelBuf."Cell Value as Text"; // ItemImportLine.MODIFY; END; ItemMainGroupCode: BEGIN ItemImportLine."Item Main Group Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemMainGroupDescription: BEGIN ItemImportLine."Item Main Group Description" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemSubGroupCode: BEGIN ItemImportLine."Item Sub Group Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemSubGroupDescription: BEGIN ItemImportLine."Item Sub Group Description" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; WayofStorageCode: BEGIN ItemImportLine."Way of Storage Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; Quantity: IF EVALUATE(ItemImportLine.Quantity,ExcelBuf."Cell Value as Text") THEN ItemImportLine.MODIFY; InPackage: BEGIN ItemImportLine."In Package" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; OutPackage: BEGIN ItemImportLine."Out Package" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; PackageofShipment: BEGIN ItemImportLine."Package of Shipment" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemSeasonCode: BEGIN ItemImportLine."Item Season Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemSeasonDescription: BEGIN ItemImportLine."Item Season Description" := ExcelBuf."Cell Value as Text"; // ItemImportLine.MODIFY; END; PriorityofCategory: BEGIN ItemImportLine."Priority of Category" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; PriorityofMainGroup: BEGIN ItemImportLine."Priority of Main Group" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; PriorityofSubGroup: BEGIN ItemImportLine."Priority of Sub Group" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; PeakofPeriodCode: BEGIN ItemImportLine."Peak of Period Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; PeakofPeriodDescription: BEGIN ItemImportLine."Peak of Period Description" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; Flag: IF EVALUATE(ItemImportLine.Flag,ExcelBuf."Cell Value as Text") THEN ItemImportLine.MODIFY; Weight: IF EVALUATE(ItemImportLine.Weight,ExcelBuf."Cell Value as Text") THEN ItemImportLine.MODIFY; Volume: BEGIN ItemImportLine.Volume := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; CountryofOrigin: BEGIN ItemImportLine."Country of Origin" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; BuyerCode: BEGIN ItemImportLine."Buyer Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; BuyerName: BEGIN ItemImportLine."Buyer Name" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; VendorCode: BEGIN ItemImportLine."Vendor Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; VendorName: BEGIN ItemImportLine."Vendor Name" := ExcelBuf."Cell Value as Text"; ItemImportLine.MODIFY; END; ItemAL: BEGIN IF ExcelBuf."Cell Value as Text" = 'Yes' THEN ItemImportLine."Item AL" := TRUE ELSE ItemImportLine."Item AL" := FALSE; ItemImportLine.MODIFY; END; StoreCode: BEGIN ItemImportLine."Store Code" := ExcelBuf."Cell Value as Text"; ItemImportLine.INSERT; END; //LocationCode: //BEGIN //ItemImportLine."Location Code" := ExcelBuf."Cell Value as Text"; //ItemImportLine.MODIFY; //END; //MaterialCode: //BEGIN //ItemImportLine."Material Code" := ExcelBuf."Cell Value as Text"; //ItemImportLine.MODIFY; //END; //VATBusinessPostingGroup: //BEGIN //ItemImportLine."VAT Business Posting Group" := ExcelBuf."Cell Value as Text"; //ItemImportLine.MODIFY; //END; END; END; UNTIL ExclBufferFirstRow.NEXT = 0; END; RowNo := ExcelBuf."Row No."; END; UNTIL ExcelBuf.NEXT = 0; END;