November 03, 2007, 10:39 AM
johneyHow 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.
November 03, 2007, 11:39 AM
dwfIf 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');
November 03, 2007, 01:42 PM
FrankDutchI 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.
November 05, 2007, 12:56 AM
johneyThank you all,
dwf's solution did the trick for me.Thank you .
Regards,
Johney.