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     Convert Comma Delimited Numeric String to Quoted Zero Padded Character String

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Convert Comma Delimited Numeric String to Quoted Zero Padded Character String
 Login/Join
 
Member
posted
Input :-- &IPSTR='123,678,12,9,9999';
DESIRED OUTPUT :- &IPSTR='''0123','0678','0012','0009','9999''';
I have a fair idea of Code, but I am missing something or Misusing something...
Can anyone help ?

Specific Problem ::- Function ATODBL below, does not seem to be printing a Number but continues to display a Character....


Here is my Code :-
==========================================================================
-SET &IPSTR='123,678,12,9,9999';
-SET &OPSTR=' ';
-SET &DSP = ' Displayed String : ';


-SET &I=1;
-SET &TOK = '1';
-* Get Tokens in a loop
-REPEAT :GETTOKENS WHILE &TOK NE ' ';
-* obtain the first token
-SET &TOK = GETTOK(&IPSTR,&IPSTR.LENGTH,&I,',',4,'A4');
-SET &DBLTOK = ATODBL(&TOK,4,'D4');
-SET &TOK = STRIP(4,&TOK,' ',&TOK);
-SET &FMTTOK = EDIT(&DBLTOK,'''9999''');
-IF &TOK = ' ' THEN GOTO :GETTOKENS;
-TYPE &I ||':' || &TOK || ' Len:' || &TOK.LENGTH || 'DBLTOK:' || &DBLTOK
-SET &OPSTR= &OPSTR |',' |&FMTTOK;
-SET &I = &I + 1;
-:GETTOKENS

-TYPE 'ALL DONE';
-TYPE &OPSTR;
==========================================================================


Saurabh Palkar
 
Posts: 18 | Registered: April 20, 2007Report This Post
Expert
posted Hide Post
Easy Way, others will follow:

-SET &IPSTR='123,678,12,9,9999';
-SET &OPSTR=' ';
-SET &DSP = ' Displayed String : ';
-SET &ECHO=ALL;

-SET &I=1;
-SET &TOK = '1';
-* Get Tokens in a loop
-REPEAT :GETTOKENS WHILE &TOK NE ' ';
-* obtain the first token
-SET &TOK = GETTOK(&IPSTR,&IPSTR.LENGTH,&I,',',4,'A4');
-SET &DBLTOK = ATODBL(&TOK,4,'D4');
-SET &TOK = STRIP(4,&TOK,' ',&TOK);


-SET &FMTOK_CK = IF EDIT(&TOK,'$999') EQ ' ' THEN '000' || &TOK ELSE
- IF EDIT(&TOK,'$$99') EQ ' ' THEN '00' || &TOK ELSE
- IF EDIT(&TOK,'$$$9') EQ ' ' THEN '0' || &TOK ELSE
- &TOK;
-TYPE &FMTOK_CK

-SET &FMTTOK = EDIT(&DBLTOK,'''9999''');

-IF &TOK = ' ' THEN GOTO :GETTOKENS;
-TYPE &I ||':' || &TOK || ' Len:' || &TOK.LENGTH || 'DBLTOK:' || &DBLTOK
-SET &OPSTR= &OPSTR |',' | &FMTOK_CK;
-SET &I = &I + 1;
-:GETTOKENS

-TYPE 'ALL DONE';
-TYPE &OPSTR;

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Member
posted Hide Post
Tom,
Your solution works !. Thanks for your prompt response. It got me thinking, and I have coded an alternate solution, which I think can be more generic.


So Here Goes
===============================================
-SET &IPSTR='123,678,12,9,9999';
-* EXPECTED OUTPUT '''0123','0678','0012','0009','9999'''
-SET &OPSTR=' ';
-SET &DSP = ' Displayed String : ';


-SET &I=1;
-SET &TOK = '1';
-REPEAT :GETTOKENS WHILE &TOK NE ' ';
-SET &TOK = GETTOK(&IPSTR,&IPSTR.LENGTH,&I,',',4,'A4');
-SET &JTOK = RJUST(4,&TOK,'A4');
-SET &STOK = CTRAN(4,&JTOK,32,48,'A4');
-SET &FMTTOK = EDIT(&STOK,'''9999''');
-IF &TOK = ' ' THEN GOTO :GETTOKENS;
-TYPE &I ||':' || &TOK || ' Len:' || &TOK.LENGTH || 'FMTTOK:' || &FMTTOK;

-SET &OPSTR = IF &I NE 1 THEN &OPSTR || ',' || &FMTTOK ELSE
- &FMTTOK;

-SET &I = &I + 1;
-:GETTOKENS
-SET &OPSTR = '''' || &OPSTR || '''';
-TYPE &OPSTR;
===============================================
Thanks Again,
Saurabh Palkar


Saurabh Palkar
 
Posts: 18 | Registered: April 20, 2007Report 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     Convert Comma Delimited Numeric String to Quoted Zero Padded Character String

Copyright © 1996-2020 Information Builders