iiCompanyID | input | integer | Id of the company for which you want ot know if the period is open for PC or not. If this parameter is left empty then you have to make sure icCompanyCode is filled |
icCompanyCode | input | character | Code of the company: this parameter has to be filled in case iiCompanyID is empty. If iiCompanyID is filled then this parameter is disregarded. |
iiPeriodYear | input | integer | Accounting year: mandatory |
iiPeriodPeriod | input | integer | Accounting Period: mandatory |
olPeriodIdPostingPCAllowed | output | logical | True in case the period allows periodic-costing postings |
oiReturnStatus | output | integer | Return status of the method. |
/* =============================== */ /* Exception handling - main block */ /* Default output */ /* =============================== */ assign oiReturnStatus = -98 viLocalReturnStatus = 0. MAINGETPCBLOCK: DO : /* ======================================================================= */ /* Validate the input, abandon icCompanyCode in case iiCompanyID is filled */ /* ======================================================================= */ if icCompanyCode = ? then assign icCompanyCode = "":U. if iiCompanyID = ? then assign iiCompanyID = 0. if iiCompanyID <> 0 then assign icCompanyCode = "":U. else do : if icCompanyCode = "":U then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-63'The Entity-code (&1) or Entity-ID (&2) should be specified as parameter for the API method.':255(413966432)T-63#, icCompanyCode, iiCompanyID)). <M-62 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 'QadFin-9806':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPeriod> Leave MAINGETPCBLOCK. end. /* if icCompanyCode = "":U */ else do : <Q-64 run CompanyPrim (all) (Read) (NoCache) (input ?, (LookupCompanyId) input icCompanyCode, (CompanyCode) output dataset tqCompanyPrim) in BCompany > Find tqCompanyPrim where tqCompanyPrim.tcCompanyCode = icCompanyCode no-lock no-error. if not available tqCompanyPrim then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-66'Unable to find the Entity based on its code (&1).':255(73474130)T-66#, icCompanyCode)). <M-65 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 'QadFin-9807':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPeriod> Leave MAINGETPCBLOCK. end. /* if not available tqCompanyPrim */ assign iiCompanyID = tqCompanyPrim.tiCompany_ID. end. /* Not if icCompanyCode = "":U */ end. /* Not if iiCompanyID <> 0 */ if iiPeriodYear = 0 or iiPeriodYear = ? or iiPeriodPeriod = 0 or iiPeriodPeriod = ? then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-47'The Year (&1) and Period (&2) are mandatory parameters for the API method.':255(733734752)T-47#, iiPeriodYear, iiPeriodPeriod)). <M-34 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 'QadFin-9799':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPeriod> Leave MAINGETPCBLOCK. end. /* if iiPeriodYear = 0 or */ /* ======================================= */ /* Query the periods based upon the input */ /* ======================================= */ <Q-67 run PeriodForSubLedgers (all) (Read) (NoCache) (input iiCompanyID, (CompanyId) input iiPeriodYear, (PeriodYear) input iiPeriodPeriod, (PeriodPeriod) input ?, (PeriodId) output dataset tqPeriodForSubLedgers) in BPeriod > Find first tqPeriodForSubLedgers where tqPeriodForSubLedgers.tiCompany_ID = iiCompanyID and tqPeriodForSubLedgers.tiPeriodYear = iiPeriodYear and tqPeriodForSubLedgers.tiPeriodPeriod = iiPeriodPeriod no-lock no-error. If not available tqPeriodForSubLedgers then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-69'Unable to find the Period based upon the Entity (&1), Year (&2) and Period (&3).':255(591290080)T-69#, icCompanyCode,iiPeriodYear, iiPeriodPeriod)). <M-68 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 'QadFin-9808':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPeriod> Leave MAINGETPCBLOCK. end. /* If not available tqPeriodForSubLedgers */ /* ======================== */ /* Set the output parameter */ /* ======================== */ assign olPeriodIdPostingPCAllowed = (tqPeriodForSubLedgers.tlPeriodIsPostingPCAllowed = true). /* =============================== */ /* Exception handling - main block */ /* =============================== */ END. /* MAINGETPCBLOCK */ assign oiReturnStatus = viLocalReturnStatus.
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 = "ApiGetPeriodicCostingPropertyForPeriod". 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.apigetperiodiccostingpropertyforperiod.i.xsd", ?). vhParameter = vhInputDS:get-buffer-handle("tParameterI"). vhParameter:buffer-create(). assign vhParameter::iiCompanyID = <parameter value> vhParameter::icCompanyCode = <parameter value> vhParameter::iiPeriodYear = <parameter value> vhParameter::iiPeriodPeriod = <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.