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] Global variables changes

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Global variables changes
 Login/Join
 
Platinum Member
posted
Hi Folks,

I would like to create a loop and exit when a global variable is a certain key value (or when we've reached a certain number of iterations, but I'm clear on that bit). I created some code that sort of works. If &&DEFDB is 'DW_IBI_PROD' when the procedure is initially run, then it exits the loop as desired. If &&DEFDB is not 'DW_IBI_PROD' then it stays in that loop until the counter reaches 36. However if &&DEFDB is changed sometime while I am in the loop (so when the procedure starts it is not 'DW_IBI_PROD' but while its in the loop it is changed to 'DW_IBI_PROD' in some other process), then webfocus is not picking up that change and it is not exiting the loop, which is not desired. I hope that is clear. Here is the code:

-SET &COUNTER=0;

-REPEAT :ENDLOOP WHILE &COUNTER LT 36;

-IF &&DEFDB EQ 'DW_IBI_PROD' GOTO :BYPASS;
-SET &COUNTER = &COUNTER+1;
-SET &DELAY = SLEEP(2,'I6');

-:ENDLOOP

-*Do stuff when &&DEFDB is not 'DW_IBI_PROD'
-*...
-EXIT

-:BYPASS
-*Do stuff when &&DEFDB is 'DW_IBI_PROD'
...



So... ya... how do I make it so that webfocus sees that &&DEFDB has changed while the procedure is running?

Thank you,

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8201, SP 0.1, Windows 7, HTML
 
Posts: 190 | Registered: May 19, 2017Report This Post
Virtuoso
posted Hide Post
quote:
changed while the procedure is running


By procedure do you mean a report or chart? If that's what you're talking about, I don't see how that's possible because by the time WebFOCUS sees TABLE FILE or GRAPH FILE, the &&VARIABLE has been resolved into the value at that moment.


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
So can I have the bit the looks at the global in a separate procedure/fex (it would check if DEFDB is a certain text string and returns the result), then my procedure above can call it and based on the results.

I dont know if that makes sense... basically if you are saying that the moment a procedure/fex file is run, then that is when the global variable is resolved and only then, then I will have to call the same fex file multiple times, and this fex needs to reutrn a value that will help me to determine if the loop should terminate (ie that &&DEFDB = 'DW_IBI_PROD'


WebFOCUS 8201, SP 0.1, Windows 7, HTML
 
Posts: 190 | Registered: May 19, 2017Report This Post
Virtuoso
posted Hide Post
I'm not quite sure but the way variables work is that they have to have a value between TABLE FILE and END. If you add -SET &ECHO=ALL; to the very beginning of your code you'll see how variables are populated with the real value you've provided them.

If you clarify your use case a little more we might be able to suggest a different way you could accomplish it though.


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
Our ETL sets a global variable called &&DEFDB to 'DW_IBI_PROD' when it is done.

I have a scheduled report that runs each morning and it gets emailed out.

I want to delay this report if our ETL took a little longer to run. More specifically, if &&DEFDB is not 'DW_IBI_PROD' then wait ten minutes and check again. If after 6 hours of trying this &&DEFDB is still not 'DW_IBI_PROD' then just give up and kill the schedule by running this -SET &&KILL_RPC='Y';.

If however at any point &&DEFDB does become 'DW_IBI_PROD' then exit the loop and run the schedule.

This procedure (the fex) is run as a pre-processing procedure for the report that will run the actual guts of the report.

I hope I didn't lose you, I thought I kept it simple enough up there. Basicly I was hoping there was a setting that I could set that would allow me to not used a cached copy of the global variable (which is what I think is happening).


WebFOCUS 8201, SP 0.1, Windows 7, HTML
 
Posts: 190 | Registered: May 19, 2017Report This Post
Virtuoso
posted Hide Post
Using below code it does what you want (I think)
-SET &TSTVAR = 'CONTINUE';
-REPEAT LOOP FOR &I FROM 2 TO 5
-IF &TSTVAR EQ 'END' THEN GOTO ENDLOOP;

TABLE FILE CAR
SUM RETAIL_COST
BY COUNTRY
BY SEATS
-*WHERE SEATS EQ &I;
ON TABLE HOLD
END
-RUN
-SET &TSTVAR = IF &LINES EQ 0 THEN 'END' ELSE 'CONTINUE';

-LOOP
-ENDLOOP

As above, it will loop 4 times (from 2 to 5) but if you "activate" the where clause it will only loop twice since there is no seats = 3.

I have not defined a global variable within my sample, but maybe you can try on your side.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Virtuoso
posted Hide Post
This sounds a lot like a use case for Alerts. https://webfocusinfocenter.inf...4C99A2294C62878AF7E0


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Virtuoso
posted Hide Post
quote:
Our ETL sets a global variable called &&DEFDB to 'DW_IBI_PROD' when it is done.


I assume that this is done by writing the whole expression to a fex. If that is true, then you have to include that procedure into your loop.

-SET &COUNTER=0;

-REPEAT :ENDLOOP WHILE &COUNTER LT 36;

-* include the procedure that has the global set.
EX GETDEFDB
-RUN

-IF &&DEFDB EQ 'DW_IBI_PROD' GOTO :BYPASS;
-SET &COUNTER = &COUNTER+1;
-SET &DELAY = SLEEP(2,'I6');

-:ENDLOOP

-*Do stuff when &&DEFDB is not 'DW_IBI_PROD'
-*...
-EXIT

-:BYPASS
-*Do stuff when &&DEFDB is 'DW_IBI_PROD'
...
  


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report 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] Global variables changes

Copyright © 1996-2020 Information Builders