Key Words or Work Arounds..

dohertyk
dohertyk Member Posts: 94
I am currently working my way through Form 10040, and changing some code in it to allow for me to get the Past Due Amounts of 30, 60, 90 days that I can incorporate into my dataport export into a text file.

I am running into issue's as this is a report, and I've learned that you can change CurrReport to CurrDataPort, and then that part will work. However, what do you do for lines like "CREATETOTALS"?

It's just not working for me, and I am doing my best to understand the logic and then massage it to my needs. Any assistance would be of great help. I really think that my life would have been easier had I just approached this problem differently from the get-go.

Thanks for any help. Sincerely,

Kevin (navision newbie)

Answers

  • Alex_Chow
    Alex_Chow Member Posts: 5,063
    It would be easiest if you just use report 10040 (A/R Aging) and get the aging information exported to Excel. You'll get the option to export to Excel in version 4.0 SP3.

    There's no CREATETOTALS function on forms. Unless it's a flowfield, you'll need to write code to add up the numbers.
  • dohertyk
    dohertyk Member Posts: 94
    deadlizard wrote:
    It would be easiest if you just use report 10040 (A/R Aging) and get the aging information exported to Excel. You'll get the option to export to Excel in version 4.0 SP3.

    There's no CREATETOTALS function on forms. Unless it's a flowfield, you'll need to write code to add up the numbers.

    Thank you DeadLizard, however, I really need to put things into a text file. And if I could make an excel spreadsheet, I would seek that out as an option.

    Just to inquire, I was wondering if I could use a flowfilter in a dataport. And if I could achieve the same sort of result? I understand that there is much more programming involved. But if I can do more now, and then not look back, other then to just be satisfied that I was able to struggle through it and to get something working properly. I would feel great.

    I guess one of the things I might have been able to do would have been to just create a report and then instead of putting it out to a screen or to a printer. Do a re-direct to a file. After all a report and a dataport are pretty well the same thing anyway, at least they are in my eyes.

    If anyone would like to give me any constructive tips in accomplishing my task, that would be very much appreciated.

    Thanks again,

    Kevin
  • Savatage
    Savatage Member Posts: 7,142
    edited 2007-01-15
    It's actually Report 10040 you're talking about - not form.

    Aged Accounts Receivable.

    This was not useful to you?
    http://www.mibuso.com/forum/viewtopic.php?p=72130

    I looks like a huge job but if you put al that code in your dataport - I guess it would work. But it's easier to export it to excel and save it as a csv or text file. You can even do a macro that does it all in a click.

    ---
    I haven't tested it but if you clean up that a/r report to print just 1 line of fields (copy it and save it with a new # & name) with some kind of text field seperator "~" (for example) I guess if you printed to file it might work. :-k
  • Alex_Chow
    Alex_Chow Member Posts: 5,063
    Don't try to write an aging report on your own. I'd rather you spend that time with your family. :mrgreen:

    The easiest way, by far, is to just modify the aging report and have the report write to a file. All you need to do is to put your write command on the report sections. This was how we did it in the 2.x before Excel Buffer came out.

    You can search the forums on how to write to a file using reports.

    Hope this helps you. :mrgreen:
  • dohertyk
    dohertyk Member Posts: 94
    Savatage wrote:
    It's actually Report 10040 you're talking about - not form.

    Aged Accounts Receivable.

    This was not useful to you?
    http://www.mibuso.com/forum/viewtopic.php?p=72130

    I looks like a huge job but if you put al that code in your dataport - I guess it would work. But it's easier to export it to excel and save it as a csv or text file. You can even do a macro that does it all in a click.

    Yes you are correct, it is Report 10040 that I was referring to Aged Accounts Receivable.

    However, I am still running into issue's, it's not as easy as just through this code into my dataport and I am fine. For whatever reason, I run into roadblocks when I do that.

    For example, when I put in the dataitem for Integer, it just keeps counting upwards when I go to compile the source code (counting lines), and all the work that I would have done to that point becomes useless.. Because I can sit there all day while it counts records. And it no longer works for me.

    Basically I am creating a text file that has a pile of information that is going to be sent to a credit reporting agency, such as Dun & Bradstreet or Experian or TransUnion Credit. And the very last little bit of information that I am working on is the 30, 60, 90 day buckets that they want to have in their text file. (not an excel file)

    Thanks for any assistance that you can help me out with in this regard. This is a huge thing for a guy who has less then 50 days experience with Navision. But I am working through it and doing my best. I know that I'll get there too.. but I am just hoping sooner rather then later, if you know what I mean.

    Thanks again.

    Sincerely,

    Kevin
  • Savatage
    Savatage Member Posts: 7,142
    Savatage wrote:
    But it's easier to export it to excel and save it as a csv or text file.

    I think you're reinventing the wheel :-k
  • Alex_Chow
    Alex_Chow Member Posts: 5,063
    Savatage wrote:
    Savatage wrote:
    But it's easier to export it to excel and save it as a csv or text file.

    I think you're reinventing the wheel :-k

    I think he wants to program it so it adheres to a certain format after the export. It probably doesn't make sense for him to format it everytime the information needs to be sent to the financial institution.
  • Alex_Chow
    Alex_Chow Member Posts: 5,063
    Kevin,

    Search the forum to find out how to write data into .txt or .csv file from a report. It'll make your life a whole lot easier than trying to duplicate the aging report using a dataport.
  • Savatage
    Savatage Member Posts: 7,142
    I was playing around with Outstream
    from http://www.mibuso.com/forum/viewtopic.php?t=8853

    If you put this on the customer onaftergetrecord (as the last thing) you can see a quick sample of what it does
    cr:=13; 
    lf:=10; 
    crlf:=FORMAT(cr)+FORMAT(lf); 
    AmtDueTest1 := FORMAT(AmountDue[1]);
    AmtDueTest2 := FORMAT(AmountDue[2]);
    AmtDueTest3 := FORMAT(AmountDue[3]);
    AmtDueTest4 := FORMAT(AmountDue[4]);
    
    Stream.WRITETEXT(crlf);
    Stream.WRITETEXT(Customer."No."+'~');
    Stream.WRITETEXT(AmtDueTest1+'~');
    Stream.WRITETEXT(AmtDueTest2+'~');
    Stream.WRITETEXT(AmtDueTest3+'~');
    Stream.WRITETEXT(AmtDueTest4');
    

    OnInitReport()
    ExportFile.TEXTMODE(FALSE);
    ExportFile.CREATE('c:\test.txt');
    ExportFile.CREATEOUTSTREAM(Stream);

    OnPostReport()
    ExportFile.CLOSE;

    Variables
    CR: char
    LF: char
    CRLF : text(2)
    ExportFile: file
    Stream: OutStream
    AmtDueTest1 : text
    AmtDueTest2 : text
    AmtDueTest3 : text
    AmtDueTest4 : text
  • David_Singleton
    David_Singleton Member Posts: 5,479
    I have just been playing with 5.00, (see my blog) with the new export to Excel feature, you can create a Form that basically looks like the excel report that you want, and then it will create a spread sheet from it. I am not sure when you need this, but it would only require a Technical Upgrade, so you could implement it as soon as 5.00 is available.

    Kamil (kine) will soon be posting the technical details of how to do this.
    David Singleton
  • kine
    kine Member Posts: 12,562
    For example, when I put in the dataitem for Integer, it just keeps counting upwards when I go to compile the source code (counting lines), and all the work that I would have done to that point becomes useless.. Because I can sit there all day while it counts records. And it no longer works for me.
    You need to set some filter on the Integer in design time (for example "1.." filter in DataItemTableView) to prevent this neverending counting of integers... or you can disable the status dialog through ShowStatus property of the dataport.

    But, as deadlizard wrote - it is better to create one file variable, open the correct output file and write all values through C/AL code in OnPostSection of the report. You just needs to correctly create the line with separators and that's all. This is simples way. Or you can continue with your work and you can try to solve all the "roadblocks", but this can take you much more time than you have. Do not forget, that in many cases it is better to step back and go another way.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • dohertyk
    dohertyk Member Posts: 94
    Savatage wrote:
    I was playing around with Outstream
    from http://www.mibuso.com/forum/viewtopic.php?t=8853

    If you put this on the customer onaftergetrecord (as the last thing) you can see a quick sample of what it does
    cr:=13; 
    lf:=10; 
    crlf:=FORMAT(cr)+FORMAT(lf); 
    AmtDueTest1 := FORMAT(AmountDue[1]);
    AmtDueTest2 := FORMAT(AmountDue[2]);
    AmtDueTest3 := FORMAT(AmountDue[3]);
    AmtDueTest4 := FORMAT(AmountDue[4]);
    
    Stream.WRITETEXT(crlf);
    Stream.WRITETEXT(Customer."No."+'~');
    Stream.WRITETEXT(AmtDueTest1+'~');
    Stream.WRITETEXT(AmtDueTest2+'~');
    Stream.WRITETEXT(AmtDueTest3+'~');
    Stream.WRITETEXT(AmtDueTest4');
    

    OnInitReport()
    ExportFile.TEXTMODE(FALSE);
    ExportFile.CREATE('c:\test.txt');
    ExportFile.CREATEOUTSTREAM(Stream);

    OnPostReport()
    ExportFile.CLOSE;

    Variables
    CR: char
    LF: char
    CRLF : text(2)
    ExportFile: file
    Stream: OutStream
    AmtDueTest1 : text
    AmtDueTest2 : text
    AmtDueTest3 : text
    AmtDueTest4 : text

    Thank you very much, this works out perfectly for what I needed it to do. Now I am just going to re-do everything else that I had done, so that I am not "re-inventing the wheel". Although many of you have encouraged me to do an export to excel, it's just not practical for this particular application.

    I do appreciate all of your input and guidance as I am learning and I am sure that I will be back in no time asking more questions and I look forward to gaining more assistance from you in the future. And when the time comes where I can help you, you can look forward to my answers.

    Thanks again,

    Kevin
  • Alex_Chow
    Alex_Chow Member Posts: 5,063
    Glad you've found your way. Don't forget to come back and post your solution and mark this topic as [SOLVED]! :D