Baanboard.com

Go Back   Baanboard.com > Blogs > roylansink's blog

User login

Frontpage Sponsor

Main

Poll
As a Customer What would do to keep your ERP Implementation intact
Proactively define Business Process-- Take the Project Ownership
50%
Handover everything to System Integrator from drawing BP till implementation of ERP
0%
Hire more inhouse skilled & capable IT Resource to work directly with SI
50%
Rely on SI Architects/Consultants
0%
Total votes: 2

Baanboard at LinkedIn


Reference Content

 
spool report to second device
By roylansink at 7 Apr 2020 - 14:29

Hi All, 

 I'm trying to print a report to a second device. The idea is that with the print, the report is stored to a folder as well. 

The following code is used for testing purpose, but when I run the report, I get a blank notepad file. What am I doing wrong?  

<code>
after.report.1:
after.layout:

|Save original values
org.spool = spool.id
org.pr.line = spool.pr.line
org.fileout = spool.fileout

|Open extra spooler and print report
spool.id = spool.open("rtcmcs041011000","NOTEPAD",0)          
spool.line()
spool.close()   

|fill predefined vallues with original values 
spool.id = org.spool
spool.pr.line = org.pr.line  

</code> 

0
No votes yet

by bhushanchanda on April 7, 2020 - 4:42pm
bhushanchanda's picture
Moved the blog post to a thread in Tools Dev forum.

Can you please post a screenshot of your report layout? i.e. What sections do you have on your original report - e.g Header, Detail...

The way you are doing will not work because the spool is reserved for the first spool ID already.

You might need to call internal report script functions to trick the spooler.

e.g. r.1.s.header() for printing Header.

But first, it would be good to understand your report design.

by bhushanchanda on April 7, 2020 - 5:28pm
bhushanchanda's picture
You can try something like this - Tried this on session tcmcs0401m000

You might need to handle special report fields in your report script. But it works as far as creating a copy.

Code:
declaration:

extern long org.spool.id
extern long my.spool.id
extern string org.pr.line(1000)
extern string org.fileout(100)

extern domain tcbool header.printed

before.program:
   org.spool.id = spool.id
   my.spool.id = spool.open("rtc040101000","NOTEPAD",0)
   header.printed = false

detail.1:
after.receive.data:

   spool.id = my.spool.id
   if not header.printed then
      r.1.s.header()
      header.printed = true
   endif

   r.1.s.detail()
   spool.id = org.spool.id

after.program:
   spool.id = my.spool.id
   spool.close()
   spool.id = org.spool.id

And if your first device is also notepad or something which is writing a text/ascii file, you can simply use this code to copy the file to your destined location -

Code:
declaration:
after.receive.data:
   long ret
   string copied_file_path(100)

   copied_file_path = "E:\my_dir\copied_file.txt"
   ret = file.mv(spool.fileout,copied_file_path)


All times are GMT +2. The time now is 23:13.


©2001-2018 - Baanboard.com - Baanforums.com