Focal Point
[SOLVED] storing Totals or Values as &var

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

October 13, 2015, 01:15 PM
Nicholas Spyrison
[SOLVED] storing Totals or Values as &var
Not sure about the best way to describe this, but;
End goal: find the percentage Revenue for each Market of the total revenue for the company; 100*(Market Revenue)/(Company Revenue)

I have several HOLD files going down to, and joined at the Market Grain.
I have a separate component finding Revenue at the Company level. I can't display the Market Grained Key without the revenue being broken down by market (I think this is a cube oddity). Without the Key I can't join it to the Market Grain holds.

So is there any way I can store Company Revenue in an &var? Be it a field, from Total, or in DM? other work-arounds?


Thanks!

This message has been edited. Last edited by: Nicholas Spyrison,


_____
WF 8.1.04
Win 7// Windows Server 2012 R2
SASS OLAP Cube
October 13, 2015, 01:43 PM
MartinY
With something similar to this you can extract the company revenue
TABLE FILE CAR
SUM DEALER_COST AS 'REVENUE'
ON TABLE HOLD AS HLD FORMAT BINARY
END
-RUN
-READFILE HLD
-RUN
-TYPE REVENUE: &REVENUE

Perform on your own Revenue at the Company level file.


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
October 13, 2015, 03:47 PM
Nicholas Spyrison
quote:
TABLE FILE CAR
SUM DEALER_COST AS 'REVENUE'
ON TABLE HOLD AS HLD FORMAT BINARY
END
-RUN
-READFILE HLD
-RUN
-TYPE REVENUE: &REVENUE


But then it just parameter prompts for &REVENUE
shouldn't we have to -SET &REVENUE?

maybe something like the follwoing?

-RUN
-READFILE HLD
-RUN
-SET &REVENUE = <REVENUE;
-TYPE REVENUE: &REVENUE 


or is there something I am missing?
I am using an alpha hold file.


_____
WF 8.1.04
Win 7// Windows Server 2012 R2
SASS OLAP Cube
October 13, 2015, 05:10 PM
Waz
Add a -DEFAULTH for &REVENUE, this will stop the prompting


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!

October 13, 2015, 05:42 PM
Nicholas Spyrison
Wouldn't that defeat the point? I am trying to store &REVENUE dynamically, not default it to a value.


_____
WF 8.1.04
Win 7// Windows Server 2012 R2
SASS OLAP Cube
October 13, 2015, 05:52 PM
Waz
My assumption is that the fex exists in MRE and when the code is executed, it is scanned for & variables.
If there is no -SET or -DEFAULT(S|H) before the variable it will be prompted.

Adding the -DEFAULTH before(Actually, probably anywhere) the -READFILE will fix this.


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!

October 13, 2015, 06:40 PM
Nicholas Spyrison
I feel like my knowledge is lacking...

Is the -READFILE HLD just going to push <|var into &var then?

I'll try mocking something simpler up in CAR tomorrow. My fex is getting too busy.


_____
WF 8.1.04
Win 7// Windows Server 2012 R2
SASS OLAP Cube
October 13, 2015, 07:15 PM
Waz
Wait till you have a fex that is over 13k lines...
Eeker


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!

October 14, 2015, 04:46 AM
Tony A
Nicholas,

A -DEFAULT(H) will provide a value for the variable if it is not -SET within your process.

A -READ, -SET or -READFILE will override any -DEFAULT that you have previous applied.

As has been mentioned a few times on the Forum recently, -DEFAULTH will be "ignored" by parameter prompting.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
October 14, 2015, 08:35 AM
J.L. Hinds
Try this. You need to read in the var name.

TABLE FILE JACK1
WHERE LISTIT EQ &HOW_MANY;
WRITE CUM_TA_SHR
ON TABLE HOLD AS 'JEFFX' FORMAT ALPHA
END

-RUN
-READ JEFFX &POT.A6.
-RUN


WebFOCUS 7.6
Windows, All Outputs
October 14, 2015, 08:50 AM
MartinY
J.L., you method is also good, but you have to be aware of the field format.

