Focal Point
How to Replace a character with a SPACE in a given string.

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

November 03, 2007, 10:39 AM
johney
How to Replace a character with a SPACE in a given string.
Hi All,

I would like to replace a character with a space in a given string .

-SET &PRINTCLAUSE='E01~E02~E03' ;

I tried something like,

-SET &PRINTCLAUSE= STRREP(&PRINTCLAUSE.LENGTH, &PRINTCLAUSE, 4, '~', 1, ' ', &PRINTCLAUSE.LENGTH, 'A&PRINTCLAUSE.LENGTH');

But it didn't do it for me.

I have to get a string like

'E01 E02 E03'

I need this to pass as column positions for my holdfile to dynamically print the columns.

TABLE FILE SQLOUT
PRINT
&PRINTCLAUSE
END

Thanks and regards,
Johney.


Version 7.6.11
Webfocus installed in AIX 5.3,
desktop PC: Windows-XP based
Output: Excel, HTML, PDF
November 03, 2007, 11:39 AM
dwf
If your data is ASCII:

-SET &PRINTCLAUSE = CTRAN(&PRINTCLAUSE.LENGTH,&PRINTCLAUSE,126,32,'A&PRINTCLAUSE.LENGTH');

If it is EBCDIC:

-SET &PRINTCLAUSE = CTRAN(&PRINTCLAUSE.LENGTH,&PRINTCLAUSE,161,64,'A&PRINTCLAUSE.LENGTH');


dwf
November 03, 2007, 01:42 PM
FrankDutch
I suppose your E01 and E02 and E03 are fields from a database or the results of a fex.

If you do a -SET command the fields you want to concatenate should be amper values.

This should work

-DEFAULT &F1='12345';
-DEFAULT &F2='abcde';
-DEFAULT &F3='x3x5xx';
-SET &PRINTCLAUSE='&F1'||'&F2'||'&F3';
-TYPE &PRINTCLAUSE


If you run a report and put this &PRINTCLAUSE in the header or as the name of a column it should give the result.

But I think you want to get these fields from an other table you run something like this

TABLE FILE CAR
PRINT COUNTRY 
MODEL
BODY
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS HHEAD FORMAT ALPHA
END
-RUN
-READ HHEAD &E01.A15. &E02.A20. &E03.A20.
etc


Now the &printclause should hold the first 45 characters from the selection and you can use them in your header.




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

November 05, 2007, 12:56 AM
johney
Thank you all,

dwf's solution did the trick for me.Thank you .

Regards,
Johney.


Version 7.6.11
Webfocus installed in AIX 5.3,
desktop PC: Windows-XP based
Output: Excel, HTML, PDF