Focal Point
[SOLVED] Include with variables

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2087028726

January 11, 2013, 12:32 PM
benicely
[SOLVED] Include with variables
According to this link, it appears to send variables to another FEX using include, you just set the variables with the normal -SET syntax.

For example:

-SET &PARAM1 = 'Val1'
-SET &PARAM2 = 'Val2'

-INCLUDE fextoinclude.fex


I'm having a problem of not getting any data inside my other fex unless I assign defaults in the fextoinclude file.

Is this normal, or am I missing something?

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


WebFOCUS 7.6
Windows, All Outputs
January 11, 2013, 12:56 PM
Mighty Max
Something is not right. Are your two fex files in the same folder? An -INCLUDE basically appends the code into the calling fex.
Below are two fex files. If you run fex1.fex you can see that you do not need a DEFAULT for &COUNTRY. Although having a DEFAULT does not hurt anything. The SET will takes precedent over the DEFAULT.

  
-* File fex1.fex
-SET &COUNTRY = 'ENGLAND';
-INCLUDE fex2.fex


-* File fex2.fex
TABLE FILE CAR
PRINT
   COUNTRY
WHERE COUNTRY EQ '&COUNTRY';
END



WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files
January 11, 2013, 01:54 PM
benicely
Thanks Max!

Your code does work. In fact, expanding your code to replicate what I'm trying to do appears to be working too.

Something must be wrong in my other code that I'm going to have to figure out.

Just in case it helps anyone else, here is the expanded version of the code similar to what I'm attempting to do.

  
-* File fex1.fex
-SET &COUNTRY = 'ENGLAND';
-INCLUDE fex2.fex

TABLE FILE TEMP1
PRINT *
END

-* File fex2.fex
TABLE FILE CAR
PRINT
   COUNTRY
WHERE COUNTRY EQ '&COUNTRY';
ON TABLE HOLD AS TEMP1
END



WebFOCUS 7.6
Windows, All Outputs
January 11, 2013, 02:45 PM
FrankDutch
The sequence is wrong

The part that does the reporting from the temp file should be at the 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

January 11, 2013, 02:51 PM
Crymsyn
I am not sure if this is the reason why your first code wasn't working but WebFOCUS sometimes gets upset when you do not end a -SET with a ;

-SET &PARAM1 = 'Val1';
-SET &PARAM2 = 'Val2';

-INCLUDE fextoinclude.fex


Also, I am not sure if you run reports without saving much but includes use the last saved version.


WF: 8201, OS: Windows, Output: HTML, PDF, Excel
January 11, 2013, 04:28 PM
benicely
Frank,

So you're saying that fex2.fex should do the reporting and not do a table hold with fex1.fex printing information about what is in the table hold? It is a fluke that this works as written?

Crymsyn,

Sorry my first post was wrong, I meant to type a semicolon at the end of my set statements. My code does have a semicolon, and it's not bringing back any results unless I have defaults in fex2.fex.


WebFOCUS 7.6
Windows, All Outputs
January 11, 2013, 04:47 PM
benicely
Sorry everyone, I figured it out. The database changed on me, so the variables were being passed to the other fex correctly. My table query in fex2 was executing correctly and getting no data. Since there was no data to print, it was correctly saying there were no rows returned. ;-)


WebFOCUS 7.6
Windows, All Outputs