Focal Point
[SOLVED]Passing Values from one Procedure to Another

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

November 13, 2008, 05:17 PM
<Meghan>
[SOLVED]Passing Values from one Procedure to Another
I have values that I need to pass from one procedure to another and it's not working correctly. Below is my code.

Baseline Value Procedure
TABLE FILE TESTCOREMEASURES
PRINT
Value
WHERE ComparitorDateID1 EQ 'FY2009';
WHERE Location_Parent_ID_caption EQ 'SystemWide';
WHERE Measure_Name1 EQ 'Composite Quality Index - Heart Attack (AMI)';
WHERE Comparitor_Type_Name1 EQ 'Operational Planning Grid - Baseline';
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE SAVE AS BASELINE
END

Target Value Procedure
TABLE FILE TESTCOREMEASURES
PRINT
Value
WHERE ComparitorDateID1 EQ 'FY2009';
WHERE Location_Parent_ID_caption EQ 'SystemWide';
WHERE Measure_Name1 EQ 'Composite Quality Index - Heart Attack (AMI)';
WHERE Comparitor_Type_Name1 EQ 'Operational Planning Grid - Target';
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE SAVE AS TARGET
END

I want the 'Value' data from BOTH procedures to display in a third procedure. I cannot get the last procedure to work. Will someone please post code that will work. I've tried -INCLUDE, -READ, and combinations of all sorts of things. HELP!

This message has been edited. Last edited by: <Meghan>,
November 13, 2008, 05:40 PM
Mighty Max
You can use a MORE statement to concatenate the two table requests.
Look it up in the Developer Studio help.
A MORE statement requires that the two tables be identical.
Each table has to have the same number of columns and the datatypes of the columns should match.
Very similar to a UNION statement in SQL.

  
-* 1st table request we need data from
TABLE FILE CAR
PRINT
     COUNTRY
     CAR
     MODEL
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS TABLE1
END

-* 2nd table request we need data from
TABLE FILE CAR 
PRINT 
     COUNTRY
     CAR
     MODEL 
WHERE COUNTRY EQ 'FRANCE';
ON TABLE HOLD AS TABLE2
END

-* Using MORE statement to concatenate the two tables
TABLE FILE TABLE1
PRINT
     COUNTRY
     CAR
     MODEL
ON TABLE HOLD AS FINAL_TABLE
MORE
FILE TABLE2
END

-* Print the results of our final table
TABLE FILE FINAL_TABLE
PRINT 
     COUNTRY
     CAR
     MODEL
END



WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files
November 13, 2008, 05:51 PM
<Meghan>
I don't want to concatenate the results of the two tables. Here's a visual example of what I'm looking for.

Table 1 produces:
Value
92

Table 2 procduces:
Value
94

I want Table 3 to display:
Value Value
92 94

I want them side by side in the same row not two data pieces in one column.
November 13, 2008, 06:07 PM
GinnyJakes
If you have 3 separate focexecs that run independently, you are going to have to physically save your SAVE files in a permanent location so that can be picked up and -READ in a 3rd program. You would have to filedef baseline.ftm and target.ftm then -READ the contents into amper variables, then use them in a report.

Here is a model for program 3:
APP FI BASELINE DISK your_save_directory/baseline.ftm
APP FI TARGET DISK your_save_directory/target.ftm
-RUN
-READ BASELINE &BASELINE
-READ TARGET &TARGET
DEFINE FILE filename
BASELINE/I2=&BASELINE;
TARGET/I2=&TARGET;
END
TABLE FILE filename
PRINT BASELINE TARGET
BY whatever
END



Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
November 13, 2008, 06:41 PM
<Meghan>
Ginny,

I get the following error using your code:
0 ERROR AT OR NEAR LINE 4 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC374) DIALOGUE MGR VARIABLE IS NOT SPECIFIED BEFORE USE IN -READ: -READ
BASELINE &Value

Basically it's quiting at the 'Define'
November 13, 2008, 07:49 PM
j.gross
Hold rather than Save in the first two procedures; use Match File to merge the two results, and report off the Hold file it produces.


- Jack Gross
WF through 8.1.05
November 14, 2008, 12:26 AM
Robert Freeman
It appears that the data is coming from the same file with the same selections - except that one value is the baseline and the other is the target. You can do this in one pass of the data, in one TABLE request, with no HOLD or SAVE files, MATCH, or -READ. A simple DEFINE will do the trick. Change the WHERE test to include both the Baseline and Target records. Define one value from the database when it matches the selection criteria, or zero if it does not (or blank if the field is alphanumeric). Use SUM MAX. to display the largest value and put both records on the same line.

DEFINE FILE TESTCOREMEASURES
BASELINE/I5=IF Comparitor_Type_Name1 EQ 'Operational Planning Grid - Baseline'
            THEN Value ELSE 0;
TARGET/I5=IF Comparitor_Type_Name1 EQ 'Operational Planning Grid - Target'
            THEN Value ELSE 0;
