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] Trouble with Append

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Trouble with Append
 Login/Join
 
Silver Member
posted
Hey guys,

I have a unique situation where I need to create a tab delimited file and append a header and trailer record to it. Here is my best approximation of what this looks like using the CAR File:

-DEFAULT &R_YR = 2015;

-RUN
-UNIX rm /home/webfocust/Finaid/111111_test_file.tab
FILEDEF EOYFILE DISK /home/webfocust/Finaid/111111_test_file.tab (LRECL 267 RECFM V APPEND

DEFINE FILE CAR
REPORT_TYPE/A4 = 'AAAA';
CODE/I6L = 029269;
R_YEAR/I4 = &R_YR.Year.;
1_SSN/I9L = 123456789;
2_ID_TYPE/I1 = 2;
3_BIRTHDATE/I8L = 11111990;
4_LAST_NAME/A30 = 'Test';
5_FIRST_NAME/A30 = 'Case';
6_MI_NAME/A1 = 'A';
CNT/I5L = IF COUNTRY NE LAST COUNTRY THEN 1 ELSE 0;
END
-* Getting the header record
TABLE FILE CAR
SUM
FST.REPORT_TYPE
FST.CODE
FST.R_YEAR
WHERE RECORDLIMIT EQ 1
BY COUNTRY NOPRINT
ON TABLE HOLD AS EOYFILE FORMAT TAB
END
-* Appending the data
TABLE FILE CAR
PRINT
1_SSN
2_ID_TYPE
3_BIRTHDATE
4_LAST_NAME
5_FIRST_NAME
6_MI_NAME
BY COUNTRY
ON TABLE HOLD AS EOYFILE FORMAT TAB
END
-* Creating data for the footer record
TABLE FILE CAR
SUM
CNT
ON TABLE HOLD AS HOLD1
END
-* Appending the footer record
DEFINE FILE HOLD1
TRAILER_ID/A4 = 'BBBB';
RECORD_COUNT/I5L = CNT;
WHERE RECORDLIMIT EQ 1
ON TABLE HOLD AS EOYFILE FORMAT TAB
END

TABLE FILE EOYFILE
PRINT *
ON TABLE PCHOLD FORMAT TAB
END

There are specific reasons I can't just pull the file down from the server, so I need the final file to come from that final PRINT * ON TABLE PCHOLD FORMAT.

When I do it this way, the header and trailer records don't appear. I only end up with the main data set. I've tried looking in the help files for some guidance on how to work with append, but I couldn't find anything that relates to my specific situation. If there is something I've overlooked, please point me towards it. Does anyone have any ideas or advice on what I need to do?

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8.105M, Windows 10, App Studio
 
Posts: 47 | Registered: October 22, 2014Report This Post
Expert
posted Hide Post
Welcome to Focal Point! Smiler

If you are going to append data and rely upon the final HOLD request to build the MFD (synonym) from which to identify all your data, each table request would need to have the same number of columns.

There is also a problem in your sample code in your final define.

There are a couple of ways that you can achieve this.
  • ensure all table requests have the same number of columns of output.
  • concatenate all the required columns into a single column (use HEXBYT(9,'A1') for a TAB char I think) in each table request.


My preference would probably be the latter so try this code -
-DEFAULT &R_YR = 2015;
SET HOLDLIST = PRINTONLY

FILEDEF EOYFILE DISK 111111_test_file.tab (LRECL 267 RECFM V APPEND
-RUN

DEFINE FILE CAR
  REPORT_TYPE/A4 = 'AAAA';
  TRAILER_ID/A4 = 'BBBB';
  CODE/I6L = 029269;
  R_YEAR/I4 = &R_YR.Year.;
  1_SSN/I9L = 123456789;
  2_ID_TYPE/I1 = 2;
  3_BIRTHDATE/I8L = 11111990;
  4_LAST_NAME/A30 = 'Test';
  5_FIRST_NAME/A30 = 'Case';
  6_MI_NAME/A1 = 'A';
-*  CNT/I5L = IF COUNTRY NE LAST COUNTRY THEN 1 ELSE 0;
  HEADER_REC/A267V = REPORT_TYPE || HEXBYT(9, 'A1') || FPRINT(CODE, 'I6L', 'A6') || HEXBYT(9, 'A1') || FPRINT(R_YEAR, 'I4', 'A4');
END

-* Getting the header record
TABLE FILE CAR
SUM HEADER_REC
BY HIGHEST 1 COUNTRY NOPRINT
ON TABLE HOLD AS EOYFILE FORMAT ALPHA
END
-RUN

-* Appending the data
TABLE FILE CAR
PRINT COMPUTE CONTENT_REC/A267V = COUNTRY
            || HEXBYT(9, 'A1') || FPRINT(1_SSN, 'I9L', 'A9')
            || HEXBYT(9, 'A1') || FPRINT(2_ID_TYPE, 'I1', 'A1')
            || HEXBYT(9, 'A1') || FPRINT(3_BIRTHDATE, 'I8L', 'A8')
            || HEXBYT(9, 'A1') || 4_LAST_NAME
            || HEXBYT(9, 'A1') || 5_FIRST_NAME
            || HEXBYT(9, 'A1') || 6_MI_NAME;
BY COUNTRY NOPRINT
ON TABLE HOLD AS EOYFILE FORMAT ALPHA
END
-RUN

-* Appending the footer record
DEFINE FILE CAR ADD
  FOOTER_REC/A267V = TRAILER_ID || HEXBYT(9, 'A1') || FPRINT(&LINES, 'I5L', 'A5');
END

TABLE FILE CAR
SUM FOOTER_REC
BY HIGHEST 1 COUNTRY NOPRINT
ON TABLE HOLD AS EOYFILE FORMAT ALPHA
END
-RUN

TABLE FILE EOYFILE
PRINT *
ON TABLE PCHOLD FORMAT TAB
END
-RUN

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Silver Member
posted Hide Post
quote:
Originally posted by Tony A:
Welcome to Focal Point! Smiler

If you are going to append data and rely upon the final HOLD request to build the MFD (synonym) from which to identify all your data, each table request would need to have the same number of columns.

There is also a problem in your sample code in your final define.

There are a couple of ways that you can achieve this.
  • ensure all table requests have the same number of columns of output.
  • concatenate all the required columns into a single column (use HEXBYT(9,'A1') for a TAB char I think) in each table request.


My preference would probably be the latter so try this code -
-DEFAULT &R_YR = 2015;
SET HOLDLIST = PRINTONLY

FILEDEF EOYFILE DISK 111111_test_file.tab (LRECL 267 RECFM V APPEND
-RUN

DEFINE FILE CAR
  REPORT_TYPE/A4 = 'AAAA';
  TRAILER_ID/A4 = 'BBBB';
  CODE/I6L = 029269;
  R_YEAR/I4 = &R_YR.Year.;
  1_SSN/I9L = 123456789;
  2_ID_TYPE/I1 = 2;
  3_BIRTHDATE/I8L = 11111990;
  4_LAST_NAME/A30 = 'Test';
  5_FIRST_NAME/A30 = 'Case';
  6_MI_NAME/A1 = 'A';
-*  CNT/I5L = IF COUNTRY NE LAST COUNTRY THEN 1 ELSE 0;
  HEADER_REC/A267V = REPORT_TYPE || HEXBYT(9, 'A1') || FPRINT(CODE, 'I6L', 'A6') || HEXBYT(9, 'A1') || FPRINT(R_YEAR, 'I4', 'A4');
END

-* Getting the header record
TABLE FILE CAR
SUM HEADER_REC
BY HIGHEST 1 COUNTRY NOPRINT
ON TABLE HOLD AS EOYFILE FORMAT ALPHA
END
-RUN

-* Appending the data
TABLE FILE CAR
PRINT COMPUTE CONTENT_REC/A267V = COUNTRY
            || HEXBYT(9, 'A1') || FPRINT(1_SSN, 'I9L', 'A9')
            || HEXBYT(9, 'A1') || FPRINT(2_ID_TYPE, 'I1', 'A1')
            || HEXBYT(9, 'A1') || FPRINT(3_BIRTHDATE, 'I8L', 'A8')
            || HEXBYT(9, 'A1') || 4_LAST_NAME
            || HEXBYT(9, 'A1') || 5_FIRST_NAME
            || HEXBYT(9, 'A1') || 6_MI_NAME;
BY COUNTRY NOPRINT
ON TABLE HOLD AS EOYFILE FORMAT ALPHA
END
-RUN

-* Appending the footer record
DEFINE FILE CAR ADD
  FOOTER_REC/A267V = TRAILER_ID || HEXBYT(9, 'A1') || FPRINT(&LINES, 'I5L', 'A5');
END

TABLE FILE CAR
SUM FOOTER_REC
BY HIGHEST 1 COUNTRY NOPRINT
ON TABLE HOLD AS EOYFILE FORMAT ALPHA
END
-RUN

TABLE FILE EOYFILE
PRINT *
ON TABLE PCHOLD FORMAT TAB
END
-RUN

T


Incredible, this works exactly like I need it to. Thank you so much!


WebFOCUS 8.105M, Windows 10, App Studio
 
Posts: 47 | Registered: October 22, 2014Report This Post
Expert
posted Hide Post
Your post indicates that you are running on UNIX.

You could just write/hold the three files, but use unis cat to combine the files.

e.g.
Write/hold as tab1/2/3

! cat tab* > myfile.tab


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report 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] Trouble with Append

Copyright © 1996-2020 Information Builders