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] Single field with Space Delimiter

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Single field with Space Delimiter
 Login/Join
 
Platinum Member
posted
Hello

I have a table with only 1 field of length 300 characters. It technically consists of multiple data columns separated by a space.
I am using EDIT, GETTOK functions but at some point it's breaking. Below data is an example. I need to split each record into 4 different fields.
ATLANTA 1 GEORGIA GA
CUPERTINO 2 CALIFORNIA CA
AUSTIN 333 TEXAS TX
BILLINGS 1232 MONTANA MT

Please suggest.

Thanks

This message has been edited. Last edited by: FP Mod Chuck,


WF 8.2.01 APP STUDIO
PDF,HTML,EXL2K,Active
 
Posts: 139 | Registered: July 21, 2011Report This Post
Virtuoso
posted Hide Post
Try using STRREP to replace the space by another character then use GETTOK to separate into different field.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Expert
posted Hide Post
Open the Manual and learn the correct syntax...

-SET &REC_1 = 'ATLANTA 1 GEORGIA GA';
-SET &REC_2 = 'CUPERTINO 2 CALIFORNIA CA';
-SET &REC_3 = 'AUSTIN 333 TEXAS TX';
-SET &REC_4 = 'BILLINGS 1232 MONTANA MT';
-SET &PASS  = 0;
-REPEAT DO_4_LINES 4 TIMES
-SET &PASS  = &PASS + 1;
-SET &GETTOK_VALUE = '&|REC_' || &PASS || '.EVAL';
-SET &CONVERT_VAL1 = GETTOK('&GETTOK_VALUE.EVAL', 50, 1, ' ', 50, 'A50');
-SET &CONVERT_VAL2 = GETTOK('&GETTOK_VALUE.EVAL', 50, 2, ' ', 50, 'A50');
-SET &CONVERT_VAL3 = GETTOK('&GETTOK_VALUE.EVAL', 50, 3, ' ', 50, 'A50');
-SET &CONVERT_VAL4 = GETTOK('&GETTOK_VALUE.EVAL', 50, 4, ' ', 50, 'A50');

-SET &VAL_1 = TRUNCATE(&CONVERT_VAL1);
-SET &VAL_2 = TRUNCATE(&CONVERT_VAL2);
-SET &VAL_3 = TRUNCATE(&CONVERT_VAL3);
-SET &VAL_4 = TRUNCATE(&CONVERT_VAL4);

-TYPE &GETTOK_VALUE.EVAL
-TYPE ********************
-TYPE VAL 1= &VAL_1
-TYPE VAL 2= &VAL_2
-TYPE VAL 3= &VAL_3
-TYPE VAL 4= &VAL_4
-TYPE -TYPE ********************
-DO_4_LINES
-EXIT


Generates:
  
 ATLANTA 1 GEORGIA GA
 ********************
 VAL 1= ATLANTA
 VAL 2= 1
 VAL 3= GEORGIA
 VAL 4= GA
 ********************
 CUPERTINO 2 CALIFORNIA CA
 ********************
 VAL 1= CUPERTINO
 VAL 2= 2
 VAL 3= CALIFORNIA
 VAL 4= CA
 ********************
 AUSTIN 333 TEXAS TX
 ********************
 VAL 1= AUSTIN
 VAL 2= 333
 VAL 3= TEXAS
 VAL 4= TX
 ********************
 BILLINGS 1232 MONTANA MT
 ********************
 VAL 1= BILLINGS
 VAL 2= 1232
 VAL 3= MONTANA
 VAL 4= MT
 ********************


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Virtuoso
posted Hide Post
or:

Master
FILENAME=INPUT, SUFFIX=DFIX    ,
 DATASET=baseapp/input.txt, $
  SEGMENT=INPUT, SEGTYPE=S0, $
    FIELDNAME=FIELD_1, USAGE=A10V, ACTUAL=A10VB, $
    FIELDNAME=FIELD_2, USAGE=I6, ACTUAL=A4V, $
    FIELDNAME=FIELD_3, USAGE=A12V, ACTUAL=A12VB, $
    FIELDNAME=FIELD_4, USAGE=A2V, ACTUAL=A2VB, $
  


