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.
Sure, actually that is easier than what you are doing. My guess, if you did a view source, the source would Either use SUBHEADS or HEADING, and fully specify the values, etc. What you want is PRINT SNO SNAME DEPT BY KEY, which you can easily get in the GUI, By bringing up the file in the REPORT PAINTER, and clicking on each of the fields SNO, SNAME and DEPT, and then choosing BY, and click on KEY.
Posts: 60 | Location: 2 penn | Registered: May 22, 2003
MODIFY FILE KEYVALUE DATA 1, Sno:111,$ 1, Sname:xxxx,$ 1, Dept:xxxx,$ 2, Sno:222,$ 2, Sname:xxxx,$ 2, Dept:xxxx,$ END
DEFINE FILE KEYVALUE SNO/A20 = IF VALUE CONTAINS 'Sno' THEN SUBSTR(20,VALUE,5,20,15,SNO); SNAME/A20 = IF VALUE CONTAINS 'Sname' THEN SUBSTR(20,VALUE,7,20,13,SNAME); DEPT/A20 = IF VALUE CONTAINS 'Dept' THEN SUBSTR(20,VALUE,6,20,14,DEPT); END
TABLE FILE KEYVALUE SUM SNO SNAME DEPT BY KEY END
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004
It looks like you want to use Tony's suggestion, with the addition of using POSIT to find the start of the string that contains the value ie: SNO/A20 = IF VALUE CONTAINS 'Sno' THEN SUBSTR(20,VALUE,POSIT(VALUE,20,'Sno',3,'I2')+4, 20,15,SNO); You might also need to something similar to find the substring end point, and its length (instead of the 20,15) otherwise the SNO would contain the sname,dept etc if it was in the string, too.
Posts: 391 | Location: California | Registered: April 14, 2003
If you want a truly versatile method where you do not know what the initial value of the VALUE field is then you could get messy and use this code (against my previous datafile) -
DEFINE FILE KEYVALUE
<br />-* Find the position of the colon marking the end of the data label
<br /> COLEND/I5 = POSIT(VALUE,20,':',1,COLEND);
<br />-* And use it to split out the label itself
<br /> NEWCOL/A20 = SUBSTR(20,VALUE,1,COLEND-1,COLEND-1,NEWCOL);
<br />-* And the actual field value
<br /> NEWVAL/A20 = SUBSTR(20,VALUE,COLEND+1,20,20-COLEND,NEWVAL);
<br />END
<br />
<br />-* Running a BY on the label field we get the unique occurences
<br />TABLE FILE KEYVALUE
<br />BY NEWCOL
<br />-* Which we save and then read back in as variables
<br />ON TABLE SAVE AS NEWCOLS
<br />END
<br />-RUN
<br />
<br />-* Set a count for identifying the new variables
<br />-SET &Cnt = 0 ;
<br />-* And read them in using &LINES to control the number
<br />-REPEAT :ColRead &LINES TIMES ;
<br />-SET &Cnt = &Cnt + 1 ;
<br />-READ NEWCOLS, &Col&Cnt.EVAL.A20.
<br />-:ColRead
<br />
<br />-* Transfer the number of variables we have to a control variable
<br />-SET &NumDefines = &Cnt ;
<br />-* Reset the count
<br />-SET &Cnt = 0 ;
<br />-* And ADD to the defines we already have<br />DEFINE FILE KEYVALUE ADD
<br />-* And add a define for each unique data label
<br />-REPEAT :ColDefine &NumDefines TIMES ;
<br />-SET &Cnt = &Cnt + 1 ;
<br /> &Col&Cnt.EVAL/A20 = IF NEWCOL CONTAINS '&Col&Cnt.EVAL' THEN NEWVAL ELSE IF KEY EQ LAST KEY THEN LAST &Col&Cnt.EVAL ELSE '' ;
<br />-:ColDefine
<br />END
<br />
<br />-* And finally add each new column into the TABLE request
<br />TABLE FILE KEYVALUE
<br />SUM
<br />-SET &Cnt = 0 ;
<br />-REPEAT :ColWrite &NumDefines TIMES ;
<br />-SET &Cnt = &Cnt + 1 ;
<br /> &Col&Cnt.EVAL<br />-:ColWrite
<br />BY KEY
<br />END
The set length of variable at 20 chars is a bit 'naf' to say the least, but it gives you the general idea and, more importantly, gives you the result that you're after.This message has been edited. Last edited by: <Mabel>,
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004