As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
The code above looks crazy, but what's happening is you have to convert the alpha string to a Date format using DATECVT, then use DATEADD to add 7 days, then use DATECVT to convert from Date format back to alpha string - read the line of code form inside going outwards.
Recently I wrote a few DEFINE FUNCTIONs to determine Fiscal periods for a given date. The DEFINE FUNCTIONs can be used in WebFOCUS reporting and Dialogue Manager. I had to create these because there aren't any IBI supplied functions to do this as the Fiscal period is company dependent.
This led me to think about creating DEFINE FUNCTIONs that would simplify calling existing Date functions in Dialogue Manager. In the example above, you have to first convert the DM variable to a Date format (DATECVT), then call the Date function (DATEADD), then convert the Date format back to a DM variable (DATECVT).
Using the DEFINE FUNCTION below, you simply have to call the function passing the required parameters, no conversion necessary - the DEFINE FUNCTION takes care of that. You can create a DEFINE FUNCTION for each of the Date functions commonly used, put them in an INCLUDEd fex, then simply call the DEFINED FUNCTION.
The DEFINE FUNCTION for DATEADD:
DEFINE FUNCTION UDATEADD(INDATE/A8YYMD, INUNIT/A2, INNBR/I4)
INDATE1/YYMD = INDATE;
UDATEADD1/YYMD = DATEADD(INDATE1, INUNIT, INNBR);
UDATEADD/A8YYMD = UDATEADD1;
END
-RUN
NOTE: The DATEADD function allows multiple Date formats as input ("any day-based non-legacy date, for example, YYMD, MDY, or JUL"), my example uses only YYMD because that format is what I always use in my programs, the DEFINE FUNCTION could probably be modified to work with multiple formats.
I think this would simplify things quite a bit if this kind of manipulation is used a lot. I hope you find this useful.
Those Fiscal period functions:
-*-- Beginning of Fiscal Quarter
DEFINE FUNCTION BOFQ(INDATE/A8)
INDTYYA/A4 = EDIT(INDATE,'9999$$$$');
INDTYY/I4 = EDIT(INDTYYA);
OUTDTYY/I4 = INDTYY - 1;
INDTMD/A4 = EDIT(INDATE,'$$$$9999');
BOFQ/A8 =
IF INDTMD FROM '1101' TO '1231' THEN INDTYYA || '1101' ELSE
IF INDTMD FROM '0101' TO '0131' THEN EDIT(OUTDTYY) || '1101' ELSE
IF INDTMD FROM '0201' TO '0430' THEN INDTYYA || '0201' ELSE
IF INDTMD FROM '0501' TO '0731' THEN INDTYYA || '0501' ELSE
IF INDTMD FROM '0801' TO '1031' THEN INDTYYA || '0801' ELSE INDATE;
END
-RUN
-*-- End of Fiscal Quarter
DEFINE FUNCTION EOFQ(INDATE/A8)
INDTYYA/A4 = EDIT(INDATE,'9999$$$$');
INDTYY/I4 = EDIT(INDTYYA);
INDTMD/A4 = EDIT(INDATE,'$$$$9999');
OUTDTYY/I4 = INDTYY + 1;
EOFQ/A8 =
IF INDTMD FROM '1101' TO '1231' THEN EDIT(OUTDTYY) || '0131' ELSE
IF INDTMD FROM '0101' TO '0131' THEN INDTYYA || '0131' ELSE
IF INDTMD FROM '0201' TO '0430' THEN INDTYYA || '0430' ELSE
IF INDTMD FROM '0501' TO '0731' THEN INDTYYA || '0731' ELSE
IF INDTMD FROM '0801' TO '1031' THEN INDTYYA || '1031' ELSE INDATE;
END
-RUN
-*-- Beginning of Fiscal Year
DEFINE FUNCTION BOFY(INDATE/A8)
INDTYYA/A4 = EDIT(INDATE,'9999$$$$');
INDTYY/I4 = EDIT(INDTYYA);
INDTMM/A2 = EDIT(INDATE,'$$$$99$$');
OUTDTYY/I4 = IF INDTMM LT '11' THEN INDTYY - 1 ELSE INDTYY;
BOFY/A8 = EDIT(OUTDTYY) || '1101';
END
-RUN
-*-- End of Fiscal Year
DEFINE FUNCTION EOFY(INDATE/A8)
INDTYYA/A4 = EDIT(INDATE,'9999$$$$');
INDTYY/I4 = EDIT(INDTYYA);
INDTMM/A2 = EDIT(INDATE,'$$$$99$$');
OUTDTYY/I4 = IF INDTMM LT '11' THEN INDTYY ELSE INDTYY + 1;
EOFY/A8 = EDIT(OUTDTYY) || '1031';
END
-RUN
For documentation on creating DEFINE FUNCTIONs, look for "Creating Temporary Fields Unrelated to Master Files" in the "Creating Reports With WebFOCUS Language" manual. For documentation on Date functions, look for "Date and Time Functions" in the "WebFOCUS Using Functions" manual.This message has been edited. Last edited by: Francis Mariani,
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