Importing a text file!!

sunnyksunnyk Member Posts: 280
Hi experts,
I m using Nav 3.7. Whenever i import a textfile into Journal(say to post the payrol data), a message appeared every time
"The Operating System cannot find the drive and directory specified for the file "Notepad.exe C:\path of the file
Please Check that the drive ,directory and files are correct".

Although the data got inserted.but why i got this message everytime whenever i m importing through text file.

Any suggestions!!!

Comments

  • AlbertvhAlbertvh Member Posts: 516
    Hi,
    I suggest you open the object that you are running and see if there is a SHELL command that is running notepad.

    Albert
  • ritesh.singhritesh.singh Member Posts: 123
    This seem problem related to the attributes of the file/drive. you need to check whether you are authorized to read/modify the drive/file .
    Thanks,
    Ritesh K Singh
  • sunnyksunnyk Member Posts: 280
    Hi Albert,
    Yes there is command which create the File at the Onpredataitem ofthe dataport(used for importing the data from Text file.)
  • AlbertvhAlbertvh Member Posts: 516
    Hi Sunnyk,

    Could you post the code here as I'm only guessing what is running.

    Albert
  • sunnyksunnyk Member Posts: 280
    Albert,
    First of all thanks for your Interest.
    Here is the code :
    Integer - OnPreDataItem()
    IF DocumentNo=''THEN BEGIN
     ERROR('Document No. can not be blank');
    END;
    ShowXfile := FALSE;
    Xfile.WRITEMODE := TRUE;
    Xfile.TEXTMODE := TRUE;
    Xfile.CREATE('C:\Payroll.txt');
    "rec Gen. Journal Line".RESET;
    "rec Gen. Journal Line".SETFILTER("Journal Template Name",'%1',JTN);
    "rec Gen. Journal Line".SETFILTER("Journal Batch Name",'%1',JBN);
    IF "rec Gen. Journal Line".FIND('+')THEN BEGIN
     lineno:="rec Gen. Journal Line"."Line No."+10000;
    END ELSE BEGIN
     lineno:=10000;
    END;
    
      IF LegacyGLAccountDept <>'' THEN BEGIN
        LegacyGLAccount:=COPYSTR(LegacyGLAccountDept,1,3);
        GLDept:=COPYSTR(LegacyGLAccountDept,5,STRLEN(LegacyGLAccountDept)-4);
        "Legacy G/L Account".RESET;
        "Legacy G/L Account".SETFILTER("No.",'%1',LegacyGLAccount);
        IF "Legacy G/L Account".FIND('-') THEN BEGIN
          deptcode:='';
          BUCode:='';
          "Dimension Value".RESET;
          "Dimension Value".SETFILTER("Dimension Value"."Dimension Code",'%1','Dept');
          "Dimension Value".SETFILTER("Dimension Value"."ADP Code",'%1',GLDept);
          IF "Dimension Value".FIND('-') THEN BEGIN
            deptcode:="Dimension Value".Code;
            BUCode:="Dimension Value"."ADP BU Code";
          END;
          IF NOT ((deptcode='') AND (GLDept<>'00000')) THEN BEGIN
            "rec Gen. Journal Line".INIT;
            "rec Gen. Journal Line".VALIDATE("Journal Template Name",JTN);
            "rec Gen. Journal Line".VALIDATE("Journal Batch Name",JBN);
            "rec Gen. Journal Line".VALIDATE("Line No.",lineno);
            "rec Gen. Journal Line".VALIDATE("Document No.",DocumentNo);
            "rec Gen. Journal Line".VALIDATE("Posting Date",PostingDate);
            IF LegacyGLAccount='107'THEN BEGIN
              "rec Gen. Journal Line".VALIDATE("Account Type",3);
              "rec Gen. Journal Line".VALIDATE("Account No.",'payroll');
            END ELSE BEGIN
              "rec Gen. Journal Line".VALIDATE("Account Type",0);
              "rec Gen. Journal Line".VALIDATE("Account No.","Legacy G/L Account"."G/L Account No.");
            END;
            "rec Gen. Journal Line".VALIDATE("Posting Date",PostingDate);
            //"rec Gen. Journal Line".Description
            "rec Gen. Journal Line".VALIDATE(Amount,amt);
            "rec Gen. Journal Line".VALIDATE("Shortcut Dimension 1 Code",deptcode);
            "rec Gen. Journal Line".VALIDATE("Shortcut Dimension 2 Code",BUCode);
            "rec Gen. Journal Line".INSERT(TRUE);
            COMMIT;
            lineno+=10000;
          END ELSE BEGIN
            ShowXfile := TRUE;
            Xfile.WRITE('Dept not found '+GLDept+' not Found');
          END;
        END ELSE BEGIN
          ShowXfile := TRUE;
          Xfile.WRITE('G/L Account'+LegacyGLAccount+' not Found');
        END;
      END;
    
      IF LegacyGLAccountDept <>'' THEN BEGIN
        LegacyGLAccount:=COPYSTR(LegacyGLAccountDept,1,8);
        GLDept:=COPYSTR(LegacyGLAccountDept,11,5);
        deptcode :=GLDept;
           "rec Gen. Journal Line".INIT;
           "rec Gen. Journal Line".VALIDATE("Journal Template Name",JTN);
           "rec Gen. Journal Line".VALIDATE("Journal Batch Name",JBN);
           "rec Gen. Journal Line".VALIDATE("Line No.",lineno);
           "rec Gen. Journal Line".VALIDATE("Document No.",DocumentNo);
           "rec Gen. Journal Line".VALIDATE("Posting Date",PostingDate);
           "rec Gen. Journal Line".VALIDATE("Account Type",0);
           "rec Gen. Journal Line".VALIDATE("Account No.",LegacyGLAccount);
           "rec Gen. Journal Line".VALIDATE("Posting Date",PostingDate);
           "rec Gen. Journal Line".VALIDATE(Amount,amt);
           "rec Gen. Journal Line".VALIDATE("Shortcut Dimension 1 Code",deptcode);
           "rec Gen. Journal Line".INSERT(TRUE);
           COMMIT;
           lineno+=10000;
        END ELSE BEGIN
          ShowXfile := TRUE;
          Xfile.WRITE('G/L Account'+LegacyGLAccount+' not Found');
        END;
    Integer - OnPostDataItem()
    IF ShowXfile THEN
      SHELL('Notepad.exe C:\Payroll.txt');
    
  • AlbertvhAlbertvh Member Posts: 516
    Hi,
    I think that you should change this
    IF ShowXfile THEN
      SHELL('Notepad.exe C:\Payroll.txt');
    

    to
    IF ShowXfile AND EXIST('C:\Payroll.txt') THEN
      SHELL('Notepad.exe', 'C:\Payroll.txt');
    


    Hope this helps

    Albert

    Edit: Tried to put ', ' in bold
  • MBergerMBerger Member Posts: 413
    You need to CLOSE the file first, otherwise it won't exist yet !
  • sunnyksunnyk Member Posts: 280
    oh Thanks a lot Everyone.The Issue is resolved now.

    Thank you very much Albert and MBerger!
Sign In or Register to comment.