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     Output of variable length comma delimited string to save file without trailing blanks

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Output of variable length comma delimited string to save file without trailing blanks
 Login/Join
 
Master
posted
Hi folks

Want to output a comma delimited string in true variable length format without the trailing blanks which pad up to the length of the field.

Tried defining the output string as A600V but this outputs the length descriptor and then still pads out the field. I'm doing an ON TABLE SAVE to generate the output.

Anyone know of an easy way to remove the trailing blanks within wf or a 3rd party bit of freeware that can be called in batch to do the job?

Best Regards

John



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
<RickW>
posted
You could use Dialogue Manager, -READ each row into a variable, use the TRUNCATE function, and write them into another file.
 
Report This Post
Expert
posted Hide Post
John,

How are you getting your output string? If I use the following code, I get an output string of length 45 (including double quotes) -
TABLE FILE CAR
SUM COUNTRY CAR MODEL RCOST DCOST
ON TABLE SAVE FORMAT COM
END
-RUN

Output is "FRANCE","PEUGEOT","504 4 DOOR",173204,143794

T

This message has been edited. Last edited by: Tony A,



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
Master
posted Hide Post
Hi Guys

Awesome answers. Was never aware of format COM till now.

Thanks

The downside is that I simplified things a bit when I said it was a comma delimited file - its actually a semi colon delimited file.

IFS_OUTPUT/A4000 = ';;' || GL1 || ';' || GL2 || ';' || GL2 || ';' || GL3 || ';;' || GL4 || ';' || GL5 || ';;;;' || HEAD_SETTLEMENT_CURRENCY || ';;;' || NEW_LINE_GROSS_AMOUNT_A || ';;;' || NEW_LINE_GROSS_AMOUNT_A || ';' || ITEM_QUANTITY || ';;' || IFS_VAT_RATE || ';' || GL2 || ';' || NEW_LINE_PURCHASE_DESC || '-' || SUPPLIER_NAME || ';;;;;;;' || NEW_POSTING_DATE || ';' || 'GROUP' ;
IFS_OUTPUT1/A600 = SUBSTR(4000,IFS_OUTPUT,1,600,600,'A600');
IFS_OUTPUT2/A600V = TRIMV('T',IFS_OUTPUT1,600,' ',1,'A600V');

The application I'm loading to unfortunately doesn't like the double quotes wf puts around the string when it's SAVE'd as format COM and I checked and there's no way round that.

I think I might go for one of those batch replacers. Already use BkReplacem which is freeware for online replacing but it does not work very well in batch mode.



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
Expert
posted Hide Post
Hi John,

If you already have your delimeters in the output string then just SAVE FORMAT COM then read each line back in and perform a substring (SUBSTV) function on it to remove the leading and trailing double quote. Not tried it myself but it should work in essence. A bit unwieldy and increased I/O, but depending upon your requirement it may be worth it?

You might be able to use the STRREP function instead.

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
Master
posted Hide Post
Thanks guys - it all helped.

Here's what I did in the end with Notes to follow.

DEFINE FILE HOLD
...
IFS_OUTPUT1/A600 = SUBSTR(4000,IFS_OUTPUT,1,600,600,'A600');
END