Using READFILE all hold field become a variable, you don't mind the format and the variable has the field name as its &var name.

Both method is good. With READFILE you also don't mind about order of fields when you reference them and you can have 4 fields in the hold file but only reference the first and third one, per example. With READ it's important to READ all the &var in the same order/format as they have been hold.


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
October 14, 2015, 11:26 AM
Nicholas Spyrison
quote:
Wait till you have a fex that is over 13k lines...


App studio struggles (or crashes) switching between components of a 250 line, 12 component fex with our set up. How does everyone else manage? tweaking tomcat sever allocation?


I digress...

I have the following working. Note that SET ASNAMES=ON is important here. I will relay this attempt back to my original fex.

SET ASNAMES = ON
TABLE FILE IBISAMP/CAR
SUM
     DEALER_COST AS 'REVENUE'
ON TABLE NOTOTAL
ON TABLE HOLD AS HLD FORMAT BINARY
END
-RUN
-DEFAULTH &REVENUE = 0
-READFILE HLD
-RUN
-TYPE REVENUE: &REVENUE



_____
WF 8.1.04
Win 7// Windows Server 2012 R2
SASS OLAP Cube
October 14, 2015, 05:42 PM
Nicholas Spyrison
OK have it working as expected. Thanks everyone!


_____
WF 8.1.04
Win 7// Windows Server 2012 R2
SASS OLAP Cube
October 14, 2015, 08:24 PM
Ricardo Augusto
I am sure Waz uses a 13k lines fex to do a complex ETL with a lot of MATCHES, JOINS, DEFINES, MODIFYs and etc.

He also should use any text editor to edit those 13k fex under approot. Am i right?


WebFOCUS 8.1.05 / APP Studio
October 15, 2015, 05:17 PM
Waz
In this case yes all done in a text editor, GUI could not handle the code. The code was in the APP path, but this fex (Actually group of fexes) produced statements and I would confidently state that is may be the most complex fex ever done. Certainly in the top 10.

[ Waits for head swelling to subside ]


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!

October 16, 2015, 03:29 PM
Pondog
Ok so

quote:
A -DEFAULT(H) will provide a value for the variable if it is not -SET within your process.

A -READ, -SET or -READFILE will override any -DEFAULT that you have previous applied.

As has been mentioned a few times on the Forum recently, -DEFAULTH will be "ignored" by parameter prompting.


Given this; if I have < -DEFAULTH &FM=' ' > then the variable &FM has some value, however, if I have < -DEFAULTH &WFFMT = 'HTML' > then my variable &WFFMT contains 'HTML'. In either case I won't be prompted for the values of these variable; is that right?

I know this is such a newbie question, but I'm getting there. slowly

Also

-READFILE RPTPERIOD tells me that the fields in RPTPERIOD can be used as variables in any order as long as they are in the same format; is that correct?

Thanks for any clarification you can offer!

Pondog


WebFOCUS 8.1.05
Windows, All Outputs
October 16, 2015, 03:44 PM
MartinY
quote:
Given this; if I have < -DEFAULTH &FM=' ' > then the variable &FM has some value, however, if I have < -DEFAULTH &WFFMT = 'HTML' > then my variable &WFFMT contains 'HTML'. In either case I won't be prompted for the values of these variable; is that right?

Correct. As long as &FM and &WFFMT don't receive any other value as input parameter from another fex or HTML page they will keep the DEFAULTH value and you won't be prompted to provide values.

quote:
Also-READFILE RPTPERIOD tells me that the fields in RPTPERIOD can be used as variables in any order as long as they are in the same format; is that correct?

Correct. But if there are 4 fields in RPTPERIOD, they don't need to be all in same format. You can have 3 alphanumeric and 1 numeric field. READFILE will assign the proper format to each as they are in the TABLE FILE.


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
October 16, 2015, 04:23 PM
Pondog
Outstanding! Thanks a bunch, MartinY


WebFOCUS 8.1.05
Windows, All Outputs