You are here: Development Standards > Routines > General Routines > GENPC

# GENPC

GENPC is a general routine that CALLs GENPC.PUB to return the accounting period associated with a particular date, or to return the beginning and ending dates for an accounting period. GENPC has three entry points: GENPC for loading the table, GENPC1 for converting a month to a period, and GENPC2 for converting a period to beginning and ending dates. The routine resides at lines 9400–9499.

Below is the GENPC description:

Variable | Description
X$ | Company ID
O9$ | Set to string containing the conversion table data

Exit Points | Explanation
RETURN | GENPC normally returns.
GENERROR | GENERROR is invoked to handle errors.

GENPC need be called only once to initialize the O9$ variable. The variable O9$ is used to store a date conversion table. The data is retrieved from the “CNVTxxx ” or “CNVT ” tables in the Resource Manager Tables (RMTB) file. If found, the company-specific table is used before the generic table.

Below is the GENPC1 description:

Variable | Description
X$ | Date mask stored in the global string "DATEMASK"
O9$ | Conversion table data
X | Set to the fiscal period for the date in X$
LOCKFLAG | Returns 1 if the current period/year being checked is locked
INVALIDYEAR | Returns 1 if the year for the given period is not set up and is estimated

Exit Points | Explanation
RETURN | GENPC1 normally returns.
GENERROR | GENERROR is invoked to handle errors.

The call to GENPC is automatic if needed by the GENPC1 call.

Here is the GENPC2 description:

Variable | Description
X | Period for which dates are computed
O9$ | Conversion table data
BEGDATE | Set to the beginning date of the period
ENDDATE | Set to the ending date of the period
LOCKFLAG | Returns 1 if the current period/year being checked is locked
INVALIDYEAR | Returns 1 if the year for the given period is not set up and is estimated

Exit Points | Explanation
RETURN | GENPC2 normally returns.
GENERROR | GENERROR is invoked to handle errors.

The call to GENPC is automatic if needed by the GENPC2 call. If you pass this routine a fiscal period, it attempts to return the beginning and ending dates. At this time it is used only in GL statement printing. You are encouraged to use it, however, if you need the functionality that it provides. Assign variables and GOSUB GENPC2:

`3010 LET X=PD`
`3020 GOSUB GENPC2`
`3030 LET F6=BEGDATE,F7=ENDDATE`

The year portion of the returned dates is taken from the current GL year. If no conversion table exists, the period beginning date is the first day of the current system date month; the period ending date is the current system date.