Focal Point
[SOLVED] Condtional Image load

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

November 06, 2014, 12:49 PM
Steven S
[SOLVED] Condtional Image load
I have 2 fex files each with a single numerical output (one represents a CNT at quarter end last quarter, the other represents a CNT at quarter end 2 quarters ago), I want to calculate the difference between those 2 fex files and where Q1 GT Q2 an image of an up arrow, Q1 EQ Q2 an image of a flat arrow, Q1 LT Q2 an image of a down arrow.

This sample car file should get me an up arrow if done correctly, I just cant figure out where I'm going wrong. I am very new at webfocus (started in June) so I could be going all about this wrong, if there is an easier way, please let me know. (I do need to keep the fex files separate from one another as they are referenced in individually throughout reports.)

File 1:Represents one quarter ago

SET ASNAMES = ON
TABLE FILE CAR
SUM
CNT.CAR.COMP.CAR AS 'QUARTER1'
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS Q1HOLD
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
ENDSTYLE
END
-RUN
-READFILE Q1HOLD
-RUN

File 2:Represents two quarter ago

SET ASNAMES = ON
TABLE FILE CAR
SUM
CNT.CAR.COMP.CAR AS 'QUARTER2'
WHERE CAR.COMP.CAR EQ 'BMW';
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS Q2HOLD
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
ENDSTYLE
END
-RUN
-READFILE Q2HOLD
-RUN

File 3: determine difference and upload corresponding jpg image

-IF &QUARTER1 GT &QUARTER2 THEN GOTO UPARROW
- ELSE IF &QUARTER1 EQ &QUARTER2 THEN GOTO FLATARROW
- ELSE IF &QUARTER1 LT &QUARTER2 THEN GOTO DOWNARROW
- ELSE GOTO ENDARROW;
-DOWNARROW
TABLE FILE CAR
SUM
FST.CAR.COMP.CAR NOPRINT AS ''
ON TABLE SUBHEAD
""
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,

$
TYPE=TABHEADING,
IMAGE=IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/down.jpg,
POSITION=(+0.000000 +0.000000),
$
ENDSTYLE
END
-GOTO ENDARROW;
-FLATARROW
TABLE FILE CAR
SUM
FST.CAR.COMP.CAR NOPRINT AS ''
ON TABLE SUBHEAD
""
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,

$
TYPE=TABHEADING,
IMAGE=IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/flat.jpg,
POSITION=(+0.000000 +0.000000),
$
ENDSTYLE
END
-GOTO ENDARROW;
-UPARROW
TABLE FILE CAR
SUM
FST.CAR.COMP.CAR NOPRINT AS ''
ON TABLE SUBHEAD
""
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,

$
TYPE=TABHEADING,
IMAGE=IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/up.jpg,
POSITION=(+0.000000 +0.000000),
$
ENDSTYLE
END
-ENDARROW



WF: Webfocus 8.0.0.7
OS: Windows
Data: SQL
Output: Multiple

This message has been edited. Last edited by: <Kathryn Henning>,
November 07, 2014, 03:08 AM
Alan B
I am not sure where you are going wrong, as logically there should not be an issue if everything is where it is meant to be. There is a simpler approach, but first can you tell us what you are getting, and also run with:
-SET &ECHO=ALL;

at the start and view source to see what is happening.


Alan.
WF 7.705/8.007
November 07, 2014, 07:31 AM
MartinY
I know that this won't solve your issue, but you may simplify a bit your code using this instead.

-SET &IMG = IF &QUARTER1 GT &QUARTER2 THEN 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/up.jpg'
-      ELSE IF &QUARTER1 EQ &QUARTER2 THEN 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/flat.jpg'
-      ELSE 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/down.jpg';

TABLE FILE CAR
SUM
 FST.CAR.COMP.CAR NOPRINT AS ''
ON TABLE SUBHEAD
""
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
 INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
