Hi Everyone

        A couple of days ago, I saw a post inquiring how to determine
the GL Period to which a particular date belonged.  After responding
with a quick answer, which I fund out subsequemtly had a logic error in
it, I thought about it and realized that this would be something for
which a generic macro could be very useful.

        I have posted the code for just such a macro below.  Storing
this macro in a report in either an MIS DPM or the Z DPM would allow you
to access the macro from any application for your reports and
dramatically simplify this process.  The documentation for this macro
follows and then the code.  Hope you find this useful.

Sincerely
Ken

Application     ALL 
Subject                 Report Writer 
Title           Get GL Period Info 
Description     DPM     MIS.QUERY
Report          zcus.npr.macro.library
Macro           get.period

Purpose

     This macro will take a GL period or a Date as input and return the
GL Period information for that GL Period or Date

A     GL Period or Date

     If a date is entered, the routine determines the GL Period in which
that date falls.  If a GL Period is entered, the routine proceeds.  This
routine will return period and fiscal information for the GL Period
entered or derived above.

The period information includes

GL Period
GL Period Start Date
GL Period End Date


The fiscal information includes

Fiscal Year
Fiscal Year Start Date
Fiscal Year End Date

The information is returned as a packed variable in the following format

{{GL.Period,GL.Period.Start.Date,GL.Period.End.Date},
 {Fiscal.Year,Fiscal.Year.Start.Date,Fiscal.Year.End.Date}}^XX

XX|0 = Period.Info
XX|1 = Fiscal.Info

Period.Info|0 = GL.Period
Period.Info|1 = GL.Period.Start.Date
Period.Info|2 = GL.Period.End.Date

Fiscal.Info|0 = Fiscal.Year
Fiscal.Info|1 = Fiscal.Year.Start.Date
Fiscal.Info|2 = Fiscal.Year.End.Date


~~~~~~~~~~~~~~~~~  Macro Code Starts Here  ~~~~~~~~~~~~~~~~~~~~~~~~~~

;Programmer : Ken MacPherson               Created : July 17, 2007
;Purpose    : Return Period dates for a period
;           : Return Period for a date
@SETUP,
@PROCESS.PERIOD,
{PR.PERIOD,PR.START,PR.END}^PERIOD,
{FY.YEAR,FY.START,FY.END}^FISCAL,
%Z.debug("TEST"),
{PERIOD,FISCAL};

SETUP
A^MIS.GL.PERIOD.period,
IF{MIS.GL.PERIOD.main;
   @PROCESS.DATE}

PROCESS.DATE
A^MIS.GL.PERIOD.ending.date,
IF{MIS.GL.PERIOD.date.x;
   @Next(MIS.GL.PERIOD.ending.date,MIS.GL.PERIOD.date.x),
   MIS.GL.PERIOD.date.x}^MIS.GL.PERIOD.period

PROCESS.PERIOD
@GET.FISCAL.YEAR.INFO,
@GET.PERIOD.INFO

GET.FISCAL.YEAR.INFO
@MIS.GL.PERIOD.fiscal.year^MIS.GL.PERIOD.fiscal.year^FY.YEAR,
""^MIS.GL.PERIOD.ending.date,
@Prev(MIS.GL.PERIOD.ending.date,MIS.GL.PERIOD.year.date.x)^FY.END,
@MIS.GL.PERIOD.fiscal.year-1^MIS.GL.PERIOD.fiscal.year,
""^MIS.GL.PERIOD.ending.date,
@Prev(MIS.GL.PERIOD.ending.date,MIS.GL.PERIOD.year.date.x),
%Z.date.add(MIS.GL.PERIOD.ending.date,1)^FY.START

GET.PERIOD.INFO
MIS.GL.PERIOD.period^PR.PERIOD,
@MIS.GL.PERIOD.ending.date^MIS.GL.PERIOD.ending.date^PR.END,
@Prev(MIS.GL.PERIOD.ending.date,MIS.GL.PERIOD.date.x),
%Z.date.add(MIS.GL.PERIOD.ending.date,1)^PR.START

~~~~~~~~~~~~~  Macro Code Ends Here  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
To subscribe or unsubscribe to the meditech-l, visit 
http://mtusers.com/mailman/listinfo/meditech-l_mtusers.com

To check the status of the meditech-l, visit MTUsers.NET

For help, email [EMAIL PROTECTED]

Please visit and add information to the MTUsers WikiPedia at MTUsers.NET/mwiki
______________________________________
meditech-l mailing list
[email protected]
http://mtusers.com/mailman/listinfo/meditech-l_mtusers.com

Reply via email to