Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   AFS/DDC/OLE: Function servers (http://www.baanboard.com/baanboard/forumdisplay.php?f=59)
-   -   Unable to output a file with Device (re-write file) (http://www.baanboard.com/baanboard/showthread.php?t=70124)

VishalMistry 20th June 2017 14:29

Unable to output a file with Device (re-write file)
 
1 Attachment(s)
Hello All,

This is for Baan IV

I want to call Print Purchase Order session (tdpur4401m000) for a range of supplier. I am selecting a Device with Re-write file type . I am specifically setting spool.fileout variable but the system is not generating the file at given path with given name. It is not generating any file.

The status of purchase order properly set to tdpur045.spur = 3

Can anybody guide what could be wrong in the given code ?

Vishal

mark_h 21st June 2017 13:15

From the looks of the code the supplier from and to are the same so only one PO would go out to the file. Second before I do a set.report I typically set spool.device to something specific and then spool.fileout to a file name. Quick example is something like this:
Code:


                spool.device = "ASCIF"
                spool.fileout = creat.tmp.file$(bse.tmp.dir$())
                print_goods_received(purchase.order,tdpur.kofl.inc.printed,errmsg)


mark_h 21st June 2017 13:18

I forgot to mention - that there have been times where I want to run the same session in 4c4 repeatedly and put the output to a new file. When I do that the spool.fileout does not always change - so for example if I ran the above code in a look even creating a new temp file the output would always end up in the first file I created. To get past his what I ended up doing in a couple of cases was importing spool.device (using code extender qkey) and spool.fileout into the called session - that solved my problems.

VishalMistry 21st June 2017 15:56

Hello Mark,

Thanks for your guidance. I was able to generate file after using spool.close() before stpapi.end.session(). Once, the file is generated in temp folder, i just rename it using file.mv(fileout, CURRDATE_BATCH_SUNO). The problem is that it does not generate file for another supplier (obviously as spooler is closed before calling stpapi.end.session).

Vishal

VishalMistry 22nd June 2017 09:44

Success in generating supplier-wise report
 
1 Attachment(s)
Hi Mark,

I was able to successfully generate a separate file for every vendor.

The mistake I was making is I had kept the stpapi.end.session() inside the loop. I kept the spool.close() inside the loop and moved out stpapi.end.session() and it worked.

I have attached sample script if anybody encounters the similar issue.

Vishal


All times are GMT +2. The time now is 12:57.


vB.Sponsors
©2001-2017 - Baanboard.com - Baanforums.com