Focal Point
[SOLVED] Webfocus Newbie Question

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

February 16, 2012, 03:14 PM
joyesiji
[SOLVED] Webfocus Newbie Question
I am new to webfocus and i am trying to achieve the following , I have this code below


TABLE FILE CAR
PRINT COUNTRY CAR MODEL
WHERE CAR EQ 'JAGUAR'
END

this prints


COUNTRY CAR MODEL
ENGLAND JAGUAR V12XKE AUTO
ENGLAND JAGUAR XJ12L AUTO


Now when i run

TABLE FILE CAR
PRINT COUNTRY CAR MODEL
WHERE CAR EQ 'JAG'
END

I get


0 NUMBER OF RECORDS IN TABLE= 0 LINES= 0



I want the result to be

COUNTRY CAR MODEL
no result found


Please how do i achieve this ??

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


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
February 16, 2012, 03:28 PM
Waz
There is a couple of ways to do this, but I would suggest checking the &LINES after the TABLE FILE, and if they are zero, show the empty report.
TABLE FILE CAR
PRINT COUNTRY CAR MODEL
WHERE CAR EQ 'JAG'
END

-RUN

-IF &LINES GT 0 THEN GOTO NEXT_BIT ;

SET EMPTYREPORT = ANSI
TABLE FILE CAR
PRINT COUNTRY CAR MODEL
FOOTING
"no result found "
WHERE CAR EQ 'JAG'
END

-EXIT

-NEXT_BIT


I would also suggest checking out the Dialog MAnager stuff (lines that begin with a dash) and the SET commands. They will help.


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!

February 16, 2012, 03:53 PM
njsden
You could also try using a DUMMY support field and a conditional SUBFOOT to achieve a similar effect while doing only 1 pass over your data:

-DEFAULT &P_CAR = 'JAG';

SET EMPTYREPORT = ANSI

DEFINE FILE CAR
DUMMY/A1 = 'X';
END

TABLE FILE CAR
PRINT COUNTRY CAR MODEL
BY DUMMY NOPRINT

ON DUMMY SUBFOOT
"no result found "
WHEN DUMMY NE 'X';

WHERE CAR EQ '&P_CAR'
END



The EMPTYREPORT = ANSI setting indicated by Waz is the key element for either approach to work.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 16, 2012, 03:54 PM
joyesiji
Yes thanks for the reply. Can i achieve this without putting this in the footing?? I come from a jasper report environment and this is extremely easy in that environment


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
February 16, 2012, 03:59 PM
njsden
Can you? well ... with more work involved, you could perhaps create a fake record and put it there after you verified that no data was found, but the FOOTING/SUBFOOT is much easier.

The question is ... why don't you want to use a FOOTING/SUBFOOT? What difference does it make to your business users who will be ones consuming the report?



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 16, 2012, 04:06 PM
joyesiji
client requirements, Date is the only entry that is supposed to be in the footing


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
February 16, 2012, 04:15 PM
njsden
Is the FOOTING at the bottom of the page? Use then a SUBFOOT as I showed above. The message will show up right below the column titles ad well above the actual FOOTING.

-DEFAULT &P_CAR = 'JAG';

SET EMPTYREPORT = ANSI
SET NODATA = ' '

DEFINE FILE CAR
DUMMY/A1 = 'X';
END

TABLE FILE CAR
PRINT COUNTRY CAR MODEL
BY DUMMY NOPRINT

ON DUMMY SUBFOOT
"no result found "
WHEN DUMMY NE 'X';

WHERE CAR EQ '&P_CAR'

ON TABLE PCHOLD FORMAT PDF

FOOTING BOTTOM
"Run Date: &YYMD"
END




Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 16, 2012, 04:27 PM
joyesiji
Thanks fellows i really appreciate, when i ran the code

i got




COUNTRY CAR MODEL

no result found

Run Date: 20120216



this would have been okay but there should be no line between the title and the "no result found" it should be


COUNTRY CAR MODEL
no result found

Run Date: 20120216


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
February 16, 2012, 04:43 PM
Waz
You can shift things around...

TABLE FILE CAR
PRINT COUNTRY CAR MODEL
WHERE CAR EQ 'JAG'
END

-RUN

-IF &LINES GT 0 THEN GOTO NEXT_BIT ;

SET EMPTYREPORT = ANSI
SET NODATA = ' '
DEFINE FILE CAR
 DUMMY/A1 = ' ' ;
END
TABLE FILE CAR
PRINT COUNTRY CAR MODEL
BY DUMMY NOPRINT
ON DUMMY SUBHEAD
"no result found "
WHERE CAR EQ 'JAG'
FOOTING
"Run Date: &YYMD"
END

-EXIT

-NEXT_BIT



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!

February 16, 2012, 05:15 PM
joyesiji
Lovely Big Grin

It works, starting to enjoy webfocus


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
February 16, 2012, 05:27 PM
Waz
Yay,

Another convert.

Resistance is Futile....




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!

February 17, 2012, 09:34 AM
Anatess
This doesn't really directly answer the question but thought I'd share it anyway.

Most of our reports go on some HTML webpage so, at the end of most of our reports we just tack on a standard empty-report html page.

Like so:

TABLE FILE CAR
PRINT COUNTRY CAR MODEL
WHERE CAR EQ 'JAG'
END
-IF &FOCERRNUM NE 0 THEN GOTO :ERROR;
-IF &LINES EQ 0 THEN GOTO :EMPTYRPT;
-GOTO :ENDFEX


And so, in the bottom of every report (well, it's actually just -included usually) is the following:
-:ERROR
-HTMLFORM SPLASH_ERROR
-GOTO :ENDFEX
-:EMPTYRPT
-HTMLFORM SPLASH_EMPTY
-GOTO :ENDFEX
-:ENDFEX


And then we have a standard HTML page called SPLASH_ERROR.htm and SPLASH_EMPTY.htm that shows a fancy message with a support contact number in case this is not what the user expects.

Hope this helps.


WF 8.1.05 Windows
February 19, 2012, 03:53 PM
Waz
This type of think was discussed a year or two ago.

We have similar.

At the bottom of the page, we have error handling and empty report.


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!