Acx:
SEGNAME=INPUT, 
  DELIMITER=' ', 
  ENCLOSURE='''', 
  HEADER=NO, 
  CDN=OFF, 
  CONNECTION=<local>, $
  


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Platinum Member
posted Hide Post
I personally would try to clean this up at the data table level so you don't have the issue of trying to break it apart with WF. A space is a terrible delimiter, all it takes is one string within that field to have an inadvertent space and your logic to break it apart is hosed. Any reason why you have one delimited field rather than a table with the fields broken out into separate data columns?


JC
WebFOCUS Dev Studio / App Studio
8.2.01
Windows 7
 
Posts: 146 | Registered: November 09, 2015Report This Post
Expert
posted Hide Post
Also in V8, there is a new token function called..... TOKEN, works well, less parameters.


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
Virtuoso
posted Hide Post
quote:
Originally posted by Tom Flynn:
-SET &REC_1 = 'ATLANTA 1 GEORGIA GA';
-SET &REC_2 = 'CUPERTINO 2 CALIFORNIA CA';
-SET &REC_3 = 'AUSTIN 333 TEXAS TX';
-SET &REC_4 = 'BILLINGS 1232 MONTANA MT';
-SET &PASS  = 0;
-REPEAT DO_4_LINES 4 TIMES
-SET &PASS  = &PASS + 1;
-SET &GETTOK_VALUE = '&|REC_' || &PASS || '.EVAL';
-SET &CONVERT_VAL1 = GETTOK('&GETTOK_VALUE.EVAL', 50, 1, ' ', 50, 'A50');
-SET &CONVERT_VAL2 = GETTOK('&GETTOK_VALUE.EVAL', 50, 2, ' ', 50, 'A50');
-SET &CONVERT_VAL3 = GETTOK('&GETTOK_VALUE.EVAL', 50, 3, ' ', 50, 'A50');
-SET &CONVERT_VAL4 = GETTOK('&GETTOK_VALUE.EVAL', 50, 4, ' ', 50, 'A50');

-SET &VAL_1 = TRUNCATE(&CONVERT_VAL1);
-SET &VAL_2 = TRUNCATE(&CONVERT_VAL2);
-SET &VAL_3 = TRUNCATE(&CONVERT_VAL3);
-SET &VAL_4 = TRUNCATE(&CONVERT_VAL4);

-TYPE &GETTOK_VALUE.EVAL
-TYPE ********************
-TYPE VAL 1= &VAL_1
-TYPE VAL 2= &VAL_2
-TYPE VAL 3= &VAL_3
-TYPE VAL 4= &VAL_4
-TYPE -TYPE ********************
-DO_4_LINES
-EXIT


Because I always wonder about that whenever I encounter EVAL, that can indeed be written without. Here's the relevant section:
-SET &GETTOK_VALUE = &REC_.&PASS;
-SET &CONVERT_VAL1 = GETTOK(&GETTOK_VALUE, 50, 1, ' ', 50, 'A50');
-SET &CONVERT_VAL2 = GETTOK(&GETTOK_VALUE, 50, 2, ' ', 50, 'A50');
-SET &CONVERT_VAL3 = GETTOK(&GETTOK_VALUE, 50, 3, ' ', 50, 'A50');
-SET &CONVERT_VAL4 = GETTOK(&GETTOK_VALUE, 50, 4, ' ', 50, 'A50');


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Platinum Member
posted Hide Post
quote:
A space is a terrible delimiter, all it takes is one string within that field to have an inadvertent space and your logic to break it apart is hosed.



SANTA FE 666 NEW MEXICO NM


Cheers,
H.

WebFOCUS 8.1.05M
Oracle 11g - DB2
RedHat
 
Posts: 115 | Location: Brighton UK | Registered: February 19, 2005Report This Post
Master
posted Hide Post
quote:
SANTA FE 666 NEW MEXICO NM

It is cold and cloudy in Chicago today. Thank you for the warm thoughts Hank! :-)
 
Posts: 822 | Registered: April 23, 2003Report This Post
Platinum Member
posted Hide Post
quote:
Originally posted by jcannavo:
I personally would try to clean this up at the data table level so you don't have the issue of trying to break it apart with WF. A space is a terrible delimiter, all it takes is one string within that field to have an inadvertent space and your logic to break it apart is hosed. Any reason why you have one delimited field rather than a table with the fields broken out into separate data columns?

It's a file that is coming from mainframe. FTP to webfocus server.
 
!/bin/mfftp toud t 'filename'  /WF/ibi/wf8/apps/baseapp/filename.txt 80 FB DIRMIXCASE


WF 8.2.01 APP STUDIO
PDF,HTML,EXL2K,Active
 
Posts: 139 | Registered: July 21, 2011Report This Post
Platinum Member
posted Hide Post
Well, it is a mainframe extract file... if you ask the jurassic park staff nicely they might tweak the JCL to make it comma-delimited, though they will lament endlessly how much it costs to store a comma. Unless it is stored that way originally, when it might be actually position-stored... but the extract should be able to handle that.


Cheers,
H.

WebFOCUS 8.1.05M
Oracle 11g - DB2
RedHat
 
Posts: 115 | Location: Brighton UK | Registered: February 19, 2005Report This Post
Platinum Member
posted Hide Post
quote:
tweak the JCL to make it comma-delimited


Long as there's no commas in the data either Big Grin.

But seriously I think, if possible, somehow getting the pieces broken apart differently before getting to WF is going to minimize the pulling of your hair out.


JC
WebFOCUS Dev Studio / App Studio
8.2.01
Windows 7
 
Posts: 146 | Registered: November 09, 2015Report 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] Single field with Space Delimiter

Copyright © 1996-2020 Information Builders