Focal Point
[SOLVEDCalculating a date to serve as the default filter parameter value for a report

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

January 25, 2018, 04:01 PM
Dale Davaz
[SOLVEDCalculating a date to serve as the default filter parameter value for a report
Hi everyone,

We're on WebFOCUS 8201 and I'm in AppStudio trying to supply a calculated default value (the last day of the previous month) to a filter parameter (&KEYDATE), so report users can accept that freshly-calculated default value or choose to overwrite it before running the report.

I thought it'd be pretty straightforward, using the -SET command and some date math to calculate the previous EOM variable, formatting the result as MM/DD/YYYY, and then supply that to a -DEFAULT command situated just prior to the report to be run:

quote:

-SET &DT1 = DATECVT(DATEADD(DATECVT(&YYMD,'I8YYMD','YYMD'),'M', -1),'YYMD','I8YYMD');
-SET &DT2 = DATECVT(DATEMOV(DATECVT(&DT1,'I8YYMD','YYMD'),'EOM'),'YYMD','I8YYMD');
-SET &DT3 = EDIT(&DT2,'$$$$99')|'/'|EDIT(&DT2,'$$$$$$99')|'/'|EDIT(&DT2,'9999');

-* -TYPE &DT3

-DEFAULT &KEYDATE = &DT3.EVAL;

TABLE FILE A_ACCT_DEPOSIT_DLY
SUM
A_ACCT_DEPOSIT_DLY.DEPOSIT_ACCOUNT_DAILY.DLY_BAL/D12.2CM AS 'SVG_BAL1'
BY LOWEST A_ACCT_DEPOSIT_DLY.MEMBER.MBR_NUM AS 'MBR_NUM'
WHERE ( A_ACCT_DEPOSIT_DLY.DATE_EFFECTIVE.DTE EQ '&KEYDATE.EVAL' ) AND (( A_ACCT_DEPOSIT_DLY.PRODUCT.PROD_TYPE_CD EQ 'SV' ) OR ( A_ACCT_DEPOSIT_DLY.PRODUCT.PROD_ID EQ 'CKG280' ) OR ( A_ACCT_DEPOSIT_DLY.PRODUCT.PROD_ID EQ 'CKG281' )) AND ( A_ACCT_DEPOSIT_DLY.MEMBER.IS_MBR_FLAG EQ 'Y' ) AND ( A_ACCT_DEPOSIT_DLY.BALANCE_STATUS.BAL_STAT EQ 'Active' ) AND (( A_ACCT_DEPOSIT_DLY.MEMBER.MBR_CLASS_CD GE '100' ) AND ( A_ACCT_DEPOSIT_DLY.MEMBER.MBR_CLASS_CD LE '199' ));
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
ENDSTYLE
END


When I uncomment the -TYPE command and test the date math, it returns what I'd hope (a value of 12/31/2017). But when I run the procedure, the filter parameter displays not the calculated value, but the character string '&DT3.EVAL' (without the quotes).

Can techniques along these lines be used to supply a calculated value to the -DEFAULT command? Is there some modest tweak I can make to get the scripting above to work? I sure appreciate any insights!

Dale Davaz
daled@stcu.org

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


WebFOCUS 8.2
January 25, 2018, 04:51 PM
jfr99
How about something like this ...

-*
-DEFAULT &KEYDATE = '.'
-*
-TYPE -----------------
-TYPE YYMD ------------ &YYMD
-TYPE KEYDATE --------- &KEYDATE
-TYPE -----------------
-IF NOT (&KEYDATE EQ '.' OR ' ') GOTO :USE_DATE ;
-SET &KEYDATE = FPRINT(DATEMOV(DATEADD(DATECVT(&YYMD,'I8YYMD','MDYY'),'M',-1),'EOM'),'MDYY','A10');
-TYPE ** CALCULATE NEW KEYDATE **
-:USE_DATE
-TYPE KEYDATE --------- &KEYDATE
-TYPE -----------------


WebFocus 8.201M, Windows, App Studio
January 25, 2018, 04:58 PM
Francis Mariani
WHERE ( A_ACCT_DEPOSIT_DLY.DATE_EFFECTIVE.DTE EQ '&KEYDATE.EVAL' )


Try removing the .EVAL here, you don't need it.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 25, 2018, 05:08 PM
Francis Mariani
I've time-machined back to v7.7.05 and lost my v8 memory, but I don't think this is kosher any more:

-DEFAULT &KEYDATE = &DT3.EVAL;


I don't think you can set a -DEFAULT to a variable...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 25, 2018, 05:19 PM
Dale Davaz
Thanks, Francis. I worried that might be the case. I'll supply a simple string as the default to at least serve as a format example, but that may be the best that's possible.

No luck going the route suggested by jfr99, I'm afraid. Try as I might, only line 002 gets read and rendered (though I may not have implemented his idea properly).

I'll check back on this thread as I can over the next few days, but I'll figure for now that I've ventured into the tall grass with this exploration.

All the same, runtime-calculatable parameter defaults sure seem like they'd be a nice feature to have, if the powers that be cared to take a swing at supporting them! :-)

--Dale


WebFOCUS 8.2
January 25, 2018, 05:29 PM
David Briars
Is your requirement to set &KEYDATE to value of &DT3 in Dialogue Manager?

If so you would want to use a -SET command.

Something like:
 -SET &KEYDATE = &DT3;  

January 25, 2018, 05:34 PM
Doug
What date format do you want? Are you using an HTML page to pass the parameters in?




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
January 25, 2018, 07:04 PM
Dale Davaz
Thanks for chiming in, David and Doug.

David, I'm hoping to have report users engage an HTML page and be prompted with a filter parameter box that invites them to supply the date that'll be used by the filter in the report. I'd like to "seed" that field with a calculated default value equal to the last day of the previous month, whatever that figures out to be, given the runtime date. But users should be able to overwrite that default value, also.

Doug, ultimately the date that users are being asked to submit should be in the format MDYY... but I can manipulate other formats into the proper one, if necessary. Yes, we're using the WebFOCUS report server interface, so folks are interacting with an HTML page to submit inputs for parameters.

Thanks for your interest in this question!

--Dale


WebFOCUS 8.2
January 26, 2018, 09:02 AM
jfr99
You can create a new fex like this ...

TABLE FILE SYSTABLE
PRINT NAME NOPRINT
COMPUTE DEF_DATE/MDYY = DATEMOV(DATEADD(DATECVT(&YYMD,'I8YYMD','MDYY'),'M',-1),'EOM');
WHERE RECORDLIMIT EQ 1
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE PCHOLD FORMAT XML
END

And then in your launch page via App Studio, you can make an explicit call to this fex (in Settings for your date parameter) and get the value from DEF_DATE.

Then in the Parameters tab ... bind DEF_DATE to your calendar control

This will pre-load that control with the last day of the previous month but still allow your user to select a different date.

Hope this helps.


WebFocus 8.201M, Windows, App Studio
January 26, 2018, 11:17 AM
Dale Davaz
Thanks for that additional insight, jfr99!

Even if one can't use a variable to supply a value to the -DEFAULT WebFOCUS command and keep matters quite that simple, you rightly point the way to binding a custom control whose default value comes from an external .fex and leverage that in a more sophisticated HTML application context.

I'll absolutely roll up my sleeves and take a swing at that approach at my next opportunity.

I really appreciate everyone's quick responses!

--Dale


WebFOCUS 8.2