Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Reusable code: X months ago

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Reusable code: X months ago
 Login/Join
 
Silver Member
posted
Good Morning,

I currently use this code:
&YYMD = 05/01/2012

-SET &MYYEAR = DATECVT(DATEADD(DATECVT (&YYMD, 'I8YYMD', 'YYMD'),'M', -5 ), 'YYMD','YY');
-SET &MYMONTH = DATECVT(DATEADD(DATECVT (&YYMD, 'I8YYMD', 'YYMD'),'M', -5 ), 'YYMD','M');

MYYEAR --> returns the year from 5 months ago = 2011
MYMONTH --> returns the month from 5 months ago = 12

We do this a lot. I would LOVE to make this simpiler by building a DEFINE FUNCTION that will calculate the year by passing in 2 variables (aDate, aMonthsAgo). I gave it a try but I keep getting the following error. Can someone point me in the correct direction?

My code:
DEFINE FUNCTION GETYEAR(myDate/I8YYMD, pastMonths/I2)
GETYEAR/YY = DATECVT(DATEADD(DATECVT (myDate, 'I8YYMD', 'YYMD'),'M', pastMonths ), 'YYMD','YY');;
END

-SET &MYYEAR = GETYEAR(&YYMD, -4, 'YY');
-RUN
-TYPE &MYYEAR
-EXIT

My Error:
(FOC263) EXTERNAL FUNCTION OR LOAD MODULE NOT FOUND: GETYEAR

Thank you for taking the time to read and help.

Nick

This message has been edited. Last edited by: Kerry,
 
Posts: 37 | Registered: January 11, 2008Report This Post
Virtuoso
posted Hide Post
  
DEFINE FUNCTION GETYEAR(myDate/I8YYMD, pastMonths/I2)
GETYEAR/YY = DATECVT(DATEADD(DATECVT (myDate, 'I8YYMD', 'YYMD'),'M', pastMonths ), 'YYMD','YY');
END
-RUN
-SET &MYYEAR = GETYEAR(&YYMD, -4);
-RUN
-TYPE &MYYEAR
-EXIT

This works.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Silver Member
posted Hide Post
Daniel, that works great.

To Recap: The difference between my code (not working) and your code (working):
1) Add the RUN statement after the DEFINE FUNCTION
2) Remove the extra ; (wish Dev Studio could tell me I did this :-)
3) Remove the data type in the calling of GETYEAR()

Thank you.
 
Posts: 37 | Registered: January 11, 2008Report This Post
Expert
posted Hide Post
you know about the AYMD and AYM functions?




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Expert
posted Hide Post
Ahich one's "extra"?
quote:
2) Remove the extra ;




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Silver Member
posted Hide Post
quote:
Originally posted by susannah:
you know about the AYMD and AYM functions?


Agreed WF offers a lot of options for working with dates. The reason why I didn't choose to use AYM is because of the required date format of (Year/Month). I like working with full dates. Even if the end game is just using the Month or Year format. AYMD I see no need for :-), but that is because my apps are mostly months at a time, and not X # of days.
 
Posts: 37 | Registered: January 11, 2008Report This Post
Silver Member
posted Hide Post
quote:
Originally posted by Doug:
Ahich one's "extra"?
quote:
2) Remove the extra ;


Sorry I wasn't more clear, the "fixes" were based on the original post code. Just wanted to offer readers the ability to see what was wrong with the original, and how the second one fixed it. I guess I just added more confusion.
 
Posts: 37 | Registered: January 11, 2008Report This Post
Expert
posted Hide Post
Nick, the most important thing here is the -RUN.

Dialog Manager is always parsed first, so when the -SET with GETYEAR is parsed, the DEFINE FUNCTION has not yet been processed.

The -RUN forces WebFOCUS to process up to the -RUN, then continue the parsing.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Reusable code: X months ago

Copyright © 1996-2020 Information Builders