Focal Point
[SOLVED] Reformat of input variable

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

February 10, 2014, 04:45 PM
Joel Elscott
[SOLVED] Reformat of input variable
Hi,

I need to reformat the following variable into a new variable with an entirely different format. How can this be done?

Incoming variable value: (small|large|huge)

The income variable values will be assigned a "code":
small = 3
large = 12
huge = 8

I also need to have comma's between each code.
Final output variable format needed: (3,12,8)

Thanks in advance!

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8.2.03
z/OS
February 10, 2014, 09:25 PM
Francis Mariani
Use the function STRREP:

-SET &VAR1 = '(small|large|huge)';

-SET &VAR1A = 
-  STRREP (&VAR1.LENGTH, &VAR1, 5, 'small', 1, '3', &VAR1.LENGTH, 'A&VAR1.LENGTH');
-SET &VAR1A = 
-  STRREP (&VAR1A.LENGTH, &VAR1A, 5, 'large', 2, '12', &VAR1.LENGTH, 'A&VAR1.LENGTH');
-SET &VAR1A = 
-  STRREP (&VAR1A.LENGTH, &VAR1A, 5, 'huge', 1, '8', &VAR1.LENGTH, 'A&VAR1.LENGTH');
-SET &VAR1A = 
-  STRREP (&VAR1A.LENGTH, &VAR1A, 1, '|', 1, ',', &VAR1.LENGTH, 'A&VAR1.LENGTH');

-TYPE &VAR1
-TYPE &VAR1A

-*STRREP (inlength, instring, searchlength, searchstring, replength, repstring, outlength, outstring)



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
February 11, 2014, 10:08 AM
Joel Elscott
Perfect! Thanks Francis!


WebFOCUS 8.2.03
z/OS