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]Generating alphanumeric values in Mainframe Focus

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]Generating alphanumeric values in Mainframe Focus
 Login/Join
 
Silver Member
posted
Hi,

I am in need to convert the order numbers (from 00001 to 99999) present in numeric format to alphanumeric format starting from (A001...A009...A00A...A00Z...A010...A019...A01A...A01Z...A020 and so on).

Is there a in-built function in Focus to provide similar results.

Thanks,
Shrikant

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


FOCUS 7.2.3
Platform: IBM system Z9 Business class
O/P formats: Flat files, excel and CSV files
 
Posts: 39 | Location: Hyderabad, India | Registered: April 28, 2007Report This Post
Virtuoso
posted Hide Post
Shrikant

It's not the same but I started a question some years ago about converting numbers to binair and hexadecimal.

You may find that usefull for your problem

take a look here




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

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
<JG>
posted
To convert from Base 10 (decimal) to any other base up to and including Base 36 which is what is wanted.

 
-SET &base=36;
-SET &num = 99999;  
-*
-SET &string   = '0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z';
-SET &value   = '' ;
-* 
-REPEAT ENDREPEAT WHILE &num NE 0;
-SET &div = &num / &base;
-SET &rem = &num - (&div * &base);
-SET &token = &rem + 1;
-SET &char = GETTOK(&string, 71, &token.EVAL, ',', 1, 'A1');
-SET &value = '&char.EVAL' || '&value.EVAL';
-SET &num = ÷
-ENDREPEAT
-TYPE &value


It's only possible in DM unless you write a subroutine.

However using an outer loop you could read, convert and re-write a data file.

can process numbers from 1 to 99999999

This message has been edited. Last edited by: <JG>,
 
Report This Post
<JG>
posted
Just for a bit of fun this converts any 2 to 36 base to any other 2 to 36 base
(The limitations for DM numerics still apply)

 
-SET &basein=16;
-SET &baseout=8;
-SET &numin = AAAAA;
-DEFAULTH &numout = 0
-*
-SET &stringin   = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
-SET &stringout   = '0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z';
-SET &value   = '' ;
-*
-SET &tpos=&numin.LENGTH +1;
-SET &power= &numin.LENGTH;
-SET &partno=1;
-REPEAT BASEIN WHILE &partno NE &tpos;
-SET &part = SUBSTR(&numin.LENGTH, '&numin.EVAL', &partno, &partno, 1, 'A1');
-SET &mod = POSIT(&stringin, 36, '&part.EVAL', 1, 'I2');
-SET &valout = 0;
-SET &valout = ((&mod -1) * (&basein ** (&power -1)));
-SET &numout = &numout + &valout;
-SET &power = &power -1;
-SET &partno=&partno + 1;
-BASEIN
-*
-REPEAT BASEOUT WHILE &numout NE 0;
-SET &div = &numout / &baseout;
-SET &rem = &numout - (&div * &baseout);
-SET &token = &rem + 1;
-SET &char = GETTOK(&stringout, 71, &token.EVAL, ',', 1, 'A1');
-SET &value = '&char.EVAL' || '&value.EVAL';
-SET &numout = ÷
-BASEOUT

-TYPE &value
 
Report This Post
Virtuoso
posted Hide Post
Here's JG's approach, coded in Define for the problem at hand.
DEFINE FILE yourfile
 BASE/I2=36;
 CHARS/A36='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';

 I/I10=NUMBER;
 Z/I2 = IMOD(I,BASE,'I2');
 I=INT(I/BASE);
 Y/I2 = IMOD(I,BASE,'I2');
 I=INT(I/BASE);
 X/I2 = IMOD(I,BASE,'I2');
 XX/A1=SUBSTR(36,CHARS,X+1,X+1,1,'A1');
 YY/A1=SUBSTR(36,CHARS,Y+1,Y+1,1,'A1');
 ZZ/A1=SUBSTR(36,CHARS,Z+1,Z+1,1,'A1');
 CODE/A4='A' | XX | YY |ZZ;
 CHECK/I10 = X*BASE*BASE + Y*BASE + Z;
END
TABLE FILE yourfile
 LIST NUMBER X  Y  Z  CODE  CHECK
END

NUMBER is the incoming value (integer);
CODE is the resulting Axxx value.
For a code scheme with three base-36 digits, the maximum encodable Number is 46655.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Silver Member
posted Hide Post
Thanks all for your responses.

I have implemented JG's and Jack's code successfully. I have done a slight modification to Jack's code as mentioned below to meet the actual requirement.

  
DEFINE FILE file
BASE/I2=36;
CHARS/A36='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
I/I10=NUMBER;
Z/I2 = IMOD(I,BASE,'I2');
I=INT(I/BASE);
Y/I2 = IMOD(I,BASE,'I2');
I=INT(I/BASE);
X/I2 = IMOD(I,BASE,'I2');
I=INT(I/BASE);
W/I2 = IMOD(I,BASE,'I2');
WW/A1=SUBSTR(36,CHARS,W+11,W+11,1,'A1');
XX/A1=SUBSTR(36,CHARS,X+1,X+1,1,'A1');
YY/A1=SUBSTR(36,CHARS,Y+1,Y+1,1,'A1');
ZZ/A1=SUBSTR(36,CHARS,Z+1,Z+1,1,'A1');
CODE/A4= WW | XX | YY |ZZ;
END

TABLE FILE file
PRINT CODE
BY NUMBER
END


Thanks again for all your help!!

-Shrikant


FOCUS 7.2.3
Platform: IBM system Z9 Business class
O/P formats: Flat files, excel and CSV files
 
Posts: 39 | Location: Hyderabad, India | Registered: April 28, 2007Report This Post
Silver Member
posted Hide Post
I would also like to hear from you guys if this can be met without a input file, meaning FOCUS actually generating the similar alphanumeric values to a certain defined limit instead of converting the numbers stored in a data file.


FOCUS 7.2.3
Platform: IBM system Z9 Business class
O/P formats: Flat files, excel and CSV files
 
Posts: 39 | Location: Hyderabad, India | Registered: April 28, 2007Report This Post
<JG>
posted
Just use an outer loop using a WHILE value and increase the number processed
by the required step interval.

 
-SET &base=36;
-SET &number = 0;  
-SET &step = 5;
-SET &limit = 1000;
-*
-SET &string   = '0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z';
-* 
-REPEAT ENDLOOP WHILE &number LT &limit;
-SET &value   = '' ;
-SET &number = &number + &step;
-SET &num = &number;
-REPEAT ENDREPEAT WHILE &num NE 0;
-SET &div = &num / &base;
-SET &rem = &num - (&div * &base);
-SET &token = &rem + 1;
-SET &char = GETTOK(&string, 71, &token.EVAL, ',', 1, 'A1');
-SET &value = '&char.EVAL' || '&value.EVAL';
-SET &num = ÷
-ENDREPEAT
-TYPE Decimal .. &number -- Base 16 &value
-ENDLOOP
 
Report 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]Generating alphanumeric values in Mainframe Focus

Copyright © 1996-2020 Information Builders