March 10, 2011, 09:17 AM
Anmol [CLOSED] Removing Leading spaces from the Column Data
Hi All,
I got stuck in a problem.
I have one column data as
"1. Some string Data Here"
Now I want to remove the 1. and space after it. OR just the space between 1. and String.
that my output should be like this
"Some string Data Here" OR
"1Some string Data Here"
My Report output format is TABT(Text) format
I have tried STRREP and TRIM with Left but not able to remove the space
Here is the code
STRREP used
WORK_UNIT_NAME/A302=STRREP(303,WORK_UNIT_NAME,2,'1.',0,'X',302,WORK_UNIT_NAME);
Here is TRIM I used
WORK_UNIT_NAME/A301=TRIM('L',WORK_UNIT_NAME,301,' ',0,WORK_UNIT_NAME);
This two lines I have used in the Define,
and I am not able to use TRUNCATE in Define.
Please suggest me something
Any help would be highly appreciated .
Thanks.
Anmol.
This message has been edited. Last edited by: Kerry , March 18, 2011 02:47 PM March 10, 2011, 09:25 AM
GamP I think you can do that with GETTOK looking for the second token separated by a dot. And then do a left justify of the data.
March 10, 2011, 09:31 AM
GamP Example in DM:
-SET &TEXT = '1. Some string data here' ;
-TYPE &TEXT
-SET &TEXT2=LJUST(&TEXT.LENGTH,GETTOK(&TEXT, &TEXT.LENGTH, 2, '.', &TEXT.LENGTH, 'A&TEXT.LENGTH'), 'A&TEXT.LENGTH');
-TYPE &TEXT2 You can do this in DEFINE also of course.
March 10, 2011, 10:00 AM
Francis Mariani There are several things wrong with your code.
1) Do not name the virtual column the same as the real column, if you do and if there is an error in the function call, the report will still run, but with the real column.
e.g.:
DEFINE FILE CAR
COUNTRYX/A301 = '1. ' | COUNTRY;
COUNTRYX/A301=TRIM('L',COUNTRYX,301,' ',0,COUNTRYX);
END
TABLE FILE CAR
PRINT
COUNTRYX
END Even though there is an error here, the report still runs. To see the error, change the code to:
DEFINE FILE CAR
COUNTRYX/A301 = '1. ' | COUNTRY;
COUNTRYY/A301=TRIM('L',COUNTRYX,301,' ',0,COUNTRYY);
END
TABLE FILE CAR
PRINT
COUNTRYX
COUNTRYY
END 2) Syntax error in the TRIM call - the "pattern_length" cannot be 0.
3) This STRREP should work:
WORK_UNIT_NAMEX/A303 = STRREP(303, WORK_UNIT_NAME, 3, '1. ', 0, 'X', 303,'A303'); 4) If you know that you need to remove the first three characters, use the SUBSTR function:
-* SUBSTR(inlength, parent, start, end, sublength, outfield);
WORK_UNIT_NAMEX/A300 = SUBSTR(301, WORK_UNIT_NAME, 4, 301, 300, 'A300');
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
March 23, 2011, 12:50 PM
Anmol Hi All,
Thanks for all the suggestions and sorry for the late reply..
I am able to work out for the solution using CTRAN function.
Followign line works for me..
WORK_UNIT_NAMEX/A303 = CTRAN(303, WORK_UNIT_NAME, 9, 32, WORK_UNIT_NAME); Thanks a lot..
Regards,
Anmol