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     [CLOSED] In variable with comma seprated values

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] In variable with comma seprated values
 Login/Join
 
Gold member
posted
Hi

can any one give solution for this how to do

Select Emp_ID from emp ;

TABLE FILE SQLOUT
PRINT EMP_ID
ON TABLE HOLD AS EMP_VAL FORMAT ALPHA
END

-RUN
-READ EMP_VAL &EMPID.A10

Values will be storing in this variable(&EMPID) like this (101 102 103 104 105)

But I need to store these values in variable(&EMPID) like this &EMPID = 101,102,103,104,105

and this varable(&EMPID) i need to use in SQL Query

How to do for loop in webfocus ,plz how to do this

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


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 51 | Registered: December 01, 2010Report This Post
Virtuoso
posted Hide Post
Here's one way:

TABLE FILE CAR
PRINT 
 COMPUTE SEQ/I4=SEQ+1; NOPRINT
 COMPUTE COMMA/A1=IF SEQ EQ 1 THEN ' ' ELSE ','; 
 CAR
BY CAR NOPRINT
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS CARLIST FORMAT ALPHA
END


and then
select...
where widget in (
-INCLUDE CARLIST
)
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Gold member
posted Hide Post
-SET &ECHO = ALL;
TABLE FILE CAR
PRINT SEATS
ON TABLE SAVE AS HCOUNTRY
END
-*?FF HCOUNTRY
-*-EXIT
-RUN

-SET &COUNTER=&LINES - 1;
-READ HCOUNTRY &STRING1.A3 NOCLOSE
-SET &STRING = TRUNCATE(&STRING1.EVAL);
-REPEAT READLIST &COUNTER.EVAL TIMES

-READ HCOUNTRY &VALUE1.A3
-SET &VALUE= TRUNCATE(&VALUE1.EVAL);

-SET &STRING='&STRING.EVAL'||','||'&VALUE.EVAL';
-READLIST
-TYPE &STRING


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 51 | Registered: December 01, 2010Report This Post
Virtuoso
posted Hide Post
Deepu

once you have stored the values in a alhpa hold file you can also say


TABLE FILE EMP
PRINT ID
ON TABLE HOLD FORMAT ALPHA
END

TABLE FILE XXXX
PRINT whatever
WHERE KEYFIELD IN FILE HOLD
END


There is a limit on the size of the hold file, the limits depend on the fieldsize and the number of records.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Platinum Member
posted Hide Post
Here's another example using the CAR file.

-*
-** This creates a file of 5 EMP_ID's using the CAR file (holds as SQLOUT)
-*
DEFINE FILE CAR
CNTR/I5 WITH CAR = CNTR + 1;
EMP_ID/A3 = DECODE CNTR (1 '101' 2 '102' 3 '103' 4 '104' 5 '105');
END
-*
TABLE FILE CAR
PRINT EMP_ID
WHERE RECORDLIMIT EQ 5
ON TABLE HOLD AS SQLOUT FORMAT ALPHA
END
-*
-** This creates one record of all EMD_ID's seperated by commas (holds as EMP_VAL)
-** NOTE: works for up to 100 EMP_ID's(If you need more - change the EMP_LIT define statement)
-*
DEFINE FILE SQLOUT
EMP_LIT/A399 = IF EMP_LIT EQ ' '
THEN EMP_ID
ELSE SUBSTR(399, EMP_LIT, 1, 395, 395, 'A395') || (',' | EMP_ID);
END
-*
TABLE FILE SQLOUT
SUM EMP_LIT
ON TABLE HOLD AS EMP_VAL FORMAT ALPHA
END
-RUN
-*
-** This reads the EMP_VAL hold file(one record) into the EMPID variable
-*
-READ EMP_VAL &EMPID.A399
-*
-** This displays the EMPID variable
-*
-TYPE *****************************************************************
-TYPE EMPID --- &EMPID
-TYPE *****************************************************************
-EXIT

Hope this helps.

Jim


WebFocus 8.201M, Windows, App Studio
 
Posts: 227 | Location: Lincoln Nebraska | Registered: August 12, 2008Report This Post
Expert
posted Hide Post
Just shows the flexibility and the many ways to climb the WF mountain! No limitations on this...

  
-SET &LOOP   = 0;
-SET &EMPID  = '101 102 103 104 105 106 107 108 109 110';
-SET &EMP_ID = '';
-*****************************************************
-BUILD_TEST
-*****************************************************
-SET &LOOP   = &LOOP + 1;
-SET &XEMPID = GETTOK(&EMPID, &EMPID.LENGTH, &LOOP, ' ', &EMPID.LENGTH, 'A&EMPID.LENGTH');
-IF &XEMPID EQ '' GOTO BUILD_DONE;
-SET &EMP_ID = IF &LOOP EQ 1 THEN &XEMPID ELSE &EMP_ID || ',' || &XEMPID;
-GOTO BUILD_TEST
-*****************************************************
-BUILD_DONE
-SET &WHERE_BUILD = 'WHERE EMPL_ID IN (' || &EMP_ID || ');';
-*****************************************************
-TYPE  &WHERE_BUILD
-EXIT


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Expert
posted Hide Post
Are the values in a single field ?


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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] In variable with comma seprated values

Copyright © 1996-2020 Information Builders