Focal Point
need help for footer in csv output format [SOLVED]

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8777051186

March 08, 2016, 08:20 AM
sumant
need help for footer in csv output format [SOLVED]
Hi All,

I have a requirement in which the output needs to be csv ( the file will be fed to another system as a feed file). The users want header and a footer with the number of records in it.
I have gone through other topics in the forum and saw the threads.

In this case, the csv file needs to be saved and when I save it, the footer and header disappear.

The following is my code:

FILEDEF testfile DISK testfile.CSV (APPEND
-RUN

-WRITE testfile Country,Car,Model,Rcost,Dcost

TABLE FILE CAR
PRINT
RCOST
DCOST
BY COUNTRY
BY CAR
BY MODEL
ON TABLE PCHOLD AS testfile FORMAT COMMA
END
-RUN
-WRITE testfile There are &LINES Records in this file
CMD TYPE testfile.csv

Thanks for reading.

This message has been edited. Last edited by: sumant,


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
March 08, 2016, 08:36 AM
BabakNYC
Switch your hold format to COMT. That keeps the column headings in the output. I believe you should also switch from PCHOLD to HOLD.

ON TABLE HOLD AS testfile FORMAT COMT

If you want to keep your FILEDEF APPEND with your own titles, just switch from PCHOLD to HOLD and your code will work.


WebFOCUS 8206, Unix, Windows
March 08, 2016, 08:40 AM
sumant
Thanks BabakNYC for the suggestion.
I need the file saved on a physical directory, and the issue arises when I save it.
As soon as I open the saved file, it loses all its headers and footers.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
March 08, 2016, 08:41 AM
BabakNYC
Switch from PCHOLD to HOLD. I just tested your code with HOLD and it works.


WebFOCUS 8206, Unix, Windows
March 08, 2016, 08:45 AM
sumant
When I switch from PCHOLD to HOLD, the output is displayed on the screen.
I need the output to be saved on my machine, as another system needs this file as input.

Am I missing something?


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
March 08, 2016, 08:54 AM
BabakNYC
I just tested this in 8105 and got a csv file on my E: drive. It also displays on my screen because of CMD TYPE E:\testfile.csv.
FILEDEF testfile DISK E:\testfile.CSV (APPEND
-RUN

-WRITE testfile Country,Car,Model,Rcost,Dcost

TABLE FILE CAR
PRINT
RCOST
DCOST
BY COUNTRY
BY CAR
BY MODEL
ON TABLE HOLD AS testfile FORMAT COMMA
END
-RUN
-WRITE testfile There are &LINES Records in this file
CMD TYPE E:\testfile.csv



WebFOCUS 8206, Unix, Windows
March 08, 2016, 09:15 AM
Tom Flynn
The WF Reporting server has no idea where "YOUR" machine is. We FILEDEF with an address of:
d:\ibi\apps\hold_area_for_files\

Your IBI install may be on a different drive.

If you APPEND right off the bat, the next time its run will retain the data from the previous run.

Store the file on the server, or, on a NFS drive, then FTP/EMAIL.

  
FILEDEF testfile DISK d:/ibi/apps/baseapp/testfile.csv  
-RUN

-WRITE testfile Country,Car,Model,Rcost,Dcost

FILEDEF testfile DISK d:/ibi/apps/baseapp/testfile.csv (APPEND
-RUN

TABLE FILE CAR
PRINT
RCOST
DCOST
BY COUNTRY
BY CAR
BY MODEL
ON TABLE HOLD AS testfile FORMAT COMMA
END
-RUN
FILEDEF testfile DISK d:/ibi/apps/baseapp/testfile.csv (APPEND
-RUN

-WRITE testfile There are &LINES Records in this file
-CLOSE testfile
-EXIT


EDIT: Didn't have the FILEDEF coded correctly, works now...

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
March 08, 2016, 09:33 AM
sumant
Thanks a lot Tom and babakNYC for your inputs.
I understood that the web focus server has no idea of my machine.
So I created a temporary folder in my C:\ibi\apps\testing and tried to run the procedure.

I get (FOC340) DIALOGUE MANAGER -WRITE FILE NOT ALLOCATED OR FILEDEF'ED

Is it related to permissions?
I have not used filedef earlier and hence the trouble...


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
March 08, 2016, 09:35 AM
Tom Flynn
Use the example I gave above; I had mis-coded some things. the above example now works.


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
March 08, 2016, 09:46 AM
sumant
Thanks Tom for correcting your code.
I tried it and still get (FOC340) DIALOGUE MANAGER -WRITE FILE NOT ALLOCATED OR FILEDEF'ED .

From the message I understand that the path I am giving c:/ibi/apps/testfile.csv is not the right path for writing the testfile.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
March 08, 2016, 09:49 AM
Tom Flynn
At the top of the FEX, do
? PATH
-EXIT

This will tell you the DRIVE:\Folder\Structure of your IBI install...

Code accordingly...


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
March 08, 2016, 10:04 AM
sumant
Thanks Tom for your help on this.
I have a shared location which is mapped and was able to send the test file there.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF