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     Dividing one input-field into several lines of output according to a given separator

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Dividing one input-field into several lines of output according to a given separator
 Login/Join
 
<Stahl>
posted
Hi,

I have a input-field like this :

CC:5675634349,Z. Zidane,5000,00&CC:4757676439,DAVID BECKHAM,10000,00&EC:4545,FIGO&

The &-sign is to be interpreted as a separator.

Now I want to produce a output like this (3 lines for this example):

CC: 5675634349,Z. Zidane,5000,00
CC:4757676439,DAVID BECKHAM,10000,00
EC:4545,FIGO

Does anybody know how to solve this problem?
Thanks for any advice!
Stahl
 
Report This Post
<ineuxf>
posted
Here you will find my solution using CTRAN and GETTOK:

-SET &ECHO=ALL;
-RUN

-* create a file with your test conditions: Ampersand as a delimiter
DEFINE FILE CAR
INFIELD/A80 WITH COUNTRY=
'CC: 567,Z. Zidane,5000,00&|CC: 39,DAVID BECKHAM,100,00&|EC:4545,FIGO&|';
END
TABLE FILE CAR
PRINT
COUNTRY
INFIELD
IF RECORDLIMIT IS 1
ON TABLE HOLD AS HOLDCAR
END

-* Solution with CTRAN and GETTOK
SET STYLEMODE = FIXED
SET PANEL = 145
DEFINE FILE HOLDCAR
-* Ampersand is a reserved sign for Focus Dialog Manager variables.
-* Therefore change Ampersand & to # with the CTRAN function
CHGFIELD/A80 = CTRAN (80,INFIELD,38,35,'A80');
-* pick up the string up to the next # as a new field.
FLD1/A80 = GETTOK(CHGFIELD,80,1,'#',80,'A80');
FLD2/A80 = GETTOK(CHGFIELD,80,2,'#',80,'A80');
FLD3/A80 = GETTOK(CHGFIELD,80,3,'#',80,'A80');
END
TABLE FILE HOLDCAR
"view from HOLDCAR"
PRINT
INFIELD OVER
CHGFIELD OVER
FLD1 OVER
FLD2 OVER
FLD3
BY COUNTRY NOPRINT
END
-EXIT

Result:

PAGE 1

view from HOLDCAR
INFIELD CC: 567,Z. Zidane,5000,00&CC: 39,DAVID BECKHAM,100,00&EC:4545,FIGO&
CHGFIELD CC: 567,Z. Zidane,5000,00#CC: 39,DAVID BECKHAM,100,00#EC:4545,FIGO#
FLD1 CC: 567,Z. Zidane,5000,00
FLD2 CC: 39,DAVID BECKHAM,100,00
FLD3 EC:4545,FIGO


Best regards

Udo from Germany
 
Report This Post
<Stahl>
posted
Thanks a lot, Udo. This works fine!
Best regards
Sonja from Germany
 
Report This Post
<WFUser>
posted
A much cleaner and easier solution would be to create master file using SUFFIX=DFIX as follows:

FILE=AMPTEST,SUFFIX=DFIX,$
SEGNAME=AMPTEST,$
FIELDNAME=DELIMITER, ALIAS=&, USAGE=A1, ACTUAL=A1 ,$
FIELDNAME= FIELD1 ,,A50 ,A50 ,$
FIELDNAME= FIELD2 ,,A50 ,A50 ,$
FIELDNAME= FIELD3 ,,A50 ,A50 ,$

Then just FILEDEF the text file and PRINT the fields using OVER AS '' if you wan them under each other.
 
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     Dividing one input-field into several lines of output according to a given separator

Copyright © 1996-2020 Information Builders