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'm using TRIM on several alphanumeric fields in a DEFINE and then concatenating them together in a separate virtual field in order to remove all trailing spaces that would otherwise appear when I do an ON TABLE HOLD FORMAT ALPHA. However, the single virtual field that contains all of the other fields concatenated/squished together is an A200 format and it has trailing spaces. Is there a way to remove these trailing spaces in my output file?This message has been edited. Last edited by: Tamra,
Or do the trim on the result of the concatenation. Alpha fields by definition are always space-filled to the right if the stuff you put it them doesn't occupy all of the positions.
Or make the format of the defined field A200V. This sometimes causes problems if the field is used in further calculation or hold files (those can be overcome as well), but also makes the field length exactly the same as the resulting value without trailing spaces.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007
Second thought, if you're saving format ALPHA, it's a fixed length flat file you're creating. Wouldn't you want all fields to be of a specified length occupying a specific position instead of trimming an unknown number of blanks from the record?
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007
Thanks for the replies. TexasStingray, I am already doing what you suggest to remove the trailing spaces on the several fields I'm concatenating, however, my NEWFIELD is an A200 and that field has the trailing spaces.
Ginny & Darin, I also had tried your suggestions already, but making it a variable length field (i.e. A200V) causes the output file to have the length printed as the first column. At least I think it's the length...a value like 000200 is appearing as the leftmost value in my output file.
It's too bad that something that should be so simple is so difficult. That's why I thought I must be missing something obvious. To be honest, I'm trying to create a CSV file with quotes around field values and commas in between...just like WebFOCUS' FORMAT COMMA except that my values are not a fixed length. Darin, I don't want them to be a fixed length because they will ultimately be used in a VLOOKUP and the values can't have spaces because then the VLOOKUP fails to match them. A CSV file gives me more flexibility than saving this as FORMAT EXCEL. Anyway, the last field's values all have trailing spaces which I can't seem to avoid. If I get sometime, I'll try to post some sample code using the CAR file. I'm sure it must do the same thing there.
Try using the formula SQUEEZ, that might work better than TRIM. The 000200 you get in the A200V field gives the real length of the internal string. Did you search this site on CSV? You may find several good suggestions. Take a look at "FORMAT COMMA", I'm rather sure that would do what you want.
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006
Doing a HOLD FORMAT ALPHA (or binary or SAVE or SAVB) will always produce records and fields that are completely filled. That's the way it is supposed to be, because these formats are meant for fixed field/record length. Putting in a variable field (format AxxV) does not alter that, it only adds the number of characters in the field to the front of the field.
To produce a record with fields that are truly variable you need to use, as Frank indicated, the FORMAT COM. This will give you the contents of the field with "'s around it if the field contains any intermediate space. If you have two or more fields in your request, it will seperate them with a comma.
Hope this helps ...
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
FILEDEF PUTDD DISK fileout.csv
DEFINE FILE CAR
Record/A200 = '"'|| COUNTRY || '","' || CAR || '","' || BODYTYPE || '"' ;
FileOut/I1 = PUTDDREC('PUTDD',5, Record,ARGLEN(200,Record,'I3'), FileOut);
END
TABLE FILE CAR
PRINT FileOut
ON TABLE HOLD
END
The function will write out a text string to a DDNAME during Tabling. One of the parameters is the length of the input, this is changed to the length of the string to only write out a truncated string to the file.
Not sure when this function came out, but it works in 7.1 and 7.6
Don't worry if you can't find a reference to it in the WebFocus documentation. It appeared in 713 new features as a reporting enhancement but is only documented in the Data Migrator functions documentation [DN3501785.0408].
As a Data migrator server is exactly the same server as a WebFocus Server or an iWay Full function server it works the same way.
This a a little brute force, but it should work under all situations:
DEFINE FILE CAR
CONCAT_VAR/A65 = COUNTRY || ',' || CAR || ',' || MODEL || ',' || BODYTYPE ;
END
-RUN
TABLE FILE CAR
PRINT CONCAT_VAR
ON TABLE SAVE AS TEMPFILE
END
-RUN
-* Put your output file in a place of your choosing
APP FILEDEF CONCAT_FILE [my-hold-dir]/concat_file.csv (LRECL 65 RECFM V
-RUN
-REPEAT WRITE_LOOP &LINES TIMES
-READ TEMPFILE &TEMP_LINE.A65.
-SET &SQUEEZED_LINE = TRUNCATE(&TEMP_LINE) ;
-WRITE CONCAT_FILE &SQUEEZED_LINE
-WRITE_LOOP
Hmmmm...that gives me a few options to play around with. I'll be trying them out because I truly believe that FORMAT COMMA was padding the fields with trailing spaces. Thanks for the suggestions.
I had similar trouble and finally realized I could switch to "FORMAT DFIX DELIMITER ' ' HEADER NO". Might give you some grief if you have more than one field...