xmlport export csv file with header

xiaoerlixiaoerli Member Posts: 6
edited 2015-08-13 in NAV Three Tier
Hi,

In the old days, we can export table data to the csv file through dataport. By adding an extra data item on top and small changes, it will export the header line as well. Now in NAV 2009 RTC, we have to use xmlport. I tried to adding the text elements under the root element to export the header line, it gives me the following error:
Microsoft Dynamics NAV Classic
If root element has source type Text, then all other elements must be source type Table.

OK

Any idea to add the header line through xmlport?

Thanks,
xiaoer

Comments

  • jelittlejohnjelittlejohn Member Posts: 61
    Just did this today.

    Added a table node under the Root and above my actual data table node that I knew had a single record. I used General Ledger Setup.

    Then I added a number of text elements under it equal to the number of actual data columns that I am exporting.

    Finally, I set the values of each of these text elements to whatever I wanted my header value to be in the OnBeforePassVariable trigger.

    I'm sure you are long.long past this issue, but I could not find the answer to this question when I searched earlier today.
    Jack Littlejohn
    Clemson, SC
  • yukonyukon Member Posts: 361
    Hi xiaoerli,

    My understanding is you want to export data including header using with xmlport. If yes please try with below code.
    OBJECT XMLport 50001 Item Import/Export
    {
      OBJECT-PROPERTIES
      {
        Date=02/05/13;
        Time=[ 9:52:20 AM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        CaptionML=ENU=Item Imp/Exp;
        Encoding=UTF-8;
        OnInitXMLport=BEGIN
                        g_intCount      := 0;
                        fnSetDimCode;
                      END;
    
        OnPostXMLport=BEGIN
                        IF currXMLport.IMPORTFILE THEN
                          MESSAGE(Text000, g_intCount, Text001)
                        ELSE
                          MESSAGE(Text000, g_intCount, Text002);
                      END;
    
        Format=Variable Text;
        TableSeparator=<NewLine><NewLine>;
        FileName=Item.csv;
      }
      ELEMENTS
      {
        { [{EA90E28C-D99B-49B5-813E-0FCA94A9CF2D}];  ;ItemList            ;Element ;Text     }
    
        { [{E96B2D5B-F579-4D3E-B583-15B01652CDE8}];1 ;Header              ;Element ;Table   ;
                                                      SourceTable=Table2000000026;
                                                      SourceTableView=SORTING(Field1)
                                                                      WHERE(Field1=CONST(1));
                                                      Import::OnAfterInitRecord=BEGIN
                                                                                  currXMLport.BREAK;
                                                                                END;
                                                                                 }
    
        { [{00BA0B79-F0C5-43BB-AFF4-CCA38F385E2F}];2 ;No_Capt             ;Element ;Text    ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     No_Capt := Item.FIELDCAPTION("No.");
                                                                                   END;
                                                                                    }
    
        { [{8E7743AF-4259-4570-B42E-34413E550889}];2 ;Description_Capt    ;Element ;Text    ;
                                                      DataType=Text;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Description_Capt := Item.FIELDCAPTION(Description);
                                                                                   END;
                                                                                    }
    
        { [{ED55FB94-2DBC-48F7-82AC-3CE49E7ACA71}];2 ;Description2_Capt   ;Element ;Text    ;
                                                      DataType=Text;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Description2_Capt := Item.FIELDCAPTION("Description 2");
                                                                                   END;
                                                                                    }
    
        { [{01EFD167-7DBE-41CF-A8F8-ACE5BC59C9B2}];2 ;SearchDescription_Capt;Element;Text   ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     SearchDescription_Capt := Item.FIELDCAPTION("Search Description");
                                                                                   END;
                                                                                    }
    
        { [{51273FE5-F46D-4EC2-97C3-90DC0B774BE7}];2 ;ItemCategoryCode_Capt;Element;Text    ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ItemCategoryCode_Capt := Item.FIELDCAPTION("Item Category Code");
                                                                                   END;
                                                                                    }
    
        { [{7AEAD77B-3104-4196-8C3D-4CB2973C85ED}];2 ;ProductGroupCode_Capt;Element;Text    ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ProductGroupCode_Capt := Item.FIELDCAPTION("Product Group Code");
                                                                                   END;
                                                                                    }
    
        { [{ADF1576F-9018-4205-90CA-322BA43E40CA}];2 ;BaseUnitOfMeasure_Capt;Element;Text   ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     BaseUnitOfMeasure_Capt := Item.FIELDCAPTION("Base Unit of Measure");
                                                                                   END;
                                                                                    }
    
        { [{27097AC9-B649-4B7E-8B5C-4A97D5962209}];2 ;PurchUnitOfMeasure_Capt;Element;Text  ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     PurchUnitOfMeasure_Capt := Item.FIELDCAPTION("Purch. Unit of Measure");
                                                                                   END;
                                                                                    }
    
        { [{DE9D394C-6CAF-4965-8C37-31BA0BBE3699}];2 ;SalesUnitOfMeasure_Capt;Element;Text  ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     SalesUnitOfMeasure_Capt := Item.FIELDCAPTION("Sales Unit of Measure");
                                                                                   END;
                                                                                    }
    
        { [{21D612CC-76F4-43E2-866A-1B98E09FF493}];2 ;GenProdPostingGroup_Capt;Element;Text ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     GenProdPostingGroup_Capt := Item.FIELDCAPTION("Gen. Prod. Posting Group");
                                                                                   END;
                                                                                    }
    
        { [{8AB2C15E-D418-417E-AAEC-3CF9EDBD1CF3}];2 ;VATProdPostingGroup_Capt;Element;Text ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     VATProdPostingGroup_Capt := Item.FIELDCAPTION("VAT Prod. Posting Group");
                                                                                   END;
                                                                                    }
    
        { [{A947E6CA-3585-407D-B6AD-CA61C9402D5F}];2 ;InventoryPostingGroup_Capt;Element;Text;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     InventoryPostingGroup_Capt := Item.FIELDCAPTION("Inventory Posting Group");
                                                                                   END;
                                                                                    }
    
        { [{5BF958DE-620D-49A7-A168-25B55724880A}];2 ;ShelfNo_Capt        ;Element ;Text    ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ShelfNo_Capt := Item.FIELDCAPTION("Shelf No.");
                                                                                   END;
                                                                                    }
    
        { [{4B9B3534-621C-4194-99B9-E483D975ED7F}];2 ;ItemDiscGroup_Capt  ;Element ;Text    ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ItemDiscGroup_Capt := Item.FIELDCAPTION("Item Disc. Group");
                                                                                   END;
                                                                                    }
    
        { [{C5F904F5-445D-42E2-A711-071E425422B5}];2 ;UnitPrice_Capt      ;Element ;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     UnitPrice_Capt := Item.FIELDCAPTION("Unit Price");
                                                                                   END;
                                                                                    }
    
        { [{C6DD33BD-97CC-4735-B748-475D830A441C}];2 ;PriceProfitCalculation_Capt;Element;Text;
                                                      DataType=Option;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     PriceProfitCalculation_Capt := Item.FIELDCAPTION("Price/Profit Calculation");
                                                                                   END;
                                                                                    }
    
        { [{165CA3BB-580A-450D-9697-998147441E4E}];2 ;Profit_Capt         ;Element ;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Profit_Capt := Item.FIELDCAPTION("Profit %");
                                                                                   END;
                                                                                    }
    
        { [{EF3C6096-E037-4470-A5BE-5135C59E144C}];2 ;CostingMethod_Capt  ;Element ;Text    ;
                                                      DataType=Option;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     CostingMethod_Capt := Item.FIELDCAPTION("Costing Method");
                                                                                   END;
                                                                                    }
    
        { [{3D654541-3703-4BFB-A76F-BA0B7230D3BC}];2 ;LastDirectCost_Capt ;Element ;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     LastDirectCost_Capt := Item.FIELDCAPTION("Last Direct Cost");
                                                                                   END;
                                                                                    }
    
        { [{2C6BC1E1-CFBA-4E6E-BD01-AD285A3525D4}];2 ;UnitCost_Capt       ;Element ;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     UnitCost_Capt := Item.FIELDCAPTION("Unit Cost");
                                                                                   END;
                                                                                    }
    
        { [{5F8FDD5B-5357-431F-A89F-838BD490A1EC}];2 ;StandardCost_Capt   ;Element ;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     StandardCost_Capt := Item.FIELDCAPTION("Standard Cost");
                                                                                   END;
                                                                                    }
    
        { [{CB334D8C-AE2D-401F-9CD8-893A2F69F717}];2 ;LeadTimeCalculation_Capt;Element;Text ;
                                                      DataType=DateFormula;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     LeadTimeCalculation_Capt := Item.FIELDCAPTION("Lead Time Calculation");
                                                                                   END;
                                                                                    }
    
        { [{896240BD-0E96-44E2-A1FF-D538CCCC16DF}];2 ;ReorderPoint_Capt   ;Element ;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ReorderPoint_Capt := Item.FIELDCAPTION("Reorder Point");
                                                                                   END;
                                                                                    }
    
        { [{0E5FC230-3ED9-4A92-BF3D-93C060535B79}];2 ;MaximumInventory_Capt;Element;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     MaximumInventory_Capt := Item.FIELDCAPTION("Maximum Inventory");
                                                                                   END;
                                                                                    }
    
        { [{008ABC1D-0EA3-4E7A-9D86-446B48CC2B6F}];2 ;ReorderQuantity_Capt;Element ;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ReorderQuantity_Capt := Item.FIELDCAPTION("Reorder Quantity");
                                                                                   END;
                                                                                    }
    
        { [{9B904296-C598-47FB-9857-60BE18FB586F}];2 ;Reserve_Capt        ;Element ;Text    ;
                                                      DataType=Option;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Reserve_Capt := Item.FIELDCAPTION(Reserve);
                                                                                   END;
                                                                                    }
    
        { [{25ADC944-EECD-4239-91D4-B55502F75F13}];2 ;Scrap_Capt          ;Element ;Text    ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Scrap_Capt := Item.FIELDCAPTION("Scrap %");
                                                                                   END;
                                                                                    }
    
        { [{EF0B91FD-181A-4922-A881-79B38C13A512}];2 ;MinimumOrderQuantity_Capt;Element;Text;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     MinimumOrderQuantity_Capt := Item.FIELDCAPTION("Minimum Order Quantity");
                                                                                   END;
                                                                                    }
    
        { [{E0C073EC-19ED-4916-9CBE-A2336C27B221}];2 ;MaximumOrderQuantity_Capt;Element;Text;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     MaximumOrderQuantity_Capt := Item.FIELDCAPTION("Maximum Order Quantity");
                                                                                   END;
                                                                                    }
    
        { [{E0262808-9E98-4B2C-A7D7-542148C425A7}];2 ;SafetyStockQuantity_Capt;Element;Text ;
                                                      DataType=Decimal;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     SafetyStockQuantity_Capt := Item.FIELDCAPTION("Safety Stock Quantity");
                                                                                   END;
                                                                                    }
    
        { [{1996D36B-4F9E-44C5-A090-4C6EEA4BE231}];2 ;SafetyLeadeTime_Capt;Element ;Text    ;
                                                      DataType=DateFormula;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     SafetyLeadeTime_Capt := Item.FIELDCAPTION("Safety Lead Time");
                                                                                   END;
                                                                                    }
    
        { [{BF6F93D7-7D6C-4F02-8F39-63532A88E52F}];2 ;ReplenishmentSystem_Capt;Element;Text ;
                                                      DataType=Option;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ReplenishmentSystem_Capt := Item.FIELDCAPTION("Replenishment System");
                                                                                   END;
                                                                                    }
    
        { [{B4C98FA3-97CB-42B7-9A4E-4D1028C741B7}];2 ;ReorderingPolicy_Capt;Element;Text    ;
                                                      DataType=Option;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ReorderingPolicy_Capt := Item.FIELDCAPTION("Reordering Policy");
                                                                                   END;
                                                                                    }
    
        { [{17EBF244-F245-4036-A47C-73719BF19D00}];2 ;ReorderCycle_Capt   ;Element ;Text    ;
                                                      DataType=DateFormula;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ReorderCycle_Capt := Item.FIELDCAPTION("Reorder Cycle");
                                                                                   END;
                                                                                    }
    
        { [{955B0975-6102-4959-BC88-12457CFF0844}];2 ;ItemTrackingCode_Capt;Element;Text    ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     ItemTrackingCode_Capt := Item.FIELDCAPTION("Item Tracking Code");
                                                                                   END;
                                                                                    }
    
        { [{CF2CE9A5-1918-476B-A2B2-9DECE397035C}];2 ;LotNos_Capt         ;Element ;Text    ;
                                                      DataType=Code;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     LotNos_Capt := Item.FIELDCAPTION("Lot Nos.");
                                                                                   END;
                                                                                    }
    
        { [{41009546-448C-4282-A23D-3882D80872EE}];2 ;Dimension1_Capt     ;Element ;Text    ;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension1_Capt := g_cdarrDimensionValueCode[1,1];
                                                                                   END;
                                                                                    }
    
        { [{02349FD0-7DB8-44D8-9FFC-552AD254DADF}];2 ;Dimension2_Capt     ;Element ;Text    ;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension2_Capt := g_cdarrDimensionValueCode[2,1];
                                                                                   END;
                                                                                    }
    
        { [{1946BBFB-0F2E-4DCE-A751-5021CDF47372}];2 ;Dimension3_Capt     ;Element ;Text    ;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension3_Capt := g_cdarrDimensionValueCode[3,1];
                                                                                   END;
                                                                                    }
    
        { [{66C29DF5-D966-4F27-AF77-5F3741351B9E}];2 ;Dimension4_Capt     ;Element ;Text    ;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension4_Capt := g_cdarrDimensionValueCode[4,1];
                                                                                   END;
                                                                                    }
    
        { [{A20AE29C-841C-40F5-AED6-0D07C9868C89}];2 ;Dimension5_Capt     ;Element ;Text    ;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension5_Capt := g_cdarrDimensionValueCode[5,1];
                                                                                   END;
                                                                                    }
    
        { [{82A544A2-309E-4363-89B3-0BDF3DEC261C}];2 ;Dimension6_Capt     ;Element ;Text    ;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension6_Capt := g_cdarrDimensionValueCode[6,1];
                                                                                   END;
                                                                                    }
    
        { [{9EC95DF8-33FE-456C-8D98-3DB0D4E196CE}];2 ;Dimension7_Capt     ;Element ;Text    ;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension7_Capt := g_cdarrDimensionValueCode[7,1];
                                                                                   END;
                                                                                    }
    
        { [{55373AA9-8EF2-4B3C-AC55-CC85B1B03616}];2 ;Dimension8_Capt     ;Element ;Text    ;
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension8_Capt := g_cdarrDimensionValueCode[8,1];
                                                                                   END;
                                                                                    }
    
        { [{0E0A1C7B-C90F-42D5-BFF5-962CD684DE79}];1 ;Item                ;Element ;Table   ;
                                                      ReqFilterFields=Field1;
                                                      SourceTable=Table27;
                                                      SourceTableView=SORTING(Field1);
                                                      Import::OnAfterInitRecord=BEGIN
                                                                                  Item.INIT;
                                                                                END;
    
                                                      Import::OnBeforeInsertRecord=BEGIN
                                                                                     fnInsertItem;
                                                                                     fnClearDimCodeValue(2,g_cdarrDimensionValueCode);
                                                                                     currXMLport.SKIP;
                                                                                   END;
    
                                                      Export::OnAfterGetRecord=BEGIN
                                                                                 fnClearDimCodeValue(2,g_cdarrDimensionValueCode);
                                                                                 fnGetDefaultDim(DATABASE::Item,Item."No.");
                                                                                 g_intCount += 1;
                                                                               END;
                                                                                }
    
        { [{E28C055B-0A04-41BE-9B6C-E2881CEE3DC8}];2 ;No                  ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::No. }
    
        { [{22677773-DCA8-4314-A157-894A57129306}];2 ;Description         ;Element ;Field   ;
                                                      DataType=Text;
                                                      FieldValidate=No;
                                                      SourceField=Item::Description }
    
        { [{59C8F0D3-CE5D-41BF-B1C2-F53A4583B57B}];2 ;Description2        ;Element ;Field   ;
                                                      DataType=Text;
                                                      SourceField=Item::Description 2 }
    
        { [{39DF29D5-57C2-4CEF-A12E-DA8B7768A00A}];2 ;SearchDescription   ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Search Description }
    
        { [{F935D0E9-4BAD-4F4C-82DA-82CA73B9E98D}];2 ;ItemCategoryCode    ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Item Category Code }
    
        { [{4F254C57-1BEC-4448-A3B3-5FFCFACA8182}];2 ;ProductGroupCode    ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Product Group Code }
    
        { [{1686AFBB-CC8D-44F2-8032-BFA19B63796C}];2 ;BaseUnitOfMeasure   ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Base Unit of Measure }
    
        { [{EA5B4DC7-6A0D-4126-9D89-4D4EF0B79076}];2 ;PurchUnitOfMeasure  ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Purch. Unit of Measure }
    
        { [{A4D73D48-BC5C-44A8-B55B-43945256ED47}];2 ;SalesUnitOfMeasure  ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Sales Unit of Measure }
    
        { [{9D2AC2D5-A837-4183-B5F7-EED482B44DC3}];2 ;GenProdPostingGroup ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Gen. Prod. Posting Group }
    
        { [{DA420559-C013-4284-A033-90DF3F2060B3}];2 ;VATProdPostingGroup ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::VAT Prod. Posting Group }
    
        { [{CE985068-0AE7-43D5-AD1B-8D5733314F8E}];2 ;InventoryPostingGroup;Element;Field   ;
                                                      DataType=Code;
                                                      AutoCalcField=No;
                                                      SourceField=Item::Inventory Posting Group }
    
        { [{22270C31-AE31-42AB-A989-FC9098A12785}];2 ;ShelfNo             ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Shelf No. }
    
        { [{4C75B927-5E3B-4241-ADFA-1108594E7587}];2 ;ItemDiscGroup       ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Item Disc. Group }
    
        { [{EDE7BC3B-F2D6-4CB9-BEFA-F52656E7415D}];2 ;UnitPrice           ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Unit Price }
    
        { [{7A55D604-827E-47A6-B999-459237F3F8E7}];2 ;PriceProfitCalculation;Element;Field  ;
                                                      DataType=Option;
                                                      FieldValidate=No;
                                                      SourceField=Item::Price/Profit Calculation }
    
        { [{138713AB-A9E1-4385-810E-89DCB1ABE874}];2 ;Profit              ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Profit % }
    
        { [{882B02B8-381E-4FF5-9B27-2BBDEA7C56D9}];2 ;CostingMethod       ;Element ;Field   ;
                                                      DataType=Option;
                                                      FieldValidate=No;
                                                      SourceField=Item::Costing Method }
    
        { [{553C0DFD-E656-4900-9F64-BA81E29E9B4E}];2 ;LastDirectCost      ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Last Direct Cost }
    
        { [{00775A18-5083-4EA9-84B2-430A6E5BEBB5}];2 ;UnitCost            ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Unit Cost }
    
        { [{BFD12452-5B92-4EFC-9459-49FAB5DAE68A}];2 ;StandardCost        ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Standard Cost }
    
        { [{C5E526FA-65E8-4426-B395-4227F0FF7AC3}];2 ;LeadTimeCalculation ;Element ;Field   ;
                                                      DataType=DateFormula;
                                                      FieldValidate=No;
                                                      SourceField=Item::Lead Time Calculation }
    
        { [{704FED37-BC54-45B8-8368-990D7CFC8938}];2 ;ReorderPoint        ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Reorder Point }
    
        { [{709DC228-5387-45A0-876F-C4B59E1744A4}];2 ;MaximumInventory    ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Maximum Inventory }
    
        { [{28657BC8-8319-403F-B38B-D3523AC5AE87}];2 ;ReorderQuantity     ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Reorder Quantity }
    
        { [{43EC4515-9656-42EC-AA1D-AC943E1776D8}];2 ;Reserve             ;Element ;Field   ;
                                                      DataType=Option;
                                                      FieldValidate=No;
                                                      SourceField=Item::Reserve }
    
        { [{67899A37-4933-4A2C-8BC4-3A0D4B965BBD}];2 ;Scrap               ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Scrap % }
    
        { [{9754ECA1-8088-4A06-B472-9A3D22379BD3}];2 ;MinimumOrderQuantity;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Minimum Order Quantity }
    
        { [{2B241B6C-EC9B-4113-B10A-64CB1717F06D}];2 ;MaximumOrderQuantity;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Maximum Order Quantity }
    
        { [{73A03C77-251A-4569-B298-F448D0B3B879}];2 ;SafetyStockQuantity ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      FieldValidate=No;
                                                      SourceField=Item::Safety Stock Quantity }
    
        { [{9AE8DBA2-DD32-41C8-B7CF-67E13D551D2E}];2 ;SafetyLeadeTime     ;Element ;Field   ;
                                                      DataType=DateFormula;
                                                      FieldValidate=No;
                                                      SourceField=Item::Safety Lead Time }
    
        { [{9A318FF2-0E50-446B-B199-C4F45CC7F8E2}];2 ;ReplenishmentSystem ;Element ;Field   ;
                                                      DataType=Option;
                                                      FieldValidate=No;
                                                      SourceField=Item::Replenishment System }
    
        { [{1AF5753D-6935-462B-8C08-B444C5EE6F82}];2 ;ReorderingPolicy    ;Element ;Field   ;
                                                      DataType=Option;
                                                      FieldValidate=No;
                                                      SourceField=Item::Reordering Policy }
    
        { [{F0C5013B-2ACA-4A28-9E27-BF7B7655086D}];2 ;ReorderCycle        ;Element ;Field   ;
                                                      DataType=DateFormula;
                                                      FieldValidate=No;
                                                      SourceField=Item::Reorder Cycle }
    
        { [{39F8A640-5CC8-42C4-A597-8099CE2A0D55}];2 ;ItemTrackingCode    ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Item Tracking Code }
    
        { [{36DCDFE1-B2E2-4A03-B50E-CE8927F4AAC2}];2 ;LotNos              ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      SourceField=Item::Lot Nos. }
    
        { [{F62619CD-0442-4134-8511-7FB1A1E7841F}];2 ;Dimension1          ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      g_cdarrDimensionValueCode[1,2] := Dimension1;
                                                                                    END;
    
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension1 := g_cdarrDimensionValueCode[1,2];
                                                                                   END;
                                                                                    }
    
        { [{ABEE7356-7A26-4ED0-973E-7AD56401F48F}];2 ;Dimension2          ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      g_cdarrDimensionValueCode[2,2] := Dimension2;
                                                                                    END;
    
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension2 := g_cdarrDimensionValueCode[2,2];
                                                                                   END;
                                                                                    }
    
        { [{0B05F65F-0A68-432F-938E-CCB25981999D}];2 ;Dimension3          ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      g_cdarrDimensionValueCode[3,2] := Dimension3;
                                                                                    END;
    
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension3 := g_cdarrDimensionValueCode[3,2];
                                                                                   END;
                                                                                    }
    
        { [{0080C08D-E85A-4D45-8029-E9565574E039}];2 ;Dimension4          ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      g_cdarrDimensionValueCode[4,2] := Dimension4;
                                                                                    END;
    
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension4 := g_cdarrDimensionValueCode[4,2];
                                                                                   END;
                                                                                    }
    
        { [{3CF1C5AF-98DC-496B-BEA8-E2EFED78DB8A}];2 ;Dimension5          ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      g_cdarrDimensionValueCode[5,2] := Dimension5;
                                                                                    END;
    
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension5 := g_cdarrDimensionValueCode[5,2];
                                                                                   END;
                                                                                    }
    
        { [{B0CB9D5C-B1F3-425A-93AE-B1B3FD8A27E8}];2 ;Dimension6          ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      g_cdarrDimensionValueCode[6,2] := Dimension6;
                                                                                    END;
    
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension6 := g_cdarrDimensionValueCode[6,2];
                                                                                   END;
                                                                                    }
    
        { [{7C6ACCDC-6834-42F4-A6D6-6F0D13D9D51A}];2 ;Dimension7          ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      g_cdarrDimensionValueCode[7,2] := Dimension7;
                                                                                    END;
    
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension7 := g_cdarrDimensionValueCode[7,2];
                                                                                   END;
                                                                                    }
    
        { [{727FCB28-3401-4198-B6EE-A6965F7AB34B}];2 ;Dimension8          ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      g_cdarrDimensionValueCode[8,2] := Dimension8;
                                                                                    END;
    
                                                      Export::OnBeforePassVariable=BEGIN
                                                                                     Dimension8 := g_cdarrDimensionValueCode[8,2];
                                                                                   END;
                                                                                    }
    
      }
      EVENTS
      {
      }
      REQUESTPAGE
      {
        PROPERTIES
        {
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          g_cdarrDimensionValueCode@1000000000 : ARRAY [8,2] OF Code[20];
          g_intCount@1000000002 : Integer;
          Text000@1000000003 : TextConst 'ENU=%1 record(s) %2ed.';
          Text001@1000000004 : TextConst 'ENU=Import';
          Text002@1000000005 : TextConst 'ENU=Export';
    
        LOCAL PROCEDURE fnSetDimCode@1000000014();
        VAR
          recGLSetup@1000000001 : Record 98;
        BEGIN
          fnClearDimCodeValue(3,g_cdarrDimensionValueCode);
          recGLSetup.GET;
          g_cdarrDimensionValueCode[1,1] := recGLSetup."Shortcut Dimension 1 Code";
          g_cdarrDimensionValueCode[2,1] := recGLSetup."Shortcut Dimension 2 Code";
          g_cdarrDimensionValueCode[3,1] := recGLSetup."Shortcut Dimension 3 Code";
          g_cdarrDimensionValueCode[4,1] := recGLSetup."Shortcut Dimension 4 Code";
          g_cdarrDimensionValueCode[5,1] := recGLSetup."Shortcut Dimension 5 Code";
          g_cdarrDimensionValueCode[6,1] := recGLSetup."Shortcut Dimension 6 Code";
          g_cdarrDimensionValueCode[7,1] := recGLSetup."Shortcut Dimension 7 Code";
          g_cdarrDimensionValueCode[8,1] := recGLSetup."Shortcut Dimension 8 Code";
        END;
    
        LOCAL PROCEDURE fnGetDefaultDim@1000000010(pintTableID@1000000000 : Integer;pcdNo@1000000002 : Code[20]);
        VAR
          recDefaultDim@1000000004 : Record 352;
          intDimCount@1000000005 : Integer;
        BEGIN
          fnClearDimCodeValue(2,g_cdarrDimensionValueCode);
          FOR intDimCount := 1 TO ARRAYLEN(g_cdarrDimensionValueCode,1) DO
            WITH recDefaultDim DO BEGIN
              SETRANGE("Table ID", pintTableID);
              SETRANGE("No.", pcdNo);
              SETRANGE("Dimension Code",g_cdarrDimensionValueCode[intDimCount,1]);
              IF FINDSET THEN
                g_cdarrDimensionValueCode[intDimCount,2] := "Dimension Value Code"
            END;
        END;
    
        LOCAL PROCEDURE fnClearDimCodeValue@1000000003(poptClearType@1000000000 : 'Code,Value,CodeValue';VAR pcdarrDimensionValueCode@1000000002 : ARRAY [8,2] OF Code[20]);
        VAR
          intDimCount@1000000001 : Integer;
        BEGIN
          CASE poptClearType OF
            1:
            FOR intDimCount := 1 TO ARRAYLEN(pcdarrDimensionValueCode,1) DO
              CLEAR(pcdarrDimensionValueCode[intDimCount,1]);
            2:
            FOR intDimCount := 1 TO ARRAYLEN(pcdarrDimensionValueCode,1) DO
              CLEAR(pcdarrDimensionValueCode[intDimCount,2]);
            3:
              CLEAR(pcdarrDimensionValueCode);
          END;
        END;
    
        LOCAL PROCEDURE fnInsertItem@1000000000();
        VAR
          recTmpItem@1000000000 : TEMPORARY Record 27;
        BEGIN
          recTmpItem := Item;
    
          WITH Item DO BEGIN
            IF INSERT(TRUE) THEN;
            IF recTmpItem.Description <> '' THEN
              VALIDATE(Description );
            recTmpItem.TESTFIELD("Base Unit of Measure");
            fnInsertBaseUOM("No.", "Base Unit of Measure");
            VALIDATE("Base Unit of Measure", recTmpItem."Base Unit of Measure");
            VALIDATE("Unit Price", recTmpItem."Unit Price");
            VALIDATE("Price/Profit Calculation", recTmpItem."Price/Profit Calculation");
            VALIDATE("Item Category Code", recTmpItem."Item Category Code");
            IF recTmpItem."Product Group Code" <> '' THEN
              VALIDATE("Product Group Code", recTmpItem."Product Group Code");
            IF recTmpItem."Gen. Prod. Posting Group" <> '' THEN
              VALIDATE("Gen. Prod. Posting Group", recTmpItem."Gen. Prod. Posting Group");
            IF recTmpItem."VAT Prod. Posting Group" <> '' THEN
              VALIDATE("VAT Prod. Posting Group", recTmpItem."VAT Prod. Posting Group");
            IF recTmpItem."Inventory Posting Group" <> '' THEN
              VALIDATE("Inventory Posting Group", recTmpItem."Inventory Posting Group");
            VALIDATE("Profit %", recTmpItem."Profit %");
            VALIDATE("Costing Method", recTmpItem."Costing Method");
            VALIDATE("Unit Cost", recTmpItem."Unit Cost");
            VALIDATE("Standard Cost", recTmpItem."Standard Cost");
            IF recTmpItem."Purch. Unit of Measure" <> '' THEN
              VALIDATE("Purch. Unit of Measure", recTmpItem."Purch. Unit of Measure");
            IF recTmpItem."Sales Unit of Measure" <> '' THEN
              VALIDATE("Sales Unit of Measure", recTmpItem."Sales Unit of Measure");
            VALIDATE("Lead Time Calculation", recTmpItem."Lead Time Calculation");
            VALIDATE("Reorder Point", recTmpItem."Reorder Point");
            VALIDATE("Maximum Inventory", recTmpItem."Maximum Inventory");
            VALIDATE("Reorder Quantity", recTmpItem."Reorder Quantity");
            IF FORMAT(recTmpItem.Reserve) <> '' THEN
              VALIDATE(Reserve, recTmpItem.Reserve);
            VALIDATE("Scrap %", recTmpItem."Scrap %");
            VALIDATE("Minimum Order Quantity", recTmpItem."Minimum Order Quantity");
            VALIDATE("Maximum Order Quantity", recTmpItem."Maximum Order Quantity");
            VALIDATE("Safety Stock Quantity", recTmpItem."Safety Stock Quantity");
            VALIDATE("Safety Lead Time", recTmpItem."Safety Lead Time");
            IF FORMAT(recTmpItem."Replenishment System") <> '' THEN
              VALIDATE("Replenishment System", recTmpItem."Replenishment System");
            IF FORMAT(recTmpItem."Reordering Policy") <> '' THEN
              VALIDATE("Reordering Policy", recTmpItem."Reordering Policy");
            IF FORMAT(recTmpItem."Reorder Cycle") <> '' THEN
              VALIDATE("Reorder Cycle", recTmpItem."Reorder Cycle");
            IF recTmpItem."Item Tracking Code" <> '' THEN
              VALIDATE("Item Tracking Code", recTmpItem."Item Tracking Code");
            IF recTmpItem."Lot Nos." <> '' THEN
              VALIDATE("Lot Nos.", recTmpItem."Lot Nos.");
            MODIFY;
            fnInsertDefaultDim(DATABASE::Item,"No.");
          END;
          g_intCount += 1;
        END;
    
        LOCAL PROCEDURE fnInsertBaseUOM@1000000002(cdeItem@1000000000 : Code[20];cdeBaseUOM@1000000001 : Code[10]);
        VAR
          recItemUOM@1000000002 : Record 5404;
        BEGIN
          IF NOT recItemUOM.GET(cdeItem, cdeBaseUOM) THEN BEGIN
            recItemUOM.INIT;
            recItemUOM."Item No." := cdeItem;
            recItemUOM.VALIDATE(Code, cdeBaseUOM);
            recItemUOM.INSERT(TRUE);
          END;
        END;
    
        LOCAL PROCEDURE fnInsertDefaultDim@1000000012(pintTableID@1000000000 : Integer;pcdNo@1000000002 : Code[20]);
        VAR
          recDefaultDim@1000000004 : Record 352;
          intDimCount@1000000005 : Integer;
        BEGIN
          WITH recDefaultDim DO BEGIN
            SETRANGE("Table ID", pintTableID);
            SETRANGE("No.", pcdNo);
            IF FINDSET THEN
              DELETEALL;
    
            FOR intDimCount := 1 TO ARRAYLEN(g_cdarrDimensionValueCode,1) DO
              IF g_cdarrDimensionValueCode[intDimCount,2]<>'' THEN BEGIN
                INIT;
                "Table ID"      := pintTableID;
                "No."           := pcdNo;
                "Dimension Code"      := g_cdarrDimensionValueCode[intDimCount,1];
                "Dimension Value Code":= g_cdarrDimensionValueCode[intDimCount,2];
                INSERT(TRUE);
              END;
          END;
        END;
    
        BEGIN
        END.
      }
    }
    

    Best Regards,
    Yukon
    Make Simple & Easy
  • mkeurmkeur Member Posts: 13
    HI, bit of an old post. The solution by Yukon with an extra data item workst almost for me. Almost, because an extra line is inserted in the csv file below the header line.
    Anyone knows a possibility to get a header row without a blank line?
  • yukonyukon Member Posts: 361
    Hi,

    Sorry for late reply. Remove the "<NewLine>" on TableSeparator Properties of XML.



    Regards,
    Yukon
    Make Simple & Easy
Sign In or Register to comment.