project QadFinancials > class BGLCalendar > method DataNewMultipleCreateManually

Description

method to be used to create a calendar year manually : default from calendar months


Parameters


iiPeriodYearinputintegerCalendar year to be created
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bglcalendar.p)

/*
* Validate input parameter
*/
if iiPeriodYear = 0 or iiPeriodYear = ?
then do:
    assign vcMessage = trim(#T-1'You must specify the GL calendar year to create.':100(2247)t-1#)
           oiReturnStatus = -1.

    <M-2 run SetMessage (input  vcMessage (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  '':U (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  '':U (icRowid), 
                     input  '-124':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BGLCalendar>
    return.
end.
    
/* Clear the instance */
<M-4 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BGLCalendar>

if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    return.
end.

/*
* Create the year with calendar months
*/
DO viCount = 1 to 12:
    /* Add new period record */
    <M-3 run AddDetailLine (input  'GLCalendar':U (icTable), 
                        input  '':U (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BGLCalendar>
    if viFcReturnSuper <> 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end.

    /* Assign the record values */
    assign tGLCalendar.GLCalendarYear = iiPeriodYear
           tGLCalendar.GLCalendarPeriod = viCount
           tGLCalendar.GLCalendarStartDate = date(viCount, 1, iiPeriodYear)
           tGLCalendar.GLCalendarEndDate = (if viCount = 12
                                            then date(12,31,iiPeriodYear)
                                            else date(viCount + 1, 1, iiPeriodYear) - 1)
           tGLCalendar.GLCalendarTypeCode = {&PERIODTYPECODE-NORMAL}.
end.

/*Sort the table in ASC*/
for each tGLCalendar where 
         tGLCalendar.tc_Status = "N":U use-index i_parent :
    assign tGLCalendar.tc_Rowid = '-' + string(int(substring(tGLCalendar.tc_Rowid,2,length(tGLCalendar.tc_Rowid,"CHARACTER":U),"CHARACTER":U)),'9999').
end.