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.
On a table file request which holds data into a hold file, how do I trim trailing speces from my character based variable and write out just the length equal to the last character?
I have a vriable in my Focus DB DESC/A25
in record 1, DESC equals "Web Focus" (9 chars) in record 2, DESC equals "Red One" (7 chars)
If xxxxx and YYYYY represent othe data in my table request< I want the hold file to be: xxxxxWebFocusYYYYY xxxxxRed OneYYYYYY
ThanksThis message has been edited. Last edited by: Kerry,
Brad S. WF 8.05 / Win7 /Tomcat Self Serve
Posts: 61 | Location: St Louis | Registered: May 15, 2003
Are you creating a hold file or a flat file? From what you have, I would assume you are essentially concatenating 3 fields together. If that is correct you could use the hard concatenation of "||" when joining your fields. Also you can use the format of A25V for a variable length field.
Does that help? If not, can you provide some more info?
Eric Woerle 8.1.05M Gen 913- Reporting Server Unix 8.1.05 Client Unix Oracle 11.2.0.2
Posts: 750 | Location: Warrenville, IL | Registered: January 08, 2013
There are several formulas to measure the length of the field and the real actual size without trailing space. And if the source field is an Av varchar the first internal 6 characters will give the actual size. So once measured the size you can calculate how many you need for the last strings with YYYY
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
Hi Brad, Look at Variable Length Character Functions, specifically, LENV and TRIMV...
From the Help in DevStudio:
TABLE FILE MOVIES
PRINT
COMPUTE TITLEV/A39V = TRIMV('T', TITLE, 39, ' ', 1, TITLEV);
ALEN/I2 = LENV(TITLEV,ALEN);
BY CATEGORY NOPRINT
WHERE CATEGORY EQ 'CHILDREN'
END
The output is:
TITLEV ALEN
------ ----
SMURFS, THE 11
SHAGGY DOG, THE 15
SCOOBY-DOO-A DOG IN THE RUFF 28
ALICE IN WONDERLAND 19
SESAME STREET-BEDTIME STORIES AND SONGS 39
ROMPER ROOM-ASK MISS MOLLY 26
SLEEPING BEAUTY 15
BAMBI 5
I tried the hard concatenation into a new variable. In the hold file, it did not remove the training spaces.
I'll review my code again but it appears that if I display the variable, the spaces are removed. If I hold the new compute variable in a file, it does not remove the trailing spaces of each of the individual variables.
Brad S. WF 8.05 / Win7 /Tomcat Self Serve
Posts: 61 | Location: St Louis | Registered: May 15, 2003
Perhaps we should use one of the sample data tables and provide you an example.
Here's an example of a new field that is a concatenation of three fields:
SET HOLDLIST=PRINTONLY
FILEDEF HOLDCAR1 DISK BASEAPP/HOLDCAR1.TXT
TABLE FILE CAR
PRINT
COMPUTE CONCAT1/A100 = COUNTRY || CAR || MODEL;
BY COUNTRY NOPRINT
ON TABLE HOLD AS HOLDCAR1 FORMAT ALPHA
END
Make sure you have HOLDLIST=PRINTONLY, otherwise you will get all the fields that are referred to in the COMPUTE as well as the COMPUTEd field.
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
Die you create the intermediate formatted fields conform The example Tom has made? The formula with the LENV and TRIMV is what you need, and you need to do that on all 3 fields and see what length it gives per record. Copy the exact fexcode once you did this and post that code so we can see you did not make a mistake.
(Looks like school ...)
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
You may want to check the available disk space on the server to be sure it is not full. I had this very same situation where the hard || concatenation just did not work. We then learned from our IT folks that the drive was full and had to be cleaned up. Once that was done the concatenation worked. I do not know for sure if this was directly related, but appears correlated. My guess is the disk may have been used for caching for performing the concatenation.
FILEDEF BRAD DISK C:\IBI\APPS\FOCALPOINT\BRAD.FTM
-RUN
DEFINE FILE CAR
BRAD/A50V=TRIMV('T', COUNTRY || CAR || MODEL, 50, ' ', 1, BRAD);
END
TABLE FILE CAR
PRINT BRAD
ON TABLE HOLD AS BRAD FORMAT ALPHA
END
I created the file in an "apps" directory to be able to see it. Results: WF creates the file with the variable length field. It prefixes the field with its length in 6 bytes. HOWEVER, it keeps the full length of the field (50 bytes) and adds spaces. So, in theory, this is a file with variable length records. In practice it is fixed length.
The only other way I could think of was using -WRITE:
FILEDEF BRAD DISK C:\IBI\APPS\FOCALPOINT\BRAD.FTM
DEFINE FILE CAR
BRAD/A50V=TRIMV('T', COUNTRY || CAR || MODEL, 50, ' ', 1, BRAD);
END
TABLE FILE CAR
PRINT BRAD
ON TABLE HOLD AS HBRAD FORMAT ALPHA
END
-RUN
-SET &L=&LINES;
-REPEAT #W FOR &I FROM 1 TO &L;
-READ HBRAD,&V
-SET &VLEN=ARGLEN(&V.LENGTH,&V,'I2');
-SET &W=SUBSTR(&V.LENGTH, &V, 1, &VLEN, &VLEN, 'A&VLEN.EVAL');
-WRITE BRAD &W
-#W
If the length of the field is not desired use An instead of AnV.
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006
As said in my first remark on this question the first 6 positions give you the actual length of the string So what you can do I think is read that number and use it to create the substring without the trailing spaces. Then you can concatenate the 3 components to one new string that mill have trailing spaces. Final string should IMHO not be a varchar but a fixed char. Webfocus does not know varchar.
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