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     [CLOSED] trim trailing spaces

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] trim trailing spaces
 Login/Join
 
Gold member
posted
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

Thanks

This 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, 2003Report This Post
Master
posted Hide Post
Brad,

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, 2013Report This Post
Gold member
posted Hide Post
a Flat file.....let me try your suggestion.


Brad S.
WF 8.05 / Win7 /Tomcat Self Serve
 
Posts: 61 | Location: St Louis | Registered: May 15, 2003Report This Post
Gold member
posted Hide Post
Eric

Did not work. In my examples, I was trying to indicate there are other data on the record.

I need a variable length record.

Brad


Brad S.
WF 8.05 / Win7 /Tomcat Self Serve
 
Posts: 61 | Location: St Louis | Registered: May 15, 2003Report This Post
Virtuoso
posted Hide Post
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, 2006Report This Post
Gold member
posted Hide Post
Thanks.

Do you have any quick examples?
My own search has not be productive.


Brad S.
WF 8.05 / Win7 /Tomcat Self Serve
 
Posts: 61 | Location: St Louis | Registered: May 15, 2003Report This Post
Expert
posted Hide Post
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


Say Hi to Mike...

Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Gold member
posted Hide Post
Thanks Tom!

I'll give it a whirl....

Brad


Brad S.
WF 8.05 / Win7 /Tomcat Self Serve
 
Posts: 61 | Location: St Louis | Registered: May 15, 2003Report This Post
Gold member
posted Hide Post
Tom

This gives me the length of each individual field. So how do I write out a variable length file?

For example writing out a
movie code,title and Rel Date, here is what i want in the hold file:

Code Title RelDate
A23456SESAME STREET-BEDTIME STORIES AND SONGS19960115
B98765SMRURFS, THE19990705
C24678BAMBI19921225


Brad S.
WF 8.05 / Win7 /Tomcat Self Serve
 
Posts: 61 | Location: St Louis | Registered: May 15, 2003Report This Post
Virtuoso
posted Hide Post
Create a new field with define and concatenation the fields to one string

Suppose fields are A B C

Newf/A100=A||B||C;

You can add the formula TRIM to remove the trailing spaces.




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, 2006Report This Post
Gold member
posted Hide Post
Frank

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, 2003Report This Post
Expert
posted Hide Post
I can't see why you're having trouble.

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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
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, 2006Report This Post
Member
posted Hide Post
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.


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 3 | Registered: December 11, 2012Report This Post
Virtuoso
posted Hide Post
I have repro'd Brad's problem:
  
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, 2006Report This Post
Virtuoso
posted Hide Post
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, 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     [CLOSED] trim trailing spaces

Copyright © 1996-2020 Information Builders