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] Use values in a file in a DEFINE or COMPUTE

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Use values in a file in a DEFINE or COMPUTE
 Login/Join
 
Expert
posted
I thought this would work, but it doesn't - the compute always results in 'NO'. Am I losing my mind or can't we do this?

TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY NE 'W GERMANY'
ON TABLE SAVE AS S001
END
-RUN

TABLE FILE CAR
PRINT COUNTRY CAR MODEL SALES
COMPUTE FLAG1/A3 = IF COUNTRY IN FILE S001 THEN 'YES' ELSE 'NO';
END
-RUN

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
What if you put the compute in a DEFINE first Francis?




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
Expert
posted Hide Post
This doesn't work either:

TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY NE 'W GERMANY'
ON TABLE SAVE AS S001
END
-RUN

DEFINE FILE CAR
FLAG1/A3 = IF COUNTRY IN FILE S001 THEN 'YES' ELSE 'NO';
END

TABLE FILE CAR
PRINT COUNTRY CAR MODEL SALES FLAG1
END
-RUN

I can't seem to find a single example of this.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
I think IN FILE requires a master in order to find/read the file.
but then again....its been a long week.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Virtuoso
posted Hide Post
how about

DEFINE FILE CAR
FLAG0/I2 = DECODE COUNTRY(S001 ELSE 1);
FLAG1/A3=IF FLAG0 EQ 0 THEN 'NO' ELSE 'YES';
END






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
Expert
posted Hide Post
Frank, thank you! While you were typing that example out, I also found it in the documentation under "DECODE: Decoding Values". The solution seems counterintuitive but it works, so thanks very much. Here's my example code corrected:

TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY NE 'W GERMANY'
ON TABLE SAVE AS S001
END
-RUN

DEFINE FILE CAR
NOT_WHAT_I_WANT/I1 = DECODE COUNTRY (S001 ELSE 1); 
FLAG1/A3 = IF NOT_WHAT_I_WANT EQ 1 THEN 'NO' ELSE 'YES';
END

TABLE FILE CAR
PRINT COUNTRY CAR MODEL SALES FLAG1
END
-RUN


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
But I wonder what happens if you say "EQ 'W GERMANY' or 'ITALY'
I think the space between W G will give some problems.




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
Expert
posted Hide Post
You're right! The values in the file must have single quotes. Lucky for me, my real-world file has no blanks.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
I spoke too soon Confused I can't get this to work Confused Confused Confused


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
I'm sure you can Francis

What is the problem? number of records? or spaces...




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
Expert
posted Hide Post
The error message I'm getting is quite misleading:

(FOC272) FORMAT ERROR IN DECODE OR FILE ELEMENT: BCPF030SA


It's the length of the file name that is the problem - here we are in v7.6.5 and the syntax still calls for an 8 character file name (I was using 9).


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
Yes

The 8 character boundary is especially for the younger once Smiler among us a problem.....




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
Expert
posted Hide Post
I haven't used this and I don't know if it will help you but there is a new function called DB_LOOKUP for 7.6.

Here is documentation from the SofNF for 7.6:

Retrieving a Value From a Fixed Format Sequential File in a TABLE Request
The following procedure creates a fixed format sequential file named GSALE from the
GGSALES data source. The fields in this file are PRODUCT (product description), CATEGORY
(product category), and PCD (product code). The file is sorted on the PCD field:
SET ASNAMES = ON
TABLE FILE GGSALES
SUM PRODUCT CATEGORY
BY PCD
ON TABLE HOLD AS GSALE FORMAT ALPHA
END

12. Reporting Language
The following Master File is generated as a result of the HOLD command:
FILENAME=GSALE, SUFFIX=FIX , $
SEGMENT=GSALE, SEGTYPE=S1, $
FIELDNAME=PCD, ALIAS=E01, USAGE=A04, ACTUAL=A04, $
FIELDNAME=PRODUCT, ALIAS=E02, USAGE=A16, ACTUAL=A16, $
FIELDNAME=CATEGORY, ALIAS=E03, USAGE=A11, ACTUAL=A11, $
The following TABLE request against the GGPRODS data source, sorts the report on the field
that matches the key field in the lookup file. It retrieves the value of the CATEGORY field
from the GSALE lookup file by matching on the product code and product description fields.
Note that the DEFINE FILE command is cleared at the end of the request:
DEFINE FILE GGPRODS
PCAT/A11 MISSING ON = DB_LOOKUP(GSALE, PRODUCT_ID, PCD,
PRODUCT_DESCRIPTION, PRODUCT, CATEGORY);
END
TABLE FILE GGPRODS
PRINT PRODUCT_DESCRIPTION PCAT
BY PRODUCT_ID
END
-RUN
DEFINE FILE GGPRODS CLEAR
END

There is more stuff there before and after this example.

I know, I know, I've been reading manuals again. Roll Eyes


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
Virtuoso
posted Hide Post
the DB_LOOKUP is a great function, but it does not always work well.
Small lookup tables do work.




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
Expert
posted Hide Post
Ginny,

Thanks for the suggestion. In this particular case, I'd rather not create masters for the files I want to use in the DECODE.

Regards,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post

I know this states that it's been solved. But, it did not seem that you got your answer. So, try adding this code between your two TABLE FILE requests and change your IN statement to "IN (&CountryList)": in your second TABLE FILE request.


...
-SET &CountryList = '' ;
-REPEAT READ_LOOP &LINES TIMES ;
-READ S001 &ThisCountry.A10.
-SET &CountryList = IF &CountryList EQ ''
- THEN '''' || &ThisCountry || ''''
- ELSE &CountryList || ',' || '''' || &ThisCountry || '''';
-TYPE *** &|ThisCountry = &ThisCountry
-READ_LOOP
-TYPE The following countries are in your SAVE file: &|COUNTRIES.
-RUN
...
COMPUTE FLAG1/A3 = IF COUNTRY IN (&CountryList) THEN 'YES' ELSE 'NO';
...


You'll see the -TYPE messages ("&ThisCountry" and "The following countries are in your SAVE file") in your View Source.
Note: No master file description needed.

-Doug




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
Doug, thanks for your input. My problem was with accessing an external file in a DEFINE or COMPUTE. The solution is to use a DECODE and make sure the file name is 8 characters or less.

Cheers,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
I know it is listed as solved but thought I would throw my 2 cents in. Of course it comes this is using a 'hold' ddname file and that this technique is limited based on the number of bytes being housed in that ddname, but I kept it out of the compute/define range...
TABLE FILE CAR PRINT COUNTRY CAR MODEL
WHERE COUNTRY NE 'W GERMANY'
ON TABLE HOLD AS S001
END
TABLE FILE CAR PRINT COUNTRY CAR MODEL
IF COUNTRY EQ (S001)
END


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
 
Posts: 195 | Registered: October 27, 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] Use values in a file in a DEFINE or COMPUTE

Copyright © 1996-2020 Information Builders