Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How Can I Write 2 Header Lines on Delimited Output?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] How Can I Write 2 Header Lines on Delimited Output?
 Login/Join
 
Member
posted
I have to produce a pipe-delimited file that has TWO header lines. The first line has file information, the second is the names of the fields. Here's a sample

FH|AROpenRepairOrders|1|DL1|2012-08-11 00:15:06|Joe.Doe@hotmail.com|

Record Identifier|Service Order Number|Creation Date Time|Buyer ID|Part Number|Manufacturer Code|Unit Of Measure|Order Quantity|

HH|RO1234533|2012-01-11 00:15:06|JDoe445|320115|81205|EA|1|
HH|RO1234534|2012-01-11 12:15:06|JDoe442|320115|81205|EA|1|
HH|RO6234535|2012-01-11 13:15:06|JDoe440|320115|81205|EA|1|

I've tried using FILEDEF (APPEND with two HOLD commands. It seems to take either the first heading or the second. I've tried -WRITE and can't get it to work. Here's the current version of code:

FILEDEF H001 DISK H001.FTM
-RUN

SQL SQLORA PREPARE SQLOUT FOR
SELECT 'FH', 'AROpenRepairOrders','1.0','ACA',TO_CHAR(SYSTIMESTAMP, 'YYYY-MM-DD HH24:MI:SS'),'joe.doe@hotmail.com|' FROM DUAL
;
END

TABLE FILE SQLOUT
PRINT *
ON TABLE PCHOLD AS H001 FORMAT DFIX DELIMITER | HEADER NO
END
-RUN
-*
SQL SQLORA ALTER SESSION SET CURRENT_SCHEMA = ODB;
END
SQL SQLORA PREPARE SQLOUT FOR
.... long SQL here

