How to pull out data if the value in one of the field matche

sunnyksunnyk Member Posts: 280
Hi experts,
I have one txt file with Item No. Now suppose if the first 3 charcters of the item no. in the text file matches the item no in Navision it pulls that item no from navision to me(in txt file).
How to do this.

Comments

  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Hi Sunnyk,

    1) Use two dataports : one for import and other for export.
    2) call the export Dataport from OnPostDataItem() of first Dataport.
    3) In Import Dataport, import the text file Items in the Navision table with a tag on them so that you can Identify them later and delete.
    4)Mark the Item Nos of Interest (i.e. first 3 characters are same as that of in text file). this can be done while importing.
    5) Once the item Nos are marked, delete the item nos just imported into the table.
    6) call the export dataport which will export only marked records. :wink:

    Here are the objects for two Dataports.. O:)
    OBJECT Dataport 90000 DP1- Start
    {
      OBJECT-PROPERTIES
      {
        Date=07/11/08;
        Time=[ 6:42:18 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Import=Yes;
        FieldStartDelimiter=None;
        FieldEndDelimiter=None;
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table27;
            DataItemTableView=SORTING(No.);
            OnPreDataItem=BEGIN
                               it1.RESET;
                          END;
    
            OnAfterImportRecord=BEGIN
                                  "No." := 'ZZZ' + Item."No." ;  // the trick part
                                   IF it1.FINDSET THEN
                                     REPEAT
                                       IF (COPYSTR(it1."No.",1,3) = COPYSTR("No.",4,3)) THEN
                                         it1.MARK(TRUE);
                                     UNTIL it1.NEXT = 0;
                                END;
    
            OnPostDataItem=BEGIN
    
                              it2.RESET;
                              IF it2.FINDSET THEN
                              REPEAT
                                IF (COPYSTR(it2."No.",1,3) = 'ZZZ') THEN
                                BEGIN
                                  it3 := it2;
                                  it3.DELETE;
                                END;
                              UNTIL it2.NEXT = 0;
    
    
                              DATAPORT.RUN(90001,FALSE,it1);
                           END;
    
          }
          FIELDS
          {
            {      ;     ;"No."                }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=19690;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          it1@1102753000 : Record 27;
          it2@1102753001 : Record 27;
          NoStr@1102753002 : Text[1024];
          IT@1102753003 : Record 27;
          PathExport@1102753004 : Text[200];
          CD@1102753005 : Codeunit 412;
          ExportDp@1102753006 : Dataport 90001;
          PathImport@1102753007 : Text[200];
          it3@1102753008 : Record 27;
    
        BEGIN
        END.
      }
    }
    
    OBJECT Dataport 90001 DP2-export
    {
      OBJECT-PROPERTIES
      {
        Date=07/11/08;
        Time=[ 6:38:01 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Import=No;
        FieldStartDelimiter=None;
        FieldEndDelimiter=None;
        OnInitDataport=BEGIN
                          CurrDataport.FILENAME := CD.OpenFile('Enter path name','*.txt',1,'*.txt',0);
                       END;
    
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table27;
            DataItemTableView=SORTING(No.);
            OnPreDataItem=BEGIN
                              MARKEDONLY(TRUE);
                          END;
    
          }
          FIELDS
          {
            {      ;     ;"No."                }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          it1@1102753000 : Record 27;
          it2@1102753001 : TEMPORARY Record 27;
          NoStr@1102753002 : Text[1024];
          IT@1102753003 : Record 27;
          CD@1102753004 : Codeunit 412;
    
        BEGIN
        END.
      }
    }
    
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
Sign In or Register to comment.