TYPE=TABHEADING,
 IMAGE=&IMG.EVAL,
 POSITION=(+0.000000 +0.000000),
$
ENDSTYLE
END



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
November 07, 2014, 09:14 AM
George Patton
This seems unnecessarily complex. I would use MATCH FILE processing to get the two totals into a single HOLD. You also have a ton of style settings that are just cluttering up your HOLD files.

SET ASNAMES=ON

MATCH FILE CAR
SUM
CNT.CAR.COMP.CAR AS 'QUARTER1'
BY COUNTRY
RUN
FILE CAR
SUM
CNT.CAR.COMP.CAR AS 'QUARTER2'
BY COUNTRY
WHERE CAR.COMP.CAR EQ 'BMW';
AFTER MATCH HOLD AS Q1Q2HOLD
END


Use this resulting HOLD file for the fancy arrows .. Smiler


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
November 10, 2014, 03:12 AM
Dave
How's this...

DEFINE FILE CAR
	Q1/A16 = CAR;
	Q2/A16 MISSING ON = IF CAR EQ 'BMW' THEN CAR ELSE MISSING; 
END

TABLE FILE CAR
SUM 
     CNT.Q1
     CNT.Q2
     COMPUTE ARROW/A5 = IF CNT.Q1 GE CNT.Q2 THEN 'ä' ELSE 'ã'; AS 'updown'
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET STYLE *
$
TYPE=DATA,
     COLUMN=N3,
     FONT='WINGDINGS',
$
ENDSTYLE
END



_____________________
WF: 8.0.0.9 > going 8.2.0.5
November 10, 2014, 03:56 PM
Steven S
George - Match file seems like that could help me get where I need to go. I will give that a shot.

Dave - this would work if some how my defines could reference the output from 2 fex files. My filters are not as basic as I have created in the sample car file ( I only filtered on bmw to get different numbers, thus getting an up arrow), so its a must to reference those other fex files and then calculate the difference.

Martin Y - That code will help me simplify things, still learning, so any advice helps.

Alan - In simple terms, I want to compare the output from 2 fex files and based on the difference between those two files an arrow is represented, my only output would be an arrow. I may not have explained myself very well the first time, I don't know all the lingo quite yet, but I'm trying Smiler

I will test some options and reply back later this week, wife just had a baby 2 days ago, and sleep seems to come few and far between, so sorry for the late response.


WebFOCUS 7.6
Windows, All Outputs
November 11, 2014, 07:47 AM
MartinY
So Steven, having something such as below should do almost what you're looking for.
If I understood properly your request is to "read" two parameters to then assign proper image to display.

SET ASNAMES = ON
-*File 1:Represents one quarter ago
TABLE FILE CAR
SUM
 CNT.CAR AS 'QUARTER1'
ON TABLE HOLD AS Q1HOLD FORMAT BINARY
END
-RUN

-READFILE Q1HOLD
-RUN
-TYPE &QUARTER1

-*File 2:Represents two quarter ago
TABLE FILE CAR
SUM
 CNT.CAR.COMP.CAR AS 'QUARTER2'
WHERE CAR.COMP.CAR EQ 'BMW';
ON TABLE HOLD AS Q2HOLD FORMAT BINARY
END
-RUN

-READFILE Q2HOLD
-RUN
-TYPE &QUARTER2

-* DISPLAY PROPER IMAGE
-SET &IMG = IF &QUARTER1 GT &QUARTER2 THEN 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/up.jpg'
-      ELSE IF &QUARTER1 EQ &QUARTER2 THEN 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/flat.jpg'
-      ELSE 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/down.jpg';

TABLE FILE CAR
BY CAR NOPRINT
WHERE READLIMIT   EQ 1;
WHERE RECORDLIMIT EQ 1;
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
 INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
TYPE=TABHEADING,
 IMAGE=&IMG.EVAL,
 POSITION=(+0.000000 +0.000000),