FILEDEF H001 DISK H001.FTM (APPEND
-RUN

TABLE FILE SQLOUT
PRINT *
ON TABLE PCHOLD AS H001 FORMAT DFIX DELIMITER | HEADER YES
END
-RUN

This gives me the file header line, but not the field-names line. I am a neophyte and will be grateful for any help.

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


WebFOCUS 8.2.03
Windows
 
Posts: 5 | Location: Montreal, Canada | Registered: December 11, 2012Report This Post
Expert
posted Hide Post
You need to issue the FILEDEF twice, once to start, then once with APPEND for the rest:

FILEDEF H001 DISK H001.FTM
-RUN

TABLE FILE CAR
PRINT
COMPUTE HEADER/A100 = COUNTRY || '|' || 'JOE.DOE@HOTMAIL.COM';

WHERE COUNTRY EQ 'ENGLAND';

ON TABLE PCHOLD AS H001 FORMAT DFIX DELIMITER | HEADER NO
END
-RUN

FILEDEF H001 DISK H001.FTM (APPEND

TABLE FILE CAR
PRINT *
WHERE COUNTRY EQ 'ENGLAND'

ON TABLE PCHOLD AS H001 FORMAT DFIX DELIMITER | HEADER YES
END
-RUN

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Member
posted Hide Post
Thanks for your reply, Francis. I copied your code and the result I get is:

ENGLAND|JOE.DOE@HOTMAIL.COM
ENGLAND|JAGUAR|V12XKE AUTO|CONVERTIBLE|2|7427|8878|0|190|66|48|3435|105.0|18.0|241|5750|16|7
ENGLAND|JAGUAR|XJ12L AUTO|SEDAN|5|11194|13491|12000|199|70|54|4200|112.8|24.0|241|5750|9|9
ENGLAND|JENSEN|INTERCEPTOR III|SEDAN|4|14940|17850|0|188|69|53|4000|105.0|24.0|385|4700|11|8
ENGLAND|TRIUMPH|TR7|HARDTOP|2|4292|5100|0|165|66|50|2241|85.0|14.5|90|5000|25|0

I need to also produce a line after the first, containing the field names.

COUNTRY|CAR|MODEL|BODYTYPE|SEATS|DEALER_COST|RETAIL_COST|SALES|LENGTH|WIDTH|HEIGHT|WEIGHT|WHEELBASE|FUEL_CAP|BHP|RPM|MPG|ACCEL

Any ideas why it doesn't appear? It seems like the HEADER YES option should have produced it. If I comment out the part that produces the first line and just use the second, the field names ARE produced. So what's happening?


WebFOCUS 8.2.03
Windows
 
Posts: 5 | Location: Montreal, Canada | Registered: December 11, 2012Report This Post
Expert
posted Hide Post
It is strange, but it works for HOLD, but not for PCHOLD. I would open a case with Tech Support, providing the two examples.

Meanwhile, the workaround might be to use HOLD - if you can access the location on the reporting server where the FILEDEF can create a file...



This works:
FILEDEF H001 DISK baseapp/h001dfix.ftm
-RUN

TABLE FILE CAR
PRINT
COMPUTE HEADER/A100 = COUNTRY || '|' || 'joe.doe@hotmail.com';

WHERE COUNTRY EQ 'ENGLAND';

ON TABLE HOLD AS H001 FORMAT DFIX DELIMITER | HEADER NO
END
-RUN

FILEDEF H001 DISK baseapp/h001dfix.ftm (APPEND

TABLE FILE CAR
PRINT
COUNTRY
CAR
MODEL
LENGTH
WEIGHT
HEIGHT
WHERE COUNTRY EQ 'ENGLAND'

ON TABLE HOLD AS H001 FORMAT DFIX DELIMITER | HEADER YES
END
-RUN

Generates:
ENGLAND|joe.doe@hotmail.com
COUNTRY|CAR|MODEL|LENGTH|WEIGHT|HEIGHT
ENGLAND|JAGUAR|V12XKE AUTO|190|3435|48
ENGLAND|JAGUAR|XJ12L AUTO|199|4200|54
ENGLAND|JENSEN|INTERCEPTOR III|188|4000|53
ENGLAND|TRIUMPH|TR7|165|2241|50

This does not work:
FILEDEF H001 DISK h001dfix.ftm
-RUN

TABLE FILE CAR
PRINT
COMPUTE HEADER/A100 = COUNTRY || '|' || 'joe.doe@hotmail.com';

WHERE COUNTRY EQ 'ENGLAND';

ON TABLE PCHOLD AS H001 FORMAT DFIX DELIMITER | HEADER NO
END
-RUN

FILEDEF H001 DISK h001dfix.ftm (APPEND

TABLE FILE CAR
PRINT
COUNTRY
CAR
MODEL
LENGTH
WEIGHT
HEIGHT
WHERE COUNTRY EQ 'ENGLAND'

ON TABLE PCHOLD AS H001 FORMAT DFIX DELIMITER | HEADER YES
END
-RUN

Generates:
ENGLAND|joe.doe@hotmail.com
ENGLAND|JAGUAR|V12XKE AUTO|190|3435|48
ENGLAND|JAGUAR|XJ12L AUTO|199|4200|54
ENGLAND|JENSEN|INTERCEPTOR III|188|4000|53
ENGLAND|TRIUMPH|TR7|165|2241|50


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Guru
posted Hide Post
I guess as a workaround you could use the two HOLDs that Francis talks about. Then create a generic master so you can PCHOLD the output.
  
-* Allocate the flat file
FILEDEF H001 DISK h001.ftm (APPEND
-RUN

TABLE FILE CAR
PRINT
   COMPUTE HEADER/A100 = COUNTRY || '|' || 'JOE.DOE@HOTMAIL.COM';

WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS H001 FORMAT DFIX DELIMITER | HEADER NO
END
-RUN


TABLE FILE CAR
PRINT
   COUNTRY CAR MODEL BODYTYPE SEATS DEALER_COST RETAIL_COST SALES 
   LENGTH WIDTH HEIGHT WEIGHT WHEELBASE FUEL_CAP BHP RPM MPG ACCEL

WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS H001 FORMAT DFIX DELIMITER | HEADER YES
END
-RUN


-* Create master for flat file
FILEDEF HMAST DISK hdata.mas
-RUN

-WRITE HMAST FILENAME=HDATA, SUFFIX=DFIX, DATASET=h001.ftm, $
-WRITE HMAST SEGMENT=HDATA, SEGTYPE=S0, $
-WRITE HMAST FIELDNAME=COLUMN1, ALIAS=COLUMN1, USAGE=A4000, ACTUAL=A4000, $
-RUN


-* Output the flat file using PCHOLD
TABLE FILE HDATA
PRINT
   COLUMN1 AS ''
ON TABLE PCHOLD FORMAT DFIX DELIMITER | HEADER NO
END
-RUN


WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files
 
Posts: 320 | Location: Memphis, TN | Registered: February 12, 2008Report This Post
Member
posted Hide Post
Thank you Max and Francis, sorry for the delay responding.

Concatenating two files using HOLD, not PCHOLD, worked. I didn't know where to find the output but did eventually (I told you I was new at this).


WebFOCUS 8.2.03
Windows
 
Posts: 5 | Location: Montreal, Canada | Registered: December 11, 2012Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How Can I Write 2 Header Lines on Delimited Output?

Copyright © 1996-2020 Information Builders