Focal Point
<SOLVED> Coding Question

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

January 28, 2015, 04:55 PM
RobertF
<SOLVED> Coding Question
The user is prompted for a Period whose format is: YYYYMM. Ex: 201207 = July 2012. I need to recode the month of the period to a fiscal month. Ex: 201207 = July 2012 = Fiscal Month 1 of 2012.

HOW CAN I DO THIS? there are no tables involved at this point. Instead of using the prompted parameter for period down the road, I need a new item I can use: FiscalMonth.

Sounds simple but I am unsure how to get started...An EDIT wrapped around the period then evaluate the month---07 = 1, 08 = 2 etc?...not really sure how to do that....

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


WebFOCUS 8206.08
Windows, All Outputs
January 28, 2015, 05:44 PM
Francis Mariani
This won't help you in WF 7.6, but some time in WF 7.7x several Fiscal (Financial) functions were added, like FIYR, FIQTR...

The easiest way to deal with this Dialogue manager variable is with IF-ELSE statements or a DECODE statement, or you could create your own Fiscal function(s).

-SET &PERIOD = '201207';

-*------------------------------------------------------------------------------

-SET &PERIOD_Y = EDIT(&PERIOD, '9999$$');
-SET &PERIOD_M = EDIT(&PERIOD, '$$$$99');

-SET &FPERIOD_M = DECODE &PERIOD_M (
- '01' '07',
- '02' '08',
- '03' '09',
- '04' '10',
- '05' '11',
- '06' '12',
- '07' '01',
- '08' '02',
- '09' '03',
- '10' '04',
- '11' '05',
- '12' '06',
- ELSE '??');

-SET &FPERIOD_Y = IF &PERIOD_M GE '07' THEN &PERIOD_Y + 1 ELSE &PERIOD_Y;

-SET &FPERIOD = &FPERIOD_Y || &FPERIOD_M;

-TYPE &PERIOD / &FPERIOD



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 29, 2015, 08:58 AM
RobertF
THANK YOU. I had part of it last night but got hung up on the syntax for the DECODE.

The next question is can I use: FPERIOD_M in a DEFINE?

I have a horizontal table with columms:
FY
Period1Amount
Period2Amount
.
.
.Period12Amount


Essentially I want to define and item:
NEWAMOUNT: If FPERIOD_M = 1 then Period1Amount
ELSE IF FPERIOD_M = 2 then Period1Amount+Period2Amount etc etc.

I don't see the item: FPERIOD_M avaialble in the list when I try to do a define for the table though....


WebFOCUS 8206.08
Windows, All Outputs
January 29, 2015, 09:05 AM
MartinY
Something like:
DEFINE FILE abc
FPERIOD_M /A2 = "&FPERIOD_M.EVAL";
NEWAMOUNT /P7 = IF FPERIOD_M EQ "01" THEN Period1Amount ELSE IF FPERIOD_M EQ "02" THEN Period1Amount+Period2Amount ELSE ...;
END



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
January 30, 2015, 03:28 AM
Alan B
As the fiscal period is just 6 months behind calendar year, it is simpler to use AYM rather than decodes and IF..THEN..ELSE
-SET &INDATE = 201207;

-SET &FPERIOD_Y = EDIT(AYM(&INDATE,-6,'I6YYM'),'9999$$');
-SET &FPERIOD_M = EDIT(AYM(&INDATE,-6,'I6YYM'),'$$$$99');

-TYPE &FPERIOD_Y
-TYPE &FPERIOD_M



Alan.
WF 7.705/8.007
January 30, 2015, 08:08 AM
RobertF
Thats neat! I thought there would be issues with a period of 201201...period = -05???...but apprently that function somehow knows how to factor that in...it came up with: 06...I'll have to read up on that one!


WebFOCUS 8206.08
Windows, All Outputs