Create Fixed length text file from Customer Record

colingbradleycolingbradley Member Posts: 162
NAV2009 Classic Client
I have a need to automatically create a file in text format, fixed length whenever the OnModify is triggered for Table 18.
Dataports are no longer supported so I am assuming I will need to write a processing type report.

The BACS report looks like it may fit the bill but that is CSV output.

Anyone have a worked example please or any pointers.

Many thanks,
Colin
Experience is what you get when you hoped to get money

Comments

  • vijay_gvijay_g Member Posts: 884
    You can write something like this
    NFile.CREATE('C:\Filename.txt');
    NFile.open('C:\Filename.txt');
    NFile.TEXTMODE(TRUE);
    NFile.WRITE('Enter Your Text Here');
    NFile.CLOSE;
    Nfile is Variable of type file
    
  • colingbradleycolingbradley Member Posts: 162
    Thanks Vijay,

    I have that information, thanks.
    I am keen to see an example of creating the file where the fields are in fixed positions.

    I have examples where the file is deliminated with "(quotes) and ,(commas) but I need Fixed Position, example:
    abc123^^^^^^^^^^^^^^^Systems Limited^^^^^^^^^^^^^^^^^^^77 High Street (where ^ = space or null).
    Not "123","Systems Limited","etc....
    This is what I have after working through the problem:

    linepart[1] := padstr("no.",maxstrlen("no."),Space);
    LinePart[2] := padstr(Name,maxstrlen(Name),Space);
    LinePart[3] := padstr("name 2",maxstrlen("name 2"),Space);
    LinePart[4] := padstr(Address,maxstrlen(address),Space);
    LinePart[5] := padstr("Address 2",maxstrlen("Address 2"),Space);
    LinePart[6] := padstr(City,maxstrlen(city),Space);
    LinePart[7] := padstr(County,maxstrlen(county),Space);
    LinePart[8] := padstr("Post Code",maxstrlen("Post Code"),Space);
    LinePart[9] := padstr("Country/Region Code",maxstrlen("Country/Region Code"),Space);
    LinePart[10] := padstr("Currency Code",maxstrlen("Currency Code"),Space);
    LinePart[11] := padstr(Contact,maxstrlen(contact),Space);
    LinePart[12] := padstr("Phone No.",maxstrlen("phone No."),Space);
    LinePart[13] := padstr("Fax No.",maxstrlen("fax No."),Space);
    LinePart[14] := padstr("VAT Registration No.",maxstrlen("VAT Registration No."),Space);
    LinePart[15] := padstr("Payment Method Code",maxstrlen("Payment Method Code"),Space);
    LinePart[16] := padstr("E-Mail",maxstrlen("E-Mail"),Space);
    Line := LinePart[1] + LinePart[2] + LinePart[3] + LinePart[4] + LinePart[5] +
    LinePart[6] + LinePart[7] + LinePart[8] + LinePart[9] + LinePart[10] +
    LinePart[11] + LinePart[12] + LinePart[13] + LinePart[14] + LinePart[15] +
    LinePart[16];

    I get a fixed length output file. \:D/
    Experience is what you get when you hoped to get money
Sign In or Register to comment.