Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Remove Leading Zeroes and Trailing spaces
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Remove Leading Zeroes and Trailing spaces
 Login/Join
 
Member
posted
Hi,

I need to remove leading zeroes and trailing spaces.

I am able to remove leading zeroes using this function, but when I try to nest it with another trim, I get error.

please help.

Input: IDOCNUMBER = 000000000123456789
Expression to remove leading zeroes - TRIM( 'L', IDOCNUMBER, 50, '0', 1, 'A50' )
Output - 123456789

Now I want to remove trailing spaces. I tried to do RTRIM(TRIM( 'L', IDOCNUMBER, 50, '0', 1, 'A50' )) or TRIM(TRIM( 'L', IDOCNUMBER, 50, '0', 1, 'A50' )) since the default is spaces, but nothing worked Frowner

This message has been edited. Last edited by: Kerry,
 
Posts: 23 | Registered: April 21, 2008Reply With QuoteReport This Post
Expert
posted Hide Post
This is a data field, not a Dialogue Manager variable?

May I ask why you need to remove trailing spaces?


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, 2005Reply With QuoteReport This Post
Member
posted Hide Post
this is a data field in my process flow that I created in datamigrator.

why I need to remove trailing spaces --> thats how I am required to do and copy to target system.
 
Posts: 23 | Registered: April 21, 2008Reply With QuoteReport This Post
Expert
posted Hide Post
Are there really trailing spaces, or is this a 50 character field? Wouldn't there always be 50 characters in a 50 character field? To determine the length of the non-blank part of a field, use the ARGLEN function.


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, 2005Reply With QuoteReport This Post
Member
posted Hide Post
The max length for this field is 50, but there will not be 50 characters in them always.. there might be spaces too Frowner

So if I am understanding right, ARGLEN will just give me the length of the characters excluding spaces is it?
 
Posts: 23 | Registered: April 21, 2008Reply With QuoteReport This Post
Expert
posted Hide Post
I don't understand why your DataMigrator process can't simply move the field from one table to the other? Why do you need to remove spaces?


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, 2005Reply With QuoteReport This Post
Member
posted Hide Post
thats my requirement :-)

when moving from source to target, I need to remove extra spaces.
 
Posts: 23 | Registered: April 21, 2008Reply With QuoteReport This Post
Virtuoso
posted Hide Post
This will remove trailing spaces, but if you put the resulting string back into an A50 field, it will be padded with spaces/blanks to fill out the 50 characters:
TRIM('R',IDOCNUMBER,50,' ',1,'A50')

You could try putting the TRIMmed value into a variable length field:
TRIM('R',IDOCNUMBER,50,' ',1,'A50V')

Or, if writing the value to a HOLD file, you could specify the exact, non-blank length by using function ARGLEN as suggested by Francis:
DEFINE FILE <filename>
 OUTLENGTH/I5  = ARGLEN(50,IDOCNUMBER,'I5');
 OUTFORMAT/A10 = 'A' | EDIT(OUTLENGTH);
END

TABLE FILE <filename?
 PRINT IDOCNUMBER/OUTFORMAT
 .
 ON TABLE HOLD
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Reply With QuoteReport This Post
Member
posted Hide Post
Thanks Dan.

About this HOLD file, is this code I need to write and cannot use the synonym generator? Frowner

Can I have nested TRIM?

Reason being, I need to TRIM leading zeroes from the data as well.
 
Posts: 23 | Registered: April 21, 2008Reply With QuoteReport This Post
Guru
posted Hide Post
Anything FOCUS programmer puts in a DEFINE you could also put in a tranformation in DataMightor. Including nested function calls.
 
Posts: 382 | Location: New York City | Registered: May 03, 2007Reply With QuoteReport This Post
Virtuoso
posted Hide Post
You can use TRIM to remove leading zeroes, but Francis' earlier comment is valid: you shouldn't need to remove trailing blanks because DataMigrator should automatically take care of truncating data from your source column when loading it into a smaller target column.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Reply With QuoteReport This Post
<JG>
posted
Silly question but what DB is the DM target? and what format is the target column?

Create the transfer file as COM or TAB and it will automatically truncate trailing spaces.
 
Reply With QuoteReport This Post
Member
posted Hide Post
Thanks Dan, JG.

I am using TRIM( 'L', IDOCNUMBER, 50, '0', 1, 'A50V' ) where IDOCNUMBER is the source column name.

Since outformat is A50V, though it removes leaading zeroes, it pads up spaces for the remaining characters in the output string.. thus has spaces.
 
Posts: 23 | Registered: April 21, 2008Reply With QuoteReport This Post
<JG>
posted
look at the adapter documentation

for example ENGINE SQLORA SET VARCHAR ON/OFF
 
Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Remove Leading Zeroes and Trailing spaces

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.