Focal Point
[CLOSED] Remove Leading Zeroes and Trailing spaces

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/526102835

October 01, 2010, 10:36 AM
Nan
[CLOSED] Remove Leading Zeroes and Trailing spaces
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,
October 01, 2010, 12:02 PM
Francis Mariani
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
October 01, 2010, 02:12 PM
Nan
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.
October 01, 2010, 02:16 PM
Francis Mariani
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
October 01, 2010, 02:25 PM
Nan
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?
October 01, 2010, 04:59 PM
Francis Mariani
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
October 02, 2010, 10:17 AM
Nan
thats my requirement :-)

when moving from source to target, I need to remove extra spaces.
October 03, 2010, 03:51 AM
Dan Satchell
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
October 04, 2010, 09:02 AM
Nan
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.
October 04, 2010, 10:33 AM
Clif
Anything FOCUS programmer puts in a DEFINE you could also put in a tranformation in DataMightor. Including nested function calls.


N/A
October 04, 2010, 01:26 PM
Dan Satchell
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
October 04, 2010, 04:01 PM
<JG>
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.
October 04, 2010, 07:19 PM
Nan
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.
October 05, 2010, 01:34 AM
<JG>
look at the adapter documentation

for example ENGINE SQLORA SET VARCHAR ON/OFF