Focal Point
[SOLVED] Date in report header based off of SQL query

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

January 03, 2020, 04:16 PM
Rageoftheage
[SOLVED] Date in report header based off of SQL query
I am using a SQL query in my report with the where condition:

VARIABLE BETWEEN TRUNC(SYSDATE-3,'MON') AND LAST_DAY(SYSDATE-3)

How can I get the header of the report to show the max date of the query result?

Currently doing something like:

HEADING
"Original booking date month-to-date through &DATEDMtYY"


Version is 8008

Thank you Smiler

This message has been edited. Last edited by: FP Mod Chuck,
January 03, 2020, 04:43 PM
Mike Williams
Not totally certain how to do this in one pass, but you could save your results in a hold file, then access that hold file to save your max value as a variable, then create your final report and place that variable in the header.

So a quasi example:

  

SQL
SELECT *
FROM GGORDER
WHERE ORDER_DATE BETWEEN '1996/01/01' AND '1996/02/01';
TABLE ON TABLE HOLD AS HOO1
END
-RUN

-SET &ORDER_DATE = ;

TABLE FILE HOO1
BY HIGHEST 1 ORDER_DATE
ON TABLE HOLD AS MAX_DATE
END
-RUN
-READFILE MAX_DATE
-RUN
-TYPE ORDERDATE = &ORDER_DATE

TABLE FILE HOO1
PRINT ORDER_DATE
STORE_CODE
ORDER_NUMBER
QUANTITY
ON TABLE SUBHEAD
"Original booking date month-to-date through &ORDER_DATE"
ON TABLE PCHOLD FORMAT HTML
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
ON TABLE SET STYLE *
ENDSTYLE
END

-RUN



Hope this helps.

This message has been edited. Last edited by: Mike Williams,


WF Version 8105
January 03, 2020, 06:37 PM
Hallway
quote:
I am using a SQL query


What SQL engine are you using? Sql Server, Oracle, etc?


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
January 06, 2020, 11:38 AM
Rageoftheage
quote:

What SQL engine are you using? Sql Server, Oracle, etc?


Oracle
January 06, 2020, 11:57 AM
Tony A
Any reason that you've decided the following would not suffice?

ON TABLE SUBHEAD
"Original booking date month-to-date through <MAX.ORDER_DATE"


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 
January 06, 2020, 02:12 PM
Rageoftheage
quote:
Originally posted by Tony A:
Any reason that you've decided the following would not suffice?

ON TABLE SUBHEAD
"Original booking date month-to-date through <MAX.ORDER_DATE"


T



I cannot select 'ORDER_DATE' in the query because then I would have to Group By it as well which would break the results. I could aggregate it in the SQL query to avoid grouping by it but I was unaware I could reference a SQL variable within the HEADING quotes with '<'. Looks like my silly brain was over complicating the issue Smiler


It works with the following:

SELECT
MAX(ORDER_DATE) AS MAXDATE

HEADING
"Original booking date month-to-date through
Thank you
January 06, 2020, 02:13 PM
Rageoftheage
quote:
Originally posted by Mike Williams:
Not totally certain how to do this in one pass, but you could save your results in a hold file, then access that hold file to save your max value as a variable, then create your final report and place that variable in the header.

So a quasi example:

  

SQL
SELECT *
FROM GGORDER
WHERE ORDER_DATE BETWEEN '1996/01/01' AND '1996/02/01';
TABLE ON TABLE HOLD AS HOO1
END
-RUN

-SET &ORDER_DATE = ;

TABLE FILE HOO1
BY HIGHEST 1 ORDER_DATE
ON TABLE HOLD AS MAX_DATE
END
-RUN
-READFILE MAX_DATE
-RUN
-TYPE ORDERDATE = &ORDER_DATE

TABLE FILE HOO1
PRINT ORDER_DATE
STORE_CODE
ORDER_NUMBER
QUANTITY
ON TABLE SUBHEAD
"Original booking date month-to-date through &ORDER_DATE"
ON TABLE PCHOLD FORMAT HTML
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
ON TABLE SET STYLE *
ENDSTYLE
END

-RUN



Hope this helps.


When I attempted this solution I was getting

(FOC295) A VALUE IS MISSING FOR: &MAXDATE

Not sure the issue, but thanks for the lead!
January 06, 2020, 03:44 PM
Mike Williams
Could you share your code?


WF Version 8105
January 10, 2020, 10:24 AM
Mike Williams
Oh, I thought you didn't have a resolution on the question.

You may want to edit your post and put a [SOLVED] in the subject.


WF Version 8105