$
ENDSTYLE
END
-RUN


It may have different way to do it, but this is one.


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
November 14, 2014, 03:19 PM
Steven S
Here is a successful conditional image load using 2 fex files with numerical outputs

FEX FILE 1:

-DEFAULTH &NUMA = 'X'
-DEFAULTH &NUMB = 'T'
DEFINE FILE CAR
NUMA/D6 = 240;
NUMB/D6 = 180;
END
SET HOLDLIST = PRINTONLY
TABLE FILE CAR
SUM MAX.NUMA BY COUNTRY NOPRINT
WHERE READLIMIT EQ 1 WHERE RECORDLIMIT EQ 1
ON TABLE HOLD AS VALA
END
-RUN
-READFILE VALA
TABLE FILE CAR
SUM
MAX.NUMA AS ''
BY COUNTRY NOPRINT
WHERE RECORDLIMIT EQ 1
WHERE READLIMIT EQ 1
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT PDF
END



FEX FILE 2:

-DEFAULTH &NUMA = 'X'
-DEFAULTH &NUMB = 'T'
DEFINE FILE CAR
NUMA/D6 = 240;
NUMB/D6 = 180;
END
SET HOLDLIST = PRINTONLY
TABLE FILE CAR
SUM MAX.NUMB BY COUNTRY NOPRINT
WHERE READLIMIT EQ 1 WHERE RECORDLIMIT EQ 1
ON TABLE HOLD AS VALB
END
-RUN
-READFILE VALB
TABLE FILE CAR
SUM
MAX.NUMB AS ''
BY COUNTRY NOPRINT
WHERE RECORDLIMIT EQ 1
WHERE READLIMIT EQ 1
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT PDF
END


FEX FILE 3:


-SET &NUMC ='&NUMA.EVAL';
-SET &NUMD ='&NUMB.EVAL';

-IF &NUMC LT &NUMD THEN GOTO DOWNARROW ELSE IF &NUMC EQ &NUMD THEN GOTO FLATARROW ELSE IF &NUMC GT &NUMD THEN GOTO UPARROW;

-DOWNARROW

-INCLUDE IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/passvar_DOWNARROW.fex
-GOTO ENDARROW;
-FLATARROW

-INCLUDE IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/passvar_FLATARROW.fex
-GOTO ENDARROW;

-UPARROW

-INCLUDE IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/passvar_UPARROW.fex
-ENDARROW

END


AND THERE ARE 3 FEX FILES THAT WILL BE USED AS THE REFERENCE IMAAGES AND CALCULATE DIFFERENCE, HAD A HARD TIME DIRECTLY REFERENCING IMAGES IN DUE TO THE OUTPUT BEING A PDF, SO I NEEDED TO PUT MY IMAGES IN DATA SERVERS, HERES AN EXAMPLE OF ONE OF THE ARROW FEX FILES


-SET &NUMC ='&NUMA.EVAL';
-SET &NUMD ='&NUMB.EVAL';

DEFINE FILE CAR
DIFFER/D10=&NUMC - &NUMD;
ARROWDEFINED/A200=
IF DIFFER GT 0 THEN 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/up.jpg'
ELSE IF DIFFER EQ 0 THEN 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/flat.jpg'
ELSE 'IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/down.jpg';
END
TABLE FILE CAR
PRINT
COUNTRY NOPRINT
ON TABLE SUBHEAD
" "
" "
" "
WHERE RECORDLIMIT EQ 1
WHERE READLIMIT EQ 1
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$

TYPE=TABHEADING,
IMAGE=IBFS:/WFC/Repository/eGRC/Standard_Reports/SCORECARD/down.jpg,
POSITION=(+0.000000 +0.000000),
$

ENDSTYLE
END
November 14, 2014, 03:24 PM
Steven S
ISSUE SOLVED - THANKS ALL FOR YOUR INPUT. I FOUND THESE FORUMS TO BE A LOT OF HELP.