END
TABLE FILE TESTCOREMEASURES
SUM MAX.BASELINE MAX.TARGET
WHERE ComparitorDateID1 EQ 'FY2009';
WHERE Location_Parent_ID_caption EQ 'SystemWide';
WHERE Measure_Name1 EQ 'Composite Quality Index - Heart Attack (AMI)';
WHERE Comparitor_Type_Name1 EQ 'Operational Planning Grid - Baseline'
                            OR 'Operational Planning Grid - Target';
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE SAVE AS BASELINE
END



Robert Freeman

FOCUS for VM 7.6.x
November 14, 2008, 12:34 AM
Danny-SRL
Meghan,
When you say:
quote:

I want the 'Value' data from BOTH procedures to display in a third procedure

do you mean that each procedure retrieves only 1 value?
where do you want the values to be displayed? in a heading? as a list?
According to your answers, there will be different solutions.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

November 14, 2008, 11:01 AM
Mighty Max
Following j.gross suggestion of using MATCH FILE.

SET ASNAMES = ON

-* 1st table request we need data from
TABLE FILE CAR
PRINT
     COUNTRY AS 'COUNTRY_A'
     CAR     AS 'CAR_A'
     MODEL   AS 'MODEL_A'
     COMPUTE LINK/A4 = 'LINK';
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS TABLE1
END

-* 2ND TABLE REQUEST WE NEED DATA FROM
TABLE FILE CAR 
PRINT 
     COUNTRY AS 'COUNTRY_B'
     CAR     AS 'CAR_B'
     MODEL   AS 'MODEL_B'
     COMPUTE LINK/A4 = 'LINK';
WHERE COUNTRY EQ 'FRANCE';
ON TABLE HOLD AS TABLE2
END


MATCH FILE TABLE1
PRINT
    COUNTRY_A
    CAR_A
    MODEL_A
BY LINK
RUN
FILE TABLE2
PRINT
     COUNTRY_B
     CAR_B
     MODEL_B
BY LINK
AFTER MATCH HOLD AS HOLD1 OLD-OR-NEW
END


TABLE FILE HOLD1
PRINT 
    COUNTRY_A
    CAR_A
    MODEL_A
    COUNTRY_B
    CAR_B
    MODEL_B
END
-EXIT



WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files
November 14, 2008, 11:35 AM
<Meghan>
I've tried the DEFINE suggested by Robert and the MATCH FILE suggested by j.gross and Mighty Max - both to no avail.

To answer Daniel's questions:
Yes, each procedure only retrieves 1 value - a baseline and a target value coming from the same cube.

I want the values to be displayed in the body of a report. What I'm looking for in my final report is this - the name of my measure, the baseline (from procedure 1), the score for my measure, and the target (from procedure 2). I want the two values to be displayed in 1 line.
November 14, 2008, 11:37 AM
<Meghan>
Ginny -

Can you READ a variable with the format D18.2? I think using your suggestion it's actually getting hung up on the READ command.

(FOC299) UNRECOGNIZED FORMAT OF AMPER VARIABLE IN -READ
November 14, 2008, 12:36 PM
<Meghan>
OK...one last message from me. I figured it out. Here's my final code:

BASELINE TABLE
TABLE FILE TESTCOREMEASURES
PRINT
Value AS 'Baseline'
WHERE ComparitorDateID1 EQ 'FY2009';
WHERE Location_Parent_ID_caption EQ 'SystemWide';
WHERE Measure_Name1 EQ 'Composite Quality Index - Heart Attack (AMI)';
WHERE Comparitor_Type_Name1 EQ 'Operational Planning Grid - Baseline';
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE SAVE AS 'BASELINE'
END


TARGET TABLE
TABLE FILE TESTCOREMEASURES
PRINT
Value AS 'Target'
WHERE ComparitorDateID1 EQ 'FY2009';
WHERE Location_Parent_ID_caption EQ 'SystemWide';
WHERE Measure_Name1 EQ 'Composite Quality Index - Heart Attack (AMI)';
WHERE Comparitor_Type_Name1 EQ 'Operational Planning Grid - Target';
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE SAVE AS 'TARGET'
END


FINAL PROCEDURE
-INCLUDE app/testing_baseline.fex
-INCLUDE app/testing_target.fex
-RUN
-READ BASELINE &Baseline.A18
-READ TARGET &Target.A18
DEFINE FILE TESTCOREMEASURES
Baseline/D18.2=&Baseline;
Target/D18.2=&Target;
END
TABLE FILE TESTCOREMEASURES
PRINT
Baseline
Percent_of_Qualifying_Accounts/D12.2%
Target
BY Measure_Set
WHERE Measure_Set EQ 'Composite Quality Index - Heart Attack (AMI)';
ON TABLE NOTOTAL
END


Where it was getting hung up was on the -READ. I did some searching and you cannot use D18.2 as a format in the READ even if the variable you are trying to READ is a D18.2. I had to trick it by putting it as a A18 and then using the DEFINE to set it right again. Works like a charm. No APP FI necessary.

THANK YOU ALL for your help - couldn't have done it without you.