Dataport question

pvarpvar Member Posts: 157
edited 2006-08-03 in Navision Attain
Hi,

Is there a way I could export data from 2 related tables in either Fixed or Variable format to a text file? When I tried to link the tables by indenting the data items, I got a message(while compiling) that 'you indented data items but the file format is not UPDXML'

Comments

  • DenSterDenSter Member Posts: 8,307
    You can't indent dataports. If you want to export data from related tables, you need to program the values in the OnBeforeExport trigger and put it as a variable in your dataport fields as part of the line of data.
  • bbrownbbrown Member Posts: 3,268
    Another way is to use a process-only report and use the File commands to write out the data.
    There are no bugs - only undocumented features.
  • pvarpvar Member Posts: 157
    Thanks Denster & bbrown for your valuable suggestions.

    But I doubt if I understood correctly what to do with Denster's option. Could you please elaborate the steps?

    I am trying to get the information from Global Item and Global Item variant tables. Do I still need to list both tables as dataitems without indentation?
  • SavatageSavatage Member Posts: 7,142
    DenSter wrote:
    You can't indent dataports. If you want to export data from related tables, you need to program the values in the OnBeforeExport trigger and put it as a variable in your dataport fields as part of the line of data.

    What part do you not understand so we can help you better?

    Do you know how to create variables?

    for example I have a dataport using "Sales lines" but I need info from the item table so I can know if an item is currently "blocked"


    Item.GET("Sales Line"."No.");

    IF Item.Blocked THEN
    BEGIN
    MyStuff blah blah;
    END;
  • pvarpvar Member Posts: 157
    The part I don't understand is how we link the tables if we don't indent and also defining a variable as a data port field.

    I am new to Navision and I think this is the first dataport I am trying to create.
  • SavatageSavatage Member Posts: 7,142
    if you look at chapter 17 or 18 of the application designers guide it has a whole section on dataports. the Designers guide can be found on your product cd. if you can't find it - I can post a link where you can download it from. that's probably a good place to start. not just for dataports but for reports, forms, tables , etc etc
  • pvarpvar Member Posts: 157
    That is where I first looked at it but I couldn't find anything about exporting data from related tables like this.
  • SavatageSavatage Member Posts: 7,142
    Apparently you need the output to look a certain way,
    You need all the info for each Item varient on 1 line?

    Am I correct in this?
  • pvarpvar Member Posts: 157
    Correct, what I am looking to see in the output is all the information from the item table and the variant code from the variant table in on line. So if you have an item with 5 variants I need 5 lines in the output with just the variant code different among the lines.
  • SavatageSavatage Member Posts: 7,142
    so here's a simple sample of a dataport - this dataport exports;
    Item table data:
    1) Item.No.
    2) Item.Vendor No.
    3) Item.UPC Code
    Item Variant Table Data
    4) Item Variant.Code
    OBJECT Dataport 50015 Item Varient Temp
    {
      OBJECT-PROPERTIES
      {
        Date=08/02/06;
        Time=[ 4:27:18 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table5401;
            OnBeforeExportRecord=BEGIN
                                   Item.GET("Item Variant"."Item No.");
                                   Exp_ItemNo := Item."No.";
                                   Exp_VendorNo := Item."Vendor No.";
                                   Exp_UPCcode := Item."Item UPC/EAN Number";
                                 END;
    
          }
          FIELDS
          {
            {      ;     ;Exp_ItemNo           }
            {      ;     ;Exp_VendorNo         }
            {      ;     ;Exp_UPCcode          }
            {      ;     ;Code                 }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          "Item Varient"@1102606001 : Record 5401;
          Exp_ItemNo@1102606000 : Code[10];
          Exp_VendorNo@1102606002 : Code[10];
          Exp_UPCcode@1102606003 : Code[10];
          Item@1102606004 : Record 27;
    
        BEGIN
        END.
      }
    }
    

    The output of this phoney item # is
    "SW1041","111865","0000101010101","AB1"
    "SW1041","111865","0000101010101","AB2"

    sw1041 is the item #
    111865 is the vendor#
    0000101010101 is the upc code
    & ab1 & ab2 are the two variants for this item

    you can of course add/remove any fields YOU want.

    Note; this is a sample using the Item Variant Table as the dataitem but You could switch it around to the item table depending on your needs.
  • pvarpvar Member Posts: 157
    Thanks Savatage. It worked but there is one problem. If an item doesn't have a variant then I won't get that item in the output.
  • SavatageSavatage Member Posts: 7,142
    Savatage wrote:
    Note; this is a sample using the Item Variant Table as the dataitem but You could switch it around to the item table depending on your needs.

    It was to show you how to get the additional info you needed and how to use variables in a dataport
  • DenSterDenSter Member Posts: 8,307
    Maybe you should run a dataport off of the Item Variant table, and get Item information as additional fields.
Sign In or Register to comment.