Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Replace character using CTRAN

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Replace character using CTRAN
 Login/Join
 
Platinum Member
posted
I’m using CTRAN in dialogue manager to replace single quotes with a space. The parameter string is from a multi selection of countries in the car file.
I’m trying to replace the single quotes with a space and the OR between the countries with a comma.
The &PARM1 variable is stopping at 16 characters. I’m not sure why.

The final output should look like: England , France , Italy , Japan , W Germany

-DEFAULTH &P1 = '';
-DEFAULTH &P2 = '';
-DEFAULTH &P3 = '';
-DEFAULTH &P4 = '';
-DEFAULTH &P5 = '';
-* replace single quote with space (ascii dec) 39 = single quote 32 = space
-SET &PARM1 = CTRAN(100, &COUNTRY, 39, 32, 100);
-TYPE &|PARM1 == &PARM1
-*
FILEDEF TEMPFILE DISK TEMPFILE.TXT

-RUN
-WRITE TEMPFILE &PARM1
-RUN

-READ TEMPFILE,&P1,&P2,&P3,&P4,&P5
-TYPE &|P1 == &P1
-TYPE &|P2 == &P2
-TYPE &|P3 == &P3
-TYPE &|P4 == &P4
-TYPE &|P5 == &P5
-EXIT

DEFINE FILE CAR
COUNTRY1/A50 = COUNTRY;
END
TABLE FILE CAR
SUM CAR.BODY.SALES
BY CAR.ORIGIN.COUNTRY
WHERE CAR.ORIGIN.COUNTRY EQ &COUNTRY.(OR(FIND CAR.ORIGIN.COUNTRY IN CAR)).COUNTRY:.;
END

This message has been edited. Last edited by: Spence,


WF 8 version 8.2.04. Windows.
In focus since 1990.
 
Posts: 189 | Location: pgh pa | Registered: October 06, 2004Report This Post
Master
posted Hide Post
I had to change this line...

-SET &PARM1 = CTRAN(100, &COUNTRY, 39, 32, 100);


...to this to get it to run...

-SET &PARM1 = CTRAN(100, &COUNTRY, 39, 32, A100);


Now I get this output:

 &PARM1 ==  ENGLAND  OR  FRANCE  OR  ITALY  OR  JAPAN  OR  W GERMANY
 FILEDEF TEMPFILE DISK TEMPFILE.TXT
 &P1 == ENGLAND  OR  FRANCE  OR  ITALY  OR  JAPAN  OR  W GERMANY
 &P2 ==
 &P3 ==
 &P4 ==
 &P5 ==


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Platinum Member
posted Hide Post
Thank you Squatch.


WF 8 version 8.2.04. Windows.
In focus since 1990.
 
Posts: 189 | Location: pgh pa | Registered: October 06, 2004Report This Post
Master
posted Hide Post
No problem. My version of WebFOCUS decided to throw an error, but it looks like your version just defaulted to an A16 output format.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Platinum Member
posted Hide Post
quote:
&P1 == ENGLAND OR FRANCE OR ITALY OR JAPAN OR W GERMANY


Now the question is can CTRAN or another function convert the OR to a comma? It appears that CTRAN can only convert a single character and not the string of ' OR '.

-DEFAULTH &P1 = '';
-DEFAULTH &P2 = '';
-DEFAULTH &P3 = '';
-DEFAULTH &P4 = '';
-DEFAULTH &P5 = '';
-TYPE &|COUNTRY == &COUNTRY
-* replace single quote with space (ascii dec) 39 = single quote 32 = space
-SET &PARM1 = CTRAN(100, &COUNTRY, 39, 32, A100);
-TYPE &|PARM1 == &PARM1

DEFINE FILE CAR
PARM/A100 = '&PARM1';
PARM1/A100 = CTRAN(100, PARM, 79, 44, PARM1);
PARM2/A100 = CTRAN(100, PARM1, 82, 32, PARM1);
END
TABLE FILE CAR
PRINT PARM
PARM1
PARM2
BY COUNTRY
IF RECORDLIMIT EQ 1
END
-EXIT
-*
FILEDEF TEMPFILE DISK TEMPFILE.TXT

-RUN
-WRITE TEMPFILE &PARM1
-RUN

-READ TEMPFILE,&P1,&P2,&P3,&P4,&P5
-TYPE &|P1 == &P1
-TYPE &|P2 == &P2
-TYPE &|P3 == &P3
-TYPE &|P4 == &P4
-TYPE &|P5 == &P5
-EXIT


DEFINE FILE CAR
COUNTRY1/A50 = COUNTRY;
END
TABLE FILE CAR
SUM CAR.BODY.SALES
BY CAR.ORIGIN.COUNTRY
WHERE CAR.ORIGIN.COUNTRY EQ &COUNTRY.(OR(FIND CAR.ORIGIN.COUNTRY IN CAR)).COUNTRY:.;
END


WF 8 version 8.2.04. Windows.
In focus since 1990.
 
Posts: 189 | Location: pgh pa | Registered: October 06, 2004Report This Post
Master
posted Hide Post
Look up STRREP, it "replaces all instances of character string 1 with character string 2".

That's what my WebFOCUS Keysheet book says, anyway. I can try to work up an example for you if you'd like.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Master
posted Hide Post
Enjoy!

-DEFAULTH &P1 = '';
-DEFAULTH &P2 = '';
-DEFAULTH &P3 = '';
-DEFAULTH &P4 = '';
-DEFAULTH &P5 = '';
-* replace single quote with space (ascii dec) 39 = single quote 32 = space
-SET &PARM1 = CTRAN(100, &COUNTRY, 39, 32, A100);
-TYPE &|PARM1 == &PARM1
-SET &PARM1 = STRREP(100, &PARM1, 6, '  OR  ', 1, ',', 100, &PARM1);
-TYPE &|PARM1 == &PARM1
-*
FILEDEF TEMPFILE DISK TEMPFILE.TXT

-RUN
-WRITE TEMPFILE &PARM1 
-RUN

-READ TEMPFILE,&P1,&P2,&P3,&P4,&P5
-TYPE &|P1 == &P1
-TYPE &|P2 == &P2
-TYPE &|P3 == &P3
-TYPE &|P4 == &P4
-TYPE &|P5 == &P5
-EXIT

DEFINE FILE CAR
COUNTRY1/A50 = COUNTRY;
END
TABLE FILE CAR
SUM CAR.BODY.SALES
BY CAR.ORIGIN.COUNTRY
WHERE CAR.ORIGIN.COUNTRY EQ &COUNTRY.(OR(FIND CAR.ORIGIN.COUNTRY IN CAR)).COUNTRY:.;
END


Output:

 &PARM1 ==  ENGLAND  OR  FRANCE  OR  ITALY  OR  JAPAN  OR  W GERMANY
 &PARM1 ==  ENGLAND,FRANCE,ITALY,JAPAN,W GERMANY
 FILEDEF TEMPFILE DISK TEMPFILE.TXT
 &P1 == ENGLAND
 &P2 == FRANCE
 &P3 == ITALY
 &P4 == JAPAN
 &P5 == W GERMANY


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Platinum Member
posted Hide Post
Perfect. Thanks again for the help.


WF 8 version 8.2.04. Windows.
In focus since 1990.
 
Posts: 189 | Location: pgh pa | Registered: October 06, 2004Report This Post
Expert
posted Hide Post
I don't know were this started, but the format on the functions should be enclosed in quotes.

You can also make the output length the same as the input variable with 'A&Var.LENGTH'


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Replace character using CTRAN

Copyright © 1996-2020 Information Builders