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.
I know it has been discussed before but after scanning through search results, did not find any solution giving the exact output I am looking for. Hence my question.
I need row values of a column turn to a single column, single row value separated by comma. Before I try this via SQL, hoping there a is a good simple Focus way.
Thanks in advance!This message has been edited. Last edited by: Tamra,
WebFocus 8.1 Service Pack 0.5 Build Version branch8105 Build/GEN Number 119
OS/Platform: Apache Tomcat/8.0.21
Posts: 46 | Location: Baltimore | Registered: October 27, 2016
TABLE FILE CAR SUM COMPUTE CNTR/I5 = CNTR + 1; COUNTRY BY COUNTRY NOPRINT ON TABLE HOLD AS HLD01 FORMAT ALPHA END -RUN TABLE FILE HLD01 PRINT COMPUTE ALL_CNTRY/A300V = IF CNTR EQ 1 THEN COUNTRY ELSE ALL_CNTRY || ', ' | COUNTRY; BY TOTAL HIGHEST 1 CNTR NOPRINT END -RUN
WebFocus 8.201M, Windows, App Studio
Posts: 227 | Location: Lincoln Nebraska | Registered: August 12, 2008
DEFINE FILE CAR POINTER/A10 = LAST COUNTRY; END TABLE FILE CAR PRINT COMPUTE CLIST/A100 = IF POINTER NE '' THEN COUNTRY || ',' ELSE COUNTRY; ACROSS HIGHEST COUNTRY NOPRINT END -RUN
TABLE FILE CAR
PRINT
COUNTRY
BY COUNTRY NOPRINT
ON TABLE HOLD AS HOLD1 FORMAT ALPHA
END
-RUN
-SET &XLINES = &LINES;
-SET &CNTR = 0;
-SET &COUNTRY_OUT = '';
-SET &COUNTRY = '';
-REPEAT GET_DATA &XLINES TIMES
-READ HOLD1 NOCLOSE &COUNTRY.A10.
-SET &CNTR = &CNTR + 1;
-SET &COUNTRY_OUT = IF &CNTR EQ 1 THEN &COUNTRY || ',' ELSE
- IF &CNTR EQ &XLINES THEN &COUNTRY_OUT || &COUNTRY ELSE &COUNTRY_OUT || &COUNTRY || ',';
-GET_DATA
-TYPE &COUNTRY_OUT
-EXIT
Tom,
I tried this method. It gives me the row values in the continuous format separated by comma. But also has other values/text as shown below. Also the number 000039 is appearing in front of all values. I just want the data like so. dynamic text place holder for graph J03, dynamic text place holder for graph J06, dynamic text place holder for graph J07
Can you suggest the changes?
Your request did not return any output to display.
Possible causes:
- No data rows matched the specified selection criteria.
- Output was directed to a destination such as a file or printer.
- An error occurred during the parsing or running of the request.
--------------------------------------------------------------------------------
0 NUMBER OF RECORDS IN TABLE= 3 LINES= 3
000039dynamic text place holder for graph J03,000039dynamic text place holder for graph J06,000039dynamic text place holder for graph J07
WebFocus 8.1 Service Pack 0.5 Build Version branch8105 Build/GEN Number 119
OS/Platform: Apache Tomcat/8.0.21
Posts: 46 | Location: Baltimore | Registered: October 27, 2016
Also the number 000039 is appearing in front of all values
Sandeep,
Does the column that you used (the COUNTRY field used by Tom in his sample) is a variable length field (something such as A39V) ?
Tom sample code will work properly with fix length field (A39). The 000039 is the length of the field used on your side.
If you use Tom's sample as below, you will see a 000010 in front of each value:
TABLE FILE CAR
PRINT
COUNTRY/A10V
BY COUNTRY NOPRINT
ON TABLE HOLD AS HOLD1 FORMAT ALPHA
END
-RUN
-SET &XLINES = &LINES;
-SET &CNTR = 0;
-SET &COUNTRY_OUT = '';
-SET &COUNTRY = '';
-REPEAT GET_DATA &XLINES TIMES
-READ HOLD1 NOCLOSE &COUNTRY.A10.
-SET &CNTR = &CNTR + 1;
-SET &COUNTRY_OUT = IF &CNTR EQ 1 THEN &COUNTRY || ',' ELSE
- IF &CNTR EQ &XLINES THEN &COUNTRY_OUT || &COUNTRY ELSE &COUNTRY_OUT || &COUNTRY || ',';
-GET_DATA
-TYPE &COUNTRY_OUT
-EXIT
Martin,
the column I am using is A256V in the mfd. I checked the length of the current value in the column. It is 39. Some how that's value that is being written in the output. Not sure why. Can you suggest what changes to make to get the desired output? Thank you.
WebFocus 8.1 Service Pack 0.5 Build Version branch8105 Build/GEN Number 119
OS/Platform: Apache Tomcat/8.0.21
Posts: 46 | Location: Baltimore | Registered: October 27, 2016
If you are using a variable column length (A256V), Tom's technique will display the field length as the first characters before the text value in the output.
The column as to be a fixed value to avoid the display of its length in the result.
Or another solution is to use READFILE instead of READ such as below. In my sample I change the format of COUNTRY from a fix length of A10 to variable length of A10V (just for purpose of the sample) but the result is properly displayed using READFILE
TABLE FILE CAR
PRINT COUNTRY/A10V
BY COUNTRY NOPRINT
ON TABLE HOLD AS HOLD1
END
-RUN
-SET &XLINES = &LINES;
-SET &CNTR = 0;
-SET &COUNTRY_OUT = '';
-SET &COUNTRY = '';
-REPEAT GET_DATA &XLINES TIMES
-READFILE HOLD1
-SET &CNTR = &CNTR + 1;
-SET &COUNTRY_OUT = IF &CNTR EQ 1 THEN &COUNTRY || ',' ELSE
- IF &CNTR EQ &XLINES THEN &COUNTRY_OUT || &COUNTRY ELSE &COUNTRY_OUT || &COUNTRY || ',';
-GET_DATA
-TYPE &COUNTRY_OUT
-EXIT
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013
-DEFAULTH &VAL_STR = ''
TABLE FILE CAR
SUM COMPUTE CNTR = LAST CNTR + 1; NOPRINT
COMPUTE COMMA/A1 = IF CNTR EQ 1 THEN '' ELSE ','; NOPRINT
COMPUTE VAL_STR/A100V = LAST VAL_STR || COMMA || LJUST(12, COUNTRY, 'A12V');
BY COUNTRY NOPRINT
ON TABLE HOLD AS TEMPHLD1
END
-RUN
TABLE FILE TEMPHLD1
SUM LST.VAL_STR
ON TABLE HOLD AS TEMPHLD2
END
-RUN
-READFILE TEMPHLD2
-SET VAL_STR = TRUNCATE(&VAL_STR);
-TYPE &|VAL_STR = &VAL_STR
Hallway
Prod: 8202M1
Test: 8202M4
Repository:
OS:
Outputs:
Posts: 608 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015
The secret is the use of READFILE instead of READ If you perform the below (your sample with a READ instead of READFILE), your result will show the 000039 at the beginning Also, no need to specify the TEMPHLD2 format with a READFILE.
-DEFAULTH &VAL_STR = ''
TABLE FILE CAR
SUM COMPUTE CNTR = LAST CNTR + 1; NOPRINT
COMPUTE COMMA/A1 = IF CNTR EQ 1 THEN '' ELSE ','; NOPRINT
COMPUTE VAL_STR/A100V = LAST VAL_STR || COMMA || LJUST(12, COUNTRY, 'A12V');
BY COUNTRY NOPRINT
ON TABLE HOLD AS TEMPHLD1
END
-RUN
TABLE FILE TEMPHLD1
SUM LST.VAL_STR
ON TABLE HOLD AS TEMPHLD2 FORMAT ALPHA
END
-RUN
-READ TEMPHLD2 &VAL_STR.A100
-SET &VAL_STR = TRUNCATE(&VAL_STR);
-TYPE &|VAL_STR = &VAL_STR
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013
I tried both of your versions. Martin's code does not give me any output. Hallway's code shows the values but still have the format length in front of it. I have pasted both the codes below and also the output.
Martin's Code
TABLE FILE MFD
PRINT
GRAPH_COMMENTS/A256V
BY GRAPH_COMMENTS NOPRINT
WHERE ( MFD.MFD.DF_AGENCY EQ &CF_AGENCY.(OR(FIND DF_AGENCY,MFD.MFD.DF_AGENCY IN MFD)).CF_AGENCY. ) AND
( MFD.MFD.DF_YEAR EQ CURRENTCY_INT ) AND
( MFD.MFD.CF_MONTH_INT LE CURRENTAYINT_LATEST ) AND
( MFD.MFD.GRAPH_NO EQ '1.1' );
ON TABLE HOLD AS HOLD1 FORMAT ALPHA
END
-RUN
-SET &XLINES = &LINES;
-SET &CNTR = 0;
-SET &COUNTRY_OUT = '';
-SET &COUNTRY = '';
-REPEAT GET_DATA &XLINES TIMES
-READFILE HOLD1
-SET &CNTR = &CNTR + 1;
-SET &COUNTRY_OUT = IF &CNTR EQ 1 THEN &COUNTRY || ',' ELSE
- IF &CNTR EQ &XLINES THEN &COUNTRY_OUT || &COUNTRY ELSE &COUNTRY_OUT || &COUNTRY || ',';
-GET_DATA
-TYPE &COUNTRY_OUT
-*ON TABLE HOLD AS HOLD2 FORMAT FLEX
-EXIT
Output:
0 NUMBER OF RECORDS IN TABLE= 3 LINES= 3
,,
Hallway's Code
-DEFAULTH &VAL_STR = ''
TABLE FILE MFD
SUM COMPUTE CNTR = LAST CNTR + 1; NOPRINT
COMPUTE COMMA/A1 = IF CNTR EQ 1 THEN '' ELSE ','; NOPRINT
COMPUTE VAL_STR/A256V = LAST VAL_STR || COMMA || LJUST(256, GRAPH_COMMENTS, 'A256V');
BY GRAPH_COMMENTS NOPRINT
WHERE ( MFD.MFD.DF_AGENCY EQ &CF_AGENCY.(OR(FIND DF_AGENCY,MFD.MFD.DF_AGENCY IN MFD)).CF_AGENCY. ) AND
( MFD.MFD.DF_YEAR EQ CURRENTCY_INT ) AND
( MFD.MFD.CF_MONTH_INT LE CURRENTAYINT_LATEST ) AND
( MFD.MFD.GRAPH_NO EQ '1.1' );
ON TABLE HOLD AS TEMPHLD1
END
-RUN
TABLE FILE TEMPHLD1
SUM LST.VAL_STR
ON TABLE HOLD AS TEMPHLD2 FORMAT ALPHA
END
-RUN
-READ TEMPHLD2 &VAL_STR.A256
-SET &VAL_STR = TRUNCATE(&VAL_STR);
-TYPE &|VAL_STR = &VAL_STR
-EXIT
Output:
0 NUMBER OF RECORDS IN TABLE= 3 LINES= 3
0 NUMBER OF RECORDS IN TABLE= 3 LINES= 1
&VAL_STR = 000256dynamic text place holder for graph J03,dynamic text place holder for graph J06,dynamic text place holder for graph J07
The output I am looking for is just the text.
Desired Output:
dynamic text place holder for graph J03,dynamic text place holder for graph J06,dynamic text place holder for graph J07
Can you please suggest the changes in the code? Thanks.
WebFocus 8.1 Service Pack 0.5 Build Version branch8105 Build/GEN Number 119
OS/Platform: Apache Tomcat/8.0.21
Posts: 46 | Location: Baltimore | Registered: October 27, 2016
TABLE FILE MFD PRINT GRAPH_COMMENTS/A256V BY GRAPH_COMMENTS NOPRINT WHERE ( MFD.MFD.DF_AGENCY EQ &CF_AGENCY.(OR(FIND DF_AGENCY,MFD.MFD.DF_AGENCY IN MFD)).CF_AGENCY. ) AND ( MFD.MFD.DF_YEAR EQ CURRENTCY_INT ) AND ( MFD.MFD.CF_MONTH_INT LE CURRENTAYINT_LATEST ) AND ( MFD.MFD.GRAPH_NO EQ '1.1' ); ON TABLE HOLD AS HOLD1 FORMAT ALPHA END...
Must be
TABLE FILE MFD
PRINT
GRAPH_COMMENTS
BY GRAPH_COMMENTS NOPRINT
WHERE ( MFD.MFD.DF_AGENCY EQ &CF_AGENCY.(OR(FIND DF_AGENCY,MFD.MFD.DF_AGENCY IN MFD)).CF_AGENCY. ) AND
( MFD.MFD.DF_YEAR EQ CURRENTCY_INT ) AND
( MFD.MFD.CF_MONTH_INT LE CURRENTAYINT_LATEST ) AND
( MFD.MFD.GRAPH_NO EQ '1.1' );
ON TABLE HOLD AS HOLD1
END
...
If GRAPH_COMMENTS is already a fix length don't change it to a variable length. And if it's a variable length, no need to change it again in variable length. In my sample I have changed the format of COUNTRY to A10V because IB sample files don't have variable length.
With READFILE you don't need to reformat the field at all. READFILE will manage the length.
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013
If GRAPH_COMMENTS is already a fix length don't change it to a variable length. And if it's a variable length, no need to change it again in variable length. In my sample I have changed the format of COUNTRY to A10V because IB sample files don't have variable length.
With READFILE you don't need to reformat the field at all. READFILE will manage the length.
Martin, The graph_comments column is a variable length column.
I used your original code but it is not retuning any data. It only gives output like I had posted in above reply. No values appearing only the commas. What do you suggest. Also in the response I only need the text as output. How do I get rid of the system generated text. Please see the output I had pasted above. Thank you.
TABLE FILE MFD
PRINT
GRAPH_COMMENTS
BY GRAPH_COMMENTS NOPRINT
WHERE ( MFD.MFD.DF_AGENCY EQ &CF_AGENCY.(OR(FIND DF_AGENCY,MFD.MFD.DF_AGENCY IN MFD)).CF_AGENCY. ) AND
( MFD.MFD.DF_YEAR EQ CURRENTCY_INT ) AND
( MFD.MFD.CF_MONTH_INT LE CURRENTAYINT_LATEST ) AND
( MFD.MFD.GRAPH_NO EQ '1.1' );
ON TABLE HOLD AS HOLD1
END
-RUN
-SET &XLINES = &LINES;
-SET &CNTR = 0;
-SET &COUNTRY_OUT = '';
-SET &COUNTRY = '';
-REPEAT GET_DATA &XLINES TIMES
-READFILE HOLD1
-SET &CNTR = &CNTR + 1;
-SET &COUNTRY_OUT = IF &CNTR EQ 1 THEN &COUNTRY || ',' ELSE
- IF &CNTR EQ &XLINES THEN &COUNTRY_OUT || &COUNTRY ELSE &COUNTRY_OUT || &COUNTRY || ',';
-GET_DATA
-TYPE &COUNTRY_OUT
-EXIT
WebFocus 8.1 Service Pack 0.5 Build Version branch8105 Build/GEN Number 119
OS/Platform: Apache Tomcat/8.0.21
Posts: 46 | Location: Baltimore | Registered: October 27, 2016
Alternatively you can use Frans' solution difference is that this is done in one TABLE request and using comma delimited output to put the comma's:
Frans,
I tried your steps. It gives the values but I get it in column format. I needed the values as continuous text separated by comma. Here is the code I used. How do I change it to only text format.
FILEDEF HOLD DISK hold.csv
TABLE FILE MFD
SUM
MAX.MFD.MFD.GRAPH_COMMENTS
ACROSS MFD.MFD.GRAPH_COMMENTS NOPRINT
WHERE ( MFD.MFD.DF_AGENCY EQ &CF_AGENCY.(OR(FIND DF_AGENCY,MFD.MFD.DF_AGENCY IN MFD)).CF_AGENCY. ) AND
( MFD.MFD.DF_YEAR EQ CURRENTCY_INT ) AND
( MFD.MFD.CF_MONTH_INT LE CURRENTAYINT_LATEST ) AND
( MFD.MFD.GRAPH_NO EQ '1.1' );
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
END
-RUN
-READ HOLD &VAL_STR.A256.
-TYPE &VAL_STR
-SET &VAL_STRING_STRIPPED = STRIP(&VAL_STR.LENGTH, &VAL_STR.QUOTEDSTRING, '"', 'A&VAL_STR.LENGTH');
-TYPE &VAL_STRING_STRIPPED
-EXIT
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDA/_EDAHOME/ETC/endeflt.sty,
$
TYPE=REPORT,
BORDER=OFF,
$
WebFocus 8.1 Service Pack 0.5 Build Version branch8105 Build/GEN Number 119
OS/Platform: Apache Tomcat/8.0.21
Posts: 46 | Location: Baltimore | Registered: October 27, 2016
Originally posted by Tom Flynn: Too many cooks in the kitchen, although, you've been shown the many ways to climb the WebFOCUS mountain...
Tom,
I am thankful to all the great cooks for helping me out in preparing the webfocus soufflé . Have learned a lot. I tried your modified code and I am almost there. The values are coming correctly as continuous text with comma. But the output also comes with the below shown text. How to get rid of it and have just the values? Can you please suggest? Thanks.
Your request did not return any output to display.
Possible causes:
- No data rows matched the specified selection criteria.
- Output was directed to a destination such as a file or printer.
- An error occurred during the parsing or running of the request.
--------------------------------------------------------------------------------
0 NUMBER OF RECORDS IN TABLE= 3 LINES= 3
WebFocus 8.1 Service Pack 0.5 Build Version branch8105 Build/GEN Number 119
OS/Platform: Apache Tomcat/8.0.21
Posts: 46 | Location: Baltimore | Registered: October 27, 2016
Alternatively you can use Frans' solution difference is that this is done in one TABLE request and using comma delimited output to put the comma's:
Frans,
I tried your steps. It gives the values but I get it in column format. I needed the values as continuous text separated by comma. Here is the code I used. How do I change it to only text format.
Because you used it a bit differently, here is how it works:
FILEDEF HOLD DISK hold.csv (LRECL 200 RECFM v
TABLE FILE MFD
SUM
MAX.MFD.MFD.GRAPH_COMMENTS
ACROSS MFD.MFD.GRAPH_COMMENTS NOPRINT
WHERE ( MFD.MFD.DF_AGENCY EQ &CF_AGENCY.(OR(FIND DF_AGENCY,MFD.MFD.DF_AGENCY IN MFD)).CF_AGENCY. ) AND
( MFD.MFD.DF_YEAR EQ CURRENTCY_INT ) AND
( MFD.MFD.CF_MONTH_INT LE CURRENTAYINT_LATEST ) AND
( MFD.MFD.GRAPH_NO EQ '1.1' );
ON TABLE HOLD FORMAT COM
END
-RUN
-READ HOLD &VAL_STR.A256.
-TYPE &VAL_STR
-SET &VAL_STRING_STRIPPED = STRIP(&VAL_STR.LENGTH, &VAL_STR.QUOTEDSTRING, '"', 'A&VAL_STR.LENGTH');
-TYPE &VAL_STRING_STRIPPED
-EXIT
Your request did not return any output to display. Possible causes: - No data rows matched the specified selection criteria. - Output was directed to a destination such as a file or printer. - An error occurred during the parsing or running of the request.
As far as I know, the above is not an error. It just telling you that you are not processing any displayable report since in your case, reason #2 is the cause. It is just an warning.
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013
I agree, this is not an error. I assume it shows when the output is not coming from TABLE or a GRAPH. How do i get the values from &VAL_STRING_STRIPPED only?
WebFocus 8.1 Service Pack 0.5 Build Version branch8105 Build/GEN Number 119
OS/Platform: Apache Tomcat/8.0.21
Posts: 46 | Location: Baltimore | Registered: October 27, 2016