Focal Point
[SOLVED] Passing Values onto HTML docs using !IBI.AMP

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

July 08, 2019, 04:45 PM
John Coleman
[SOLVED] Passing Values onto HTML docs using !IBI.AMP
I am trying to get the value of a field passed from my hold file to display on the HTML document. I know it can be done if the value is a constant by using !IBI.AMP.FOO, where FOO is the defined Amper Variable. When I try to set FOO from a value in my table it will not pass.

Example:

TABLE FILE FOO
COMPUTE FOO_PCT/D3.1% = SUM.FOO.FOO_ONE / SUM.FOO.FOO_TWO * 100;
ON TABLE HOLD AS FOO_HOLD FORMAT BINARY
END
-RUN

If I set an Amper Variable named &TEST to the value of FOO_PCT ( -SET &TEST = FOO.FOO_PCTWink and pass it to my HTML using !IBI.AMP.FOO_PCT, the text that is displayed is "FOO.FOO_PCT", but I am looking to have it display whatever value FOO_PCT calculates out to, say 2.2%.

Is this possible? I am completely lost and trying to see if I am banging my head against a wall for nothing.

John

EDIT - I have an example of what I am trying to do using the wf_lite data set if that would be any less confusing, but it is erroring out so I don't think it would be helpful.

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


John Coleman
WEBFocus 8.1.05
Windows 7
July 08, 2019, 05:02 PM
Hallway
Yes please. Post the wf_lite code to see exactly what you are trying to do.

However, in looking at your post, the variable you are setting is &TEST so in the html, it should be: !IBI.AMP.TEST;


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
July 08, 2019, 05:02 PM
BabakNYC
HOLD will not maintain the formatting masks, only the raw numbers. But to populate an &VAR with the data from this request, you could use -READFILE. Once the numbers are in &variables you can pass them to anything you want. Something like this:

  
-DEFAULTH &FOO_PCT=;
-DEFAULTH &RETAIL_COST=;
-DEFAULTH &DEALER_COST=;
SET HOLDLIST=PRINTONLY
SET ASNAME=ON
TABLE FILE CAR
SUM RETAIL DEALER
COMPUTE FOO_PCT/D12.2 = (RETAIL-DEALER)*100/RETAIL;
ON TABLE HOLD
END
-RUN
-READFILE HOLD
-TYPE &RETAIL_COST &DEALER_COST &FOO_PCT



WebFOCUS 8206, Unix, Windows
July 09, 2019, 10:09 AM
John Coleman
I did find that one of the issues I am running into. I found some documentation about using a -READ statement after the hold table to populate the variable. The issue I am finding now is that the formats have to match and they cannot have a '.' in them. So the code becomes:

TABLE FILE FOO
COMPUTE FOO_PCT/I5 = SUM.FOO.FOO_ONE / SUM.FOO.FOO_TWO * 100; AS 'FOO_PCT'
ON TABLE HOLD AS FOO_HOLD FORMAT BINARY
END
-RUN

-READ FOO_HOLD &FOO_PCT.I5
-TYPE &FOO_PCT

This -READ passes the value into &FOO_PCT but the formats must match and not have a decimal (At least to my research knowledge thus far). So the code above works and gives me an Integer, say 30, but the actual value should be in D3.1%L, say 30.9%. If the format is switched to D3.1%L the code breaks and it requests a value for &FOO_PCT.


So thanks for the help but back to the drawing board, if anyone has any other ideas, I'm open.

@Hallway - I will try to put that up as soon as I work n this a few minutes more.

@BabakNYC - That code was not giving me a value, but I will keep poking at it.


John Coleman
WEBFocus 8.1.05
Windows 7
July 09, 2019, 10:46 AM
BabakNYC
Do you have an error or just no data? If you have car file in your path, you should get data from the -READFILE.


WebFOCUS 8206, Unix, Windows
July 09, 2019, 11:18 AM
Tony A
You might also want to check out DMPRECISION setting if you are going to use decimals in your variables.


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.06 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
July 09, 2019, 11:55 AM
John Coleman
quote:
Originally posted by Hallway:
Yes please. Post the wf_lite code to see exactly what you are trying to do.

However, in looking at your post, the variable you are setting is &TEST so in the html, it should be: !IBI.AMP.TEST;


Here is the code for WF_LITE

-* File: IBFS:/Dev/WFC/Repository/Retail_Samples/~jcoleman/Report1.fex Created by WebFOCUS AppStudio
SET HOLDLIST = PRINTONLY

TABLE FILE WF_RETAIL_LITE
SUM
COMPUTE Sold_per_MSRP/I5 = WF_RETAIL_LITE.WF_RETAIL_SALES.MSRP_US / WF_RETAIL_LITE.WF_RETAIL_SALES.QUANTITY_SOLD; AS 'MSRP_QS'

ON TABLE HOLD AS TEST FORMAT ALPHA


END
-RUN

-READ TEST &MSRP_QS.I5
-TYPE &MSRP_QS


John Coleman
WEBFocus 8.1.05
Windows 7
July 09, 2019, 01:18 PM
Hallway
Try this code
  
-DEFAULTH &MSRP_QS = 0;
-SET DMPRECISION = 2;

SET HOLDLIST = PRINTONLY
SET ASNAMES = ON
SET CENT-ZERO = ON

TABLE FILE WF_RETAIL_LITE
SUM
COMPUTE Sold_per_MSRP/D12.2 = WF_RETAIL_LITE.WF_RETAIL_SALES.MSRP_US / WF_RETAIL_LITE.WF_RETAIL_SALES.QUANTITY_SOLD; AS 'MSRP_QS'
ON TABLE HOLD AS TEST FORMAT BINARY
END
-RUN

-READFILE TEST
-TYPE &|MSRP_QS = &MSRP_QS &MSRP_QS.TYPE

-HTMLFORM BEGIN NOEVAL
<style>
* {
    font-family: 'Trebuchet MS','Lucida Sans Unicode','Lucida Grande','Lucida Sans',Arial,sans-serif;
}
</style>
<h1>The value for &amp;MSRP_QS is: !IBI.AMP.MSRP_QS; </h1>
-HTMLFORM END

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


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
July 09, 2019, 01:28 PM
Hallway
I edited the code above to include the variable in an HTMLFORM


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All