Dataport With 2 dataitems

sunnyksunnyk Member Posts: 280
Hi,
I need a Dataport with 2 Dataitems(say Item & Table X). Both Tables have Item No. as Common Field. I need to create a dataport (Export)with 5-6 Item table fields and Need one field from Table X. How can i do it.

Thnx in Advance.

Comments

  • MalajloMalajlo Member Posts: 294
    Put code in OnBeforeExport to get field from table x (into var), modify dataport fields (you can put TableX.Field)
  • sunnyksunnyk Member Posts: 280
    Yup, I did that. But the Problem is how to export the data if tht field(The dat stored in the variable)
  • MalajloMalajlo Member Posts: 294
    Go to Dataport Fields, insert new line, SourceExpr is TableX.Field (or var).
    You should type value.
  • sunnyksunnyk Member Posts: 280
    Hi Malajlo,
    Acood to you I have one Dataitem (Say Item) , 2 Global Variable one for Table x and other for storing the value of the field in the Table X.
    I wrote the code in the Onbeforexport on item, but how can i select the variable in Dataport field. It is giving error.
  • MalajloMalajlo Member Posts: 294
    You can always type in the value of variable in dataport fields.
    Where is the problem?
  • EugeneEugene Member Posts: 309
    what is the relation between twop tables ? is it one-to-one relation or one-to-many relation or many-to-one or even many-to-many relation?

    If the relation is Item(one) to (many)"Table X" ( that is a given item can have many records in the "Table X" associated with that item) then you should have "Table X" as dataitem in your report and lookup the values from the Item table.

    If the relation is Item(many) to (one)"Table X" ( that is several items "belong" to a single record in Table X) then you use Item as dataitem on your report and lookup Table X value
  • DenSterDenSter Member Posts: 8,305
    What you want to do is not possible with two data items. Check this out:
    OBJECT Dataport 60000 Two Table Test
    {
      OBJECT-PROPERTIES
      {
        Date=12/10/07;
        Time=[ 9:16:41 AM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table27;
            OnBeforeExportRecord=BEGIN
                                   IF NOT ItemUOM.GET(Item."No.",Item."Base Unit of Measure") THEN BEGIN
                                     ItemUOM.INIT;
                                     ItemUOM.Code := 'NOTFOUND';
                                   END;
                                 END;
    
          }
          FIELDS
          {
            { 1    ;20   ;"No."                }
            { 22   ;30   ;Description          }
            {      ;     ;ItemUOM.Code         }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          ItemUOM@1000000000 : Record 5404;
    
        BEGIN
        END.
      }
    }
    
    This is just a sample, meant to run for export only. Using this for importing data will give you unintended results :mrgreen:
  • sunnyksunnyk Member Posts: 280
    Thnx all, Now the data is exported. Now I have One more query, when exporting Data in a csv file which property of Fields or Datport or Dataitem i will set so that the csv file will show coloumn heading as well.

    My problem is that when exporting Data to a CSv file it is showing 5-6 coloumns but not the Coloumn heading.
    I tried with caption Property of Fields, i tried writing Dataport fields as dataport.Filed in the source Exp but all is in Vain.

    Please Suggest.
  • MalajloMalajlo Member Posts: 294
    Put Integer DataItem, set filter of dataitem to Number=1, create variables for header, change DataportFelds of Integer as header variables, define header variables in onBeforeExport, change optionaly RecordSeparator <newline><newline>(but then disable import!).
  • SavatageSavatage Member Posts: 7,142
    Here's a wonderful post about how to skip the header line when importing

    FYI
    http://www.mibuso.com/forum/viewtopic.php?t=10564
Sign In or Register to comment.