DOS DEL C:\P3OUTPUT.TXT
FILEDEF SAVEV DISK C:\P3OUTPUT.TXT ( RECFM V
TABLE FILE HOLD
PRINT IFS_OUTPUT1
ON TABLE SAVE
END
-RUN
-READ SAVE &INLINE.A600.
-LOOP
-IF &IORETURN NE 0 THEN GOTO LOOPEXIT ;
-SET &OUTLINE = TRUNCATE(&INLINE);
-WRITE SAVEV &OUTLINE
-READ SAVE &INLINE.A600.
-GOTO LOOP
-LOOPEXIT
-CLOSE SAVEV

1. Had to output as F600 because -READ will not read a variable length file since it treats it as a stream and reads 600 chars regardless of CR/LF combinations it encounters. -READ, will read variable length data but stops if it encounters a comma which is legit data in my example.

2. Had to DEL output, filedef RECFM V for output and issue a -CLOSE. Not sure which one is essential but this combo works, as agent was crashing with other combos I tried.

Not one of WF's strong points! Thanks again.

PS Tried to look at string substitution tools but still did not find a good freeware one to run in batch. Will keep you posted.



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
Expert
posted Hide Post
No Dialog Manager necessary, use TAB as output format (trailing blanks are stripped):

FILEDEF H001 DISK C:\TEMP\H001.CSV

TABLE FILE CAR
PRINT
COMPUTE TEST/A600 =
COUNTRY || ';' ||
CAR     || ';' ||
MODEL   || ';' ||
FTOA(DEALER_COST, '(D7)', 'A10');
ON TABLE HOLD AS H001 FORMAT TAB
END


If you require, you can use SQUEEZ to reduce multiple consecutive blanks within the string to one blank.

FILEDEF H002 DISK C:\TEMP\H002.CSV

TABLE FILE CAR
PRINT
COMPUTE TEST/A600 =
COUNTRY || ';' ||
CAR     || ';' ||
MODEL   || ';' ||
FTOA(DEALER_COST, '(D7)', 'A10'); NOPRINT
COMPUTE TEST2/A1000 = SQUEEZ(600, TEST, 'A600');
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS H002 FORMAT TAB
END

quote:
All trailing blanks are stripped from alpha [An] fields.

All leading blanks are stripped from numeric [/Dx.y, /Fx.y, /Px.y, and /In] fields.

There is a 32K record length limit in the output file.


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
Platinum Member
posted Hide Post
Hi John,

Here's a solution that works for me using Perl(You will need to have perl on the webfocus server).

This example reads the CAR file and holds data using format TAB(or could be TABT if you want headings). It then -WRITEs a perl script that will later be executed by a CMD statement. This perl script will read in the tab delimited hold file; break up the fields from each record into an array named in_fields; remove any leading or trailing white space from each field; push each field into an array named ot_fields; join all the fields back together seperated by a ";" and put it into a field called ot_line; and finally print the new line(which will be re-directed into a new file).

Here's the focexec(I hope it will post correctly):
-----------------------------------------------------------------------------------
TABLE FILE CAR
PRINT RCOST DCOST BY COUNTRY BY CAR BY MODEL
ON TABLE HOLD AS FORUM877 FORMAT TAB
END
-*
FILEDEF PERLSCR DISK forum877.pl
-RUN
-*
-WRITE PERLSCR #!/Perl/bin/perl -w
-WRITE PERLSCR while (<>Wink {
-WRITE PERLSCR chomp;
-WRITE PERLSCR @in_fields = ();
-WRITE PERLSCR @ot_fields = ();
-WRITE PERLSCR @in_fields = split("\t", $_);
-WRITE PERLSCR foreach $field (@in_fields) {
-WRITE PERLSCR for ($field) {
-WRITE PERLSCR s/^\s+//;
-WRITE PERLSCR s/\s+$//;
-WRITE PERLSCR }
-WRITE PERLSCR push(@ot_fields,$field);
-WRITE PERLSCR }
-WRITE PERLSCR $ot_line = join(";", @ot_fields);
-WRITE PERLSCR print "$ot_line\n";
-WRITE PERLSCR }
-CLOSE
-*
CMD forum877.pl forum877.tab > forum877.txt
-*
CMD COPY forum877.* \\SOME_NETWORK_DRIVE\WF\FORUM\FORUM877
----------------------------------------------------------

When I ran this focexec it produced the following output:

----------------------------------------------------------
0 NUMBER OF RECORDS IN TABLE= 18 LINES= 18
forum877.mas
forum877.pl
forum877.tab
forum877.txt
4 file(s) copied.
-----------------------------------------------------------

I now have a tab delimited file with a master file description, a copy of the perl script that was executed, and a new text file that is semi-colon delimited.

Let me know if this works.
Jim


WF DevStu 5.2.6/WF Srv 5.2.4/Win NT 5.2
 
Posts: 118 | Location: Lincoln Nebraska | Registered: May 04, 2005Report This Post
Master
posted Hide Post
Perhaps that saying "Great Minds think alike" doesn't apply to this problem. These are Great leftfield ideas all around.

Might use PERL on our server because we do need a scripting language that's better than DOS. Never occured to be to use squeeze especially for numbers as was doing LJUST with hard concatenation.

Thanks again for all your contributions

John



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
Master
posted Hide Post
Talking of scripting languages: wasn't there supposed to be a successor to .BAT language in Windows that had all the functionality of REXX, but with usual Microsoft "we wont conform to anyone else's standard - we will become the new standard" approach. (See MP3, JAVA etc etc)



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
Gold member
posted Hide Post
hamm01j,

You must be thinking of vbscript. See this article:

http://en.wikipedia.org/wiki/VBScript

-James


WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Expert
posted Hide Post
francis, that is wicked sweet!




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report 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     Output of variable length comma delimited string to save file without trailing blanks

Copyright © 1996-2020 Information Builders