Empty file - dataport

SrivasSrivas Member Posts: 89
I am importing csv file from a dataport and then copy the file to a different folder.
It imports correctly but the file is empty.
I don't know why the file is empty after import. ](*,)

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Do you do it manually or through code?
  • SrivasSrivas Member Posts: 89
    through code
  • SavatageSavatage Member Posts: 7,142
    OnAfterImportRecord()
    OrderCount := OrderCount + 1;
    

    text constants:
    Text0001-> %1 Orders Imported / Would You Like To Delete The File?
    FilePath->c:\DataportFile\Completed Import\

    OnPostDataport()
    CurrFile.CLOSE;  //don't forget to close!
    IF CONFIRM(Text0001,TRUE,OrderCount) THEN BEGIN
    SavedFileName := FORMAT(WORKDATE,0,'<Year4>'+'-'+'<Month Text,3>'+'-'+'<Day,2>')+'.txt';
    FILE.COPY(CurrDataport.FILENAME,FilePath+SavedFileName);
    ERASE(CurrDataport.FILENAME);
    END;
    

    In this example of moving a file after import to another directory - my new filename becomes the day month year.
  • SrivasSrivas Member Posts: 89
    I call the dataport from a code unit like this

    GLEAdjImport.IMPORT := TRUE;
    GLEAdjImport.FILENAME := ImpFile.Path + '\' + ImpFile.Name;
    GLEAdjImport.RUN;

    And then in code unit itself I move the file to new location

    IF COPY("Imp Ready to Process Location" + '\' + ImpFile.Name,"Imp Processed Location" + '\' + ImpFile.Name) THEN
    ERASE("Imp Ready to Process Location" + '\' + ImpFile.Name);
  • SavatageSavatage Member Posts: 7,142
    have you tried your move from the dataport as i did?
    have you tried closing the file before moving it?
  • DaveTDaveT Member Posts: 1,039
    Savatage wrote:
    have you tried closing the file before moving it?

    My money is on this :mrgreen:
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • SrivasSrivas Member Posts: 89
    I have taken IMPfile as a record variable of file which donot have close method.
  • SavatageSavatage Member Posts: 7,142
    why not just add the code to onpostdataport trigger?

    are you obligated to move the file using the codeunit?
Sign In or Register to comment.