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     reference fields in a hold file in -IF .. THEN GOTO ..

Read-Only Read-Only Topic
Go
Search
Notify
Tools
reference fields in a hold file in -IF .. THEN GOTO ..
 Login/Join
 
<bigpgo>
posted
Hello. I'm trying to compute something with an SQL query, and use that value to determine what GOTO to jump to:

SQL
SELECT MAX(cost) AS MAX_COST FROM ...;
TABLE
ON TABLE HOLD AS myReport
END
-RUN

TABLE FILE myReport
PRINT
COMPUTE myCost/I5 = MAX_COST;
END
ON TABLE HOLD AS myReport2
END

-IF myReport2.myCost EQ 10 THEN GOTO OUT;
....
some other stuff done here
...
-OUT

I know that myCost is 10 (I printed it), but I never jump to OUT. It's as if it ignores this value, or cannot reference it properly in myReport2. Any help appreciated.
 
Report This Post
Silver Member
posted Hide Post
maybe something like:

SQL
SELECT MAX(cost) AS MAX_COST FROM ...;
TABLE FILE SQLOUT
PRINT *
ON TABLE SAVE
END
-RUN
-READ SAVE &MCOST

-IF &MCOST EQ 10 THEN GOTO OUT;
....
some other stuff done here
...
-OUT


hth,

drew
 
Posts: 46 | Location: San Francisco, California | Registered: April 14, 2003Report This Post
Virtuoso
posted Hide Post
Make sure you know how wide the field is when stored in SAVE, and initialize &MCOST to that width (or specify it in the -READ).
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
<bigpgo>
posted
Thanks for the replies. I tried it just like you said (and added the width):
-READ SAVE &MCOST.I22

But it's asking me to enter a value for MCOST. If I specify "no input parameters" in the properties, it says MCOST value is missing. Any thoughts?
 
Report This Post
Virtuoso
posted Hide Post
Some suggestions:

1. Are you sure that the COST variable stored in SAVE is USAGE=I22 (or P22)? Check the MFD of the source table.

2. Add:
-SET &MCOST='0000000000000000000000';
-* (or any string value 22 characters wide)
to initialize &MCOST to the appropriate length before the -READ, instead of specifying format in the -READ

3. Add
-TYPE ## &|MCOST:
-TYPE ## '&MCOST'
-TYPE ## *123456789.123456789.123456789.
before and after the read, to verify what value &MCOST received (length, content).

4. Use EDIT() to force evaluation as an integer:
-IF EDIT(&MCOST) EQ 10 ...
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Guru
posted Hide Post
-IF myReport2.myCost EQ 10 THEN GOTO OUT;

-READ SAVE &MCOST.I22

Why are are you specifying I22? The width being referred to is the width of the value, not the width of the qualified field name.

Integer formats are generally I9 or less.
 
Posts: 346 | Location: Melbourne Australia | Registered: April 15, 2003Report This Post
<Pietro De Santis>
posted
The best way for us to help you would be to post an example that we can run on our P.C's.

Here is an example of using Dialog Manager to read a value from a HOLD or SAVE file and then use the value for further processing. This example also illustrates that, in Dialog Manager, you can read a value as an alpha field, but use it in numeric calculations.

The problem you're encountering may be occuring because I22 is not a valid numeric format, there is a maximum length for Integer fields, I10, I think.

SET HOLDLIST=PRINTONLY
TABLE FILE CAR
PRINT RETAIL_COST/P22
WHERE RECORDLIMIT EQ 1
ON TABLE SAVE
END
-RUN
-READ SAVE &RET_COST.A22

-TYPE &RET_COST

-SET &RET_COST2 = &RET_COST * 239;
-TYPE &RET_COST2
-IF &RET_COST GT 5000 GOTO OVER_5;

-TYPE UNDER 5000

-OVER_5

-TYPE OVER 5000

(There's ampersands on all the Dialog Manager variables in case this forum removes them)
 
Report This Post
<bigpgo>
posted
Pietro, your solution worked. Specifically, this line:

SET HOLDLIST=PRINTONLY

was very important. If I dont have this line, the code doesnt work (it then thinks that MYCOST field that I compute is 0 in my -IF statement, all the time).

One question that I have is: can you provide a code sample that reads from a HOLD file, not a SAVE file? I tried doing:

SET HOLDLIST=PRINTONLY
TABLE FILE report1
PRINT
COMPUTE MYCOST/I5 = MAX_COST;
ON TABLE HOLD AS report2
END
-RUN
-READ report2 &MYCOST.I5

-IF &MYCOST GT 5 GOTO OVER_5;

But it complains that value for MYCOST is missing. What's the proper syntax? Thanks a lot.
 
Report This Post
<Pietro De Santis>
posted
ON TABLE HOLD FORMAT ALPHA

Format Alpha is very important if you want to read the file with Dialog Manager or copy the HOLD file for use with a non-FOCUS program.

According to the manual, FORMAT HOLD creates a BINARY file, the data is not stored as you may expect.

I always use ON TABLE HOLD FORMAT ALPHA, even if I'm not going to read the file with Dialog Manager.

I hope this helps.

SET HOLDLIST=PRINTONLY
TABLE FILE CAR
PRINT RETAIL_COST/I5
WHERE RECORDLIMIT EQ 1
ON TABLE HOLD FORMAT ALPHA
END
-RUN

-READ HOLD &RET_COST.I5


-TYPE &RET_COST
 
Report This Post
<bigpgo>
posted
That worked beautifully, thanks a lot.
Complete code:

SET HOLDLIST=PRINTONLY
TABLE FILE report1
PRINT
COMPUTE MYCOST/I5 = MAX_COST;
ON TABLE HOLD AS report2 FORMAT ALPHA
END
-RUN
-READ report2 &MYCOST.I5

-IF &MYCOST GT 5 GOTO OVER_5;
 
Report This Post
Platinum Member
posted Hide Post
Hi Just as a last note... if you have more than one param, just separate them in the same READ line

like ...

-READ HOLDFILE &X.A1 &Y.A2

etc. Just make sure you refer to every field in the correct order of course.
 
Posts: 246 | Location: Montreal, QC, Canada | Registered: October 01, 2003Report 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     reference fields in a hold file in -IF .. THEN GOTO ..

Copyright © 1996-2020 Information Builders