project QadFinancials > class BRecurringEntry > method ApiPostRecEntryApplyFilter

Description

Method to propose recurring entry postings based on filter values.


Parameters


itTillAccountingDateinputdateDate till when the recurring entry postings should be proposed.
icPostingTemplateCodeinputcharacterPosting Template Code for which the RE-postings should be proposed. (Can be blank or 'all').
icRecEntryFreqinputcharacterFrequency of the RE for which the RE-postings should be proposed. (Can be Period, Monthly, Weekly, Manually, Quarterly, blank or 'all').
icRecEntryUpdateinputcharacterUpdate Type for which the RE-postings should be proposed. (Can be Forbidden, Allowed, Mandatory, blank or 'all').
icJournalCodeinputcharacterJournal Code for which the RE-postings should be proposed. (Can also be blank or 'all').
icRecEntryCodeinputcharacterRecEntryCode
tProposedPostingoutputtemp-tableReturn temp-table containing all proposed postings for the Recurring entries within the filter-range
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program3/brecurringentry.p)

/* ======================================== */
/* PART I. Test if the parameters are valid */
/* ======================================== */

    if icPostingTemplateCode = "All":U or icPostingTemplateCode = ? then assign icPostingTemplateCode = "":U.
    if icRecEntryFreq        = "All":U or icRecEntryFreq        = ? then assign icRecEntryFreq        = "":U.
    if icRecEntryUpdate      = "All":U or icRecEntryUpdate      = ? then assign icRecEntryUpdate      = "":U.
    if icJournalCode         = "All":U or icJournalCode         = ? then assign icJournalCode         = "":U.
    if icRecEntryCode        = "All":U or icRecEntryCode        = ? then assign icRecEntryCode        = "":U.
    
    /* ===================================================== */                                            
    /* Parameter 010: itTillAccountingDate must be a entered */
    /* ===================================================== */
    if itTillAccountingDate = ?
    then do:
        assign vcMessageRE    = trim(#T-12'You must enter the end date.':150(3495)T-12#)
               oiReturnStatus = -1.
        <M-1 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  itTillAccountingDate (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-995':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
    end.
    
    /* ============================================================ */                                            
    /* Parameter 020: icPostingTemplateCode must exist (if entered) */
    /* ============================================================ */
    if icPostingTemplateCode <> "":U
    then do:
        <Q-3 run PostingTemplatePrim (all) (Read) (NoCache)
          (input viCompanyID, (CompanyId)
           input ?, (TemplateID)
           input icPostingTemplateCode, (TemplateCode)
           input ?, (PostingID)
           output dataset tqPostingTemplatePrim) in BPostingTemplate >
        find tqPostingTemplatePrim no-lock no-error.
        if not available tqPostingTemplatePrim
        then do:
            assign vcMessageRE    = trim(substitute(#T-13'The selected Posting Template Code (&1) does not exist.':150(3496)t-13#, trim(icPostingTemplateCode) ))
                   oiReturnStatus = -1.
            <M-2 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  icPostingTemplateCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-996':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
        end.
    end.
    
    /* ===================================================== */                                            
    /* Parameter 030: icRecEntryFreq must exist (if entered) */
    /* ===================================================== */
    if icRecEntryFreq <> "":U
    then do:
        if not (lookup(icRecEntryFreq, {&RECENTRYFREQS}, chr(2))         <> 0 and
                lookup(icRecEntryFreq, {&RECENTRYFREQS}, chr(2)) modulo 2 = 0)    
        then do:
            assign vcMessageRE    = trim(substitute(#T-14'The specified frequency (&1) is invalid.':150(3497)t-14#, trim(icRecEntryFreq) ))
                   oiReturnStatus = -1.    
            <M-6 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  icRecEntryFreq (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-997':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
        end.
    end.
    
    /* ======================================================= */                                            
    /* Parameter 040: icRecEntryUpdate must exist (if entered) */
    /* ======================================================= */
    if icRecEntryUpdate <> "":U
    then do:
        if not (lookup(icRecEntryUpdate, {&RECENTRYUPDATES}, chr(2))         <> 0 and
                lookup(icRecEntryUpdate, {&RECENTRYUPDATES}, chr(2)) modulo 2 = 0)    
        then do:
            assign vcMessageRE    = trim(substitute(#T-15'Update Type (&1) does not contain a valid value.':150(3498)t-15#, trim(icRecEntryUpdate) ))
                   oiReturnStatus = -1.    
            <M-7 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  icRecEntryUpdate (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-998':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
        end.
    end.
    
    /* ==================================================== */                                            
    /* Parameter 050: icJournalCode must exist (if entered) */
    /* ==================================================== */
    if icJournalCode <> "":U
    then do:
        <Q-10 run JournalPrim (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input icJournalCode, (JournalCode)
           input ?, (JournalID)
           output dataset tqJournalPrim) in BJournal >
        find tqJournalPrim no-lock no-error.
        if not available tqJournalPrim
        then do:
            assign vcMessageRE    = trim(substitute(#T-16'The selected daybook code (&1) is not defined in the system.':150(3499)t-16#, trim(icJournalCode) ))
                   oiReturnStatus = -1.
            <M-9 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  icJournalCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-999':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
        end.
    end.

/* ============================= */
/* PART II. Clear the temp-table */
/* ============================= */
    for each tProposedPosting: 
        delete tProposedPosting. 
    end.

    if oiReturnStatus < 0
    then return.

/* ============================== */
/* PART III. Build the temp-table */
/* ============================== */

    /* ================================================== */
    /* Run Query to get all posting proposals for active, */
    /*   waiting Recurring Entry lines within selection   */
    /* ================================================== */
    <Q-11 run RecEntryLineByTillPostingDate (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input itTillAccountingDate, (TillAccountingDate)
        input icPostingTemplateCode, (PostingTemplateCode)
        input icRecEntryFreq, (RecEntryFreq)
        input icRecEntryUpdate, (RecEntryUpdate)
        input icJournalCode, (JournalCode)
        input {&RECENTRYLINESTATUS-WAITING}, (RecEntryLineStatus)
        input true, (RecEntryIsActive)
        input icRecEntryCode, (RecEntryCode)
        output dataset tqRecEntryLineByTillPostingDate) in BRecurringEntry >

    for each tqRecEntryLineByTillPostingDate no-lock:
        /* ================================================ */
        /* Create temp-table record and assign field-values */
        /* ================================================ */
        create tProposedPosting.
        assign tProposedPosting.tcPPJournalCode               = tqRecEntryLineByTillPostingDate.tcJournalCode
               tProposedPosting.tcPPLayerCode                 = tqRecEntryLineByTillPostingDate.tcLayerCode
               tProposedPosting.tcPPPostingTemplateCode       = tqRecEntryLineByTillPostingDate.tcPostingTemplateCode
               tProposedPosting.tiPPPostingID                 = tqRecEntryLineByTillPostingDate.tiPosting_ID
               tProposedPosting.tcPPRecEntryFreq              = tqRecEntryLineByTillPostingDate.tcRecEntryFreq
               tProposedPosting.tcPPRecEntryLineCode          = tqRecEntryLineByTillPostingDate.tcRecEntryLineCode
               tProposedPosting.tcPPRecEntryCode              = tqRecEntryLineByTillPostingDate.tcRecEntryCode
               tProposedPosting.tcPPRecEntryUpdate            = tqRecEntryLineByTillPostingDate.tcRecEntryUpdate
               tProposedPosting.tdPPRecEntryLineAmountLC      = tqRecEntryLineByTillPostingDate.tdRecEntryLineAmountLC
               tProposedPosting.tiPPJournalID                 = tqRecEntryLineByTillPostingDate.tiJournal_ID
               tProposedPosting.tiPPPeriodID                  = tqRecEntryLineByTillPostingDate.tiPeriod_ID
               tProposedPosting.tiPPPeriodPeriod              = tqRecEntryLineByTillPostingDate.tiPeriodPeriod
               tProposedPosting.tiPPPeriodYear                = tqRecEntryLineByTillPostingDate.tiPeriodYear
               tProposedPosting.tiPPPostingTemplateID         = tqRecEntryLineByTillPostingDate.tiPostingTemplate_ID
               tProposedPosting.tiPPRecEntryID                = tqRecEntryLineByTillPostingDate.tiRecEntry_ID
               tProposedPosting.tiPPRecEntryLineID            = tqRecEntryLineByTillPostingDate.tiRecEntryLine_ID
               tProposedPosting.tlPPIsUpdated                 = false
               tProposedPosting.tlPPToPost                    = true
               tProposedPosting.ttPPRecEntryLinePostingDate   = tqRecEntryLineByTillPostingDate.ttRecEntryLinePostingDate
               tProposedPosting.ttPPRecEntryLineReversingDate = tqRecEntryLineByTillPostingDate.ttRecEntryLineReversingDate.
    end. /* for each tqRecEntryLineByTillPostingDate */


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 = "BRecurringEntry".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiPostRecEntryApplyFilter".
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/brecurringentry.apipostrecentryapplyfilter.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::itTillAccountingDate = <parameter value>
       vhParameter::icPostingTemplateCode = <parameter value>
       vhParameter::icRecEntryFreq = <parameter value>
       vhParameter::icRecEntryUpdate = <parameter value>
       vhParameter::icJournalCode = <parameter value>
       vhParameter::icRecEntryCode = <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.