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] Extract remaining charcters from alpha string

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Extract remaining charcters from alpha string
 Login/Join
 
Master
posted
I have been working on a technique to extract the last name from file containing names in
the format Smith J Albert PhD. I want to extract Smith and add a comma to it (Smith,)
and concatenate the remaining elements to look like: Smith, J Albert PhD.

As an example in Japan for the model 'COROLLA 4 DOOR DIX AUTO'. I can successfully extract COROLLA, but I want to extract the entire string after COROLLA, to include '4 DOOR DIX AUTO'.

Here is the code as I have written it thus far:

-*SET &ECHO=ALL;
-*
-*
TABLE FILE CAR
PRINT
CAR MODEL
COMPUTE MLEN/I2 = ARGLEN(24, MODEL, MLEN);
COMPUTE QBLNK/I2 = POSIT(MODEL, MLEN, ' ', 1, 'I2');
COMPUTE LNME/A11 = SUBSTR(15,MODEL,1,QBLNK-1,QBLNK,'A11');
COMPUTE FNME/A70 = SUBSTR(15,MODEL,QBLNK+1,QBLNK+(MLEN-QBLNK),(MLEN-QBLNK)+1,'A70');
BY COUNTRY
END
-RUN

-EXIT

Any ideas? Roll Eyes

Thanks!

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


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Virtuoso
posted Hide Post
Does something like this get you what you need? I'm finding the position of the first blank, breaking it out into two strings, before and after that position, then concatenating with a comma-blank in between.

TABLE FILE CAR
PRINT CAR MODEL
COMPUTE POSIT/I2=POSIT(MODEL, 20,' ', 1, POSIT);
COMPUTE LAST_NAME/A20V=SUBSTR(20, MODEL, 1, POSIT-1, POSIT-1, LAST_NAME);
COMPUTE FIRST_NAME/A20V=SUBSTR(20,MODEL,POSIT+1,20,20-POSIT,FIRST_NAME);
COMPUTE NAME/A21=LAST_NAME||', '|FIRST_NAME;
END


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Expert
posted Hide Post
TABLE FILE CAR
PRINT
CAR MODEL
COMPUTE MLEN/I2 = ARGLEN(24, MODEL, MLEN);
COMPUTE QBLNK/I2 = POSIT(MODEL, MLEN, ' ', 1, 'I2');
COMPUTE LNME/A11 = SUBSTR(15,MODEL,1,QBLNK-1,QBLNK,'A11');
COMPUTE FNME/A70 = SUBSTR(15,MODEL,QBLNK+1,QBLNK+(MLEN-QBLNK),(MLEN-QBLNK)+1,'A70');
BY COUNTRY
END


I think your problem was the input length for the SUBSTR subroutine. It needs to be the input length of the parent string, in this case 24.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Master
posted Hide Post
Thanks for your replies.

The problem was that I neglected to account for the input length of the parent string.


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Expert
posted Hide Post
TABLE FILE CAR
PRINT
CAR MODEL
COMPUTE MLEN/I2 = ARGLEN(24, MODEL, MLEN);
COMPUTE QBLNK/I2 = POSIT(MODEL, MLEN, ' ', 1, 'I2');
COMPUTE LNME/A11 = SUBSTR(24,MODEL,1,QBLNK-1,QBLNK,'A11');
COMPUTE FNME/A70 = SUBSTR(24,MODEL,QBLNK+1,24,(24-QBLNK)+1,'A70');
        FULLNAME/A90=IF QBLNK EQ 0 THEN MODEL ELSE LNME||', '|FNME;
BY COUNTRY
END


Sorry, I forgot to post the corrected code.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 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] Extract remaining charcters from alpha string

Copyright © 1996-2020 Information Builders