project QadFinancials > class BPeriod > method ApiCreatePeriod

Description

This method is used to create a new Period by input parameters.


Parameters


iiPeriodYearinputintegerAccounting Year
iiPeriodPeriodinputintegerAccounting Period
icPeriodStatusinputcharacterAccounting Period Status
itPeriodStartDateinputdateAccounting Period Start Date
itPeriodEndDateinputdateAccounting Period End Date
itPeriodLowerLimitDateinputdateAccounting Period Lower Limit Date
itPeriodUpperLimitDateinputdateAccounting Period Upper Limit Date
icPeriodTypeCodeinputcharacterAccounting Period Type Code
ilPeriodIsPostingPurchAllowedinputlogicalPeriod allows Purchase Postings
ilPeriodIsPostingGLAllowedinputlogicalPeriod allows GL Account Postings
ilPeriodIsPostingSalesAllowedinputlogicalPeriod allows Sales Postings
ilPeriodIsPostingOtherAllowedinputlogicalPeriod allows Other Postings
ilPeriodIsPostingInvAllowedinputlogicalPeriod allows Invoice Postings
ilPeriodIsReportCheckedinputlogicalPeriod Is Reported
oiPeriod_IDoutputintegerAccounting Period ID
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program3/bperiod.p)

<M-6 run AddDetailLine (input  'Period':U (icTable), 
                        input  '':U (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

if not available tPeriod
then do:
    find first tPeriod no-error.
    if not available tPeriod
    then do:
        <M-2 run SetMessage
          (input  #T-7'Created GL period was not found.':60(3096)T-7# (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  2 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-862':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BPeriod>
        assign oiReturnStatus = -1.
        return.
    end.
end.

assign tPeriod.PeriodYear       = iiPeriodYear
       tPeriod.PeriodPeriod     = iiPeriodPeriod
       tPeriod.PeriodYearPeriod = iiPeriodYear * 100 + iiPeriodPeriod
       tPeriod.PeriodStatus     = icPeriodStatus
       tPeriod.PeriodTypeCode   = icPeriodTypeCode
       tPeriod.PeriodStartDate  = itPeriodStartDate
       tPeriod.PeriodEndDate    = itPeriodEndDate
       tPeriod.PeriodIsPostingGLAllowed = ilPeriodIsPostingGLAllowed
       tPeriod.PeriodIsPostingInvAllowed = ilPeriodIsPostingInvAllowed
       tPeriod.PeriodIsPostingOtherAllow = ilPeriodIsPostingOtherAllowed
       tPeriod.PeriodIsPostingPurchAllow = ilPeriodIsPostingSalesAllowed
       tPeriod.PeriodIsPostingSalesAllow = ilPeriodIsPostingSalesAllowed
       tPeriod.PeriodIsReportChecked = ilPeriodIsReportChecked
       oiPeriod_ID = tPeriod.Period_ID.

/* validate */
<M-3 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

/* additional updates */
<M-4 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

/* save */
<M-5 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.


Sample code: how to call this method through RPCRequestService (QXtend Inbound)

define temp-table ttContext no-undo
    field propertyQualifier as character
    field propertyName as character
    field propertyValue as character
    index entityContext is primary unique
        propertyQualifier
        propertyName
    index propertyQualifier
        propertyQualifier.

define dataset dsContext for ttContext.

define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.

/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
       ttContext.propertyValue = "BPeriod".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiCreatePeriod".
create ttContext.
assign ttContext.propertyName = "applicationId"
       ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
       ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
       ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
       ttContext.propertyValue = "".

/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bperiod.apicreateperiod.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiPeriodYear = <parameter value>
       vhParameter::iiPeriodPeriod = <parameter value>
       vhParameter::icPeriodStatus = <parameter value>
       vhParameter::itPeriodStartDate = <parameter value>
       vhParameter::itPeriodEndDate = <parameter value>
       vhParameter::itPeriodLowerLimitDate = <parameter value>
       vhParameter::itPeriodUpperLimitDate = <parameter value>
       vhParameter::icPeriodTypeCode = <parameter value>
       vhParameter::ilPeriodIsPostingPurchAllowed = <parameter value>
       vhParameter::ilPeriodIsPostingGLAllowed = <parameter value>
       vhParameter::ilPeriodIsPostingSalesAllowed = <parameter value>
       vhParameter::ilPeriodIsPostingOtherAllowed = <parameter value>
       vhParameter::ilPeriodIsPostingInvAllowed = <parameter value>
       vhParameter::ilPeriodIsReportChecked = <parameter value>.

/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").

if not vhServer:connected()
then do:
    message "Could not connect AppServer" view-as alert-box error title "Error".
    return.
end.

/* Run */
assign vhContextDS = dataset dsContext:handle.

run program/rpcrequestservice.p on vhServer
    (input-output dataset-handle vhContextDS by-reference,
           output dataset-handle vhExceptionDS,
     input        dataset-handle vhInputDS by-reference,
     input-output dataset-handle vhInputOutputDS by-reference,
           output dataset-handle vhOutputDS).

/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).

if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).

/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.

if valid-handle(vhInputDS)
then delete object vhInputDS.

if valid-handle(vhOutputDS)
then delete object vhOutputDS.

if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.