project QadFinancials > class BPeriod > method ApiUpdatePeriodStatus

Description

This method is used to update the specific periods status.


Parameters


iiPeriod_IDinputintegerAccounting Period ID
iiPeriodYearinputintegerAccounting Year
iiPeriodPeriodinputintegerAccounting Period
icStatusinputcharacterAccounting Period Status
ilIsReportCheckedinputlogicalFlag if period is Report Checked
ilClearDatainputlogicalClear existing data in the instance
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program3/bperiod.p)

if ilClearData
then do:
    <M-1 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end.

if iiPeriod_ID = 0 or
   iiPeriod_ID = ?
then do:
    <Q-19 run PeriodPrim (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input ?, (PeriodId)
           input iiPeriodYear, (PeriodYear)
           input iiPeriodPeriod, (PeriodPeriod)
           output dataset tqPeriodPrim) in BPeriod >    
    
    find first tqPeriodPrim no-error.
    if not available tqPeriodPrim
    then do:
        assign oiReturnStatus = -1.
        return.
    end.
    assign iiPeriod_ID = tqPeriodPrim.tiPeriod_ID.
end.

<M-2 run DataLoad
          (input  '':U (icRowids), 
           input  string(iiPeriod_ID) (icPkeys), 
           input  '':U (icObjectIds), 
           input  '' (icFreeform), 
           input  if ilClearData then no else yes (ilKeepPrevious), 
           output viFcReturnSuper (oiReturnStatus)) in BPeriod>

if viFcReturnSuper <> 0
then do:
    <M-3 run SetMessage
          (input  #T-23'Cannot load the GL period ($1).':200(3056)t-23# (icMessage), 
           input  string(iiPeriod_ID) (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  2 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-789':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BPeriod>
    assign oiReturnStatus = -1.
    return.
end.
find first tPeriod where tPeriod.Period_ID = iiPeriod_ID no-error.
if not available tPeriod
then do:
    <M-4 run SetMessage
          (input  #T-24'The data has been successfully loaded, but the GL period record ($1) is not available.':200(3057)t-24# (icMessage), 
           input  string(iiPeriod_ID) (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  2 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-790':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BPeriod>
    assign oiReturnStatus = -1.
    return.
end.

if tPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED} and
   icStatus = {&PERIODSTATUS-REPORTED}
then do:
    <M-5 run SetMessage
          (input  #T-25'The GL period $1 has already been reported.':150(3058)t-25# (icMessage), 
           input  string(iiPeriod_ID) (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-791':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BPeriod>
    
    assign oiReturnStatus = -1.
    return.
end.

if ilIsReportChecked <> ?
then assign tPeriod.PeriodIsReportChecked = ilIsReportChecked.

if icStatus <> ? and 
   icStatus <> "":U
then do:
    assign tPeriod.PeriodStatus = icStatus.
    if icStatus <> {&PERIODSTATUS-REPORTED} and 
       icStatus <> {&PERIODSTATUS-FROZEN}
    then assign tPeriod.PeriodIsReportChecked = false.
end.

assign tPeriod.tc_Status          = "C":U.  

<I-10 {bFcOpenInstance
            &CLASS           = "Session"}>

<M-14 run GetLogicalValue (input  'BPeriodIsCalledFromTheClosing':U (icName), 
                           output vlTemp (olValue), 
                           output viFcReturnSuper (oiReturnStatus)) in Session>
<M-13 run SetLogicalValue (input  'BPeriodIsCalledFromTheClosing':U (icName), 
                           input  true (ilValue), 
                           output viFcReturnSuper (oiReturnStatus)) in Session>

<I-12 {bFcCloseInstance
            &CLASS           = "Session"}>

<M-7 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = -1.
    return.
end.

<M-8 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = -1.
    return.
end.

<M-6 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = -1.
    return.
end.

<I-20 {bFcOpenInstance
            &CLASS           = "Session"}>

<M-21 run SetLogicalValue (input  'BPeriodIsCalledFromTheClosing':U (icName), 
                           input  vlTemp (ilValue), 
                           output viFcReturnSuper (oiReturnStatus)) in Session>

<I-22 {bFcCloseInstance
            &CLASS           = "Session"}>


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 = "ApiUpdatePeriodStatus".
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.apiupdateperiodstatus.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiPeriod_ID = <parameter value>
       vhParameter::iiPeriodYear = <parameter value>
       vhParameter::iiPeriodPeriod = <parameter value>
       vhParameter::icStatus = <parameter value>
       vhParameter::ilIsReportChecked = <parameter value>
       vhParameter::ilClearData = <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.