project QadFinancials > class BAPMatching > method AddAPMatchingLn

Description

AddAPMatchingLn: Create an APMatchingLn-record based upon the input parameters


Parameters


icAPMatchingTcRowidinputcharacterTc-rowid of the tAPMatching-record for which you want to create detail lines.
Mandatory
icDomainCodeinputcharacterDomain: this should be the domain that the user logged in on.
if not filled, then the current domain is used.
Mandatory
ilCallGTMinputlogicalCallGTM: set to true in case you want the taxes to be recalculated, set to false if you just want to use the taxes of the pending-voucher.
Note that in case the MatchUnitPrice differs from the PvodUnitPrice or the MatchQty differs from the PvodOpenQty, GTM will be called anyway - even when ilCallGTM is false.
ilFillPendingMatchFieldsinputlogicalFillPendingMatchFields: Set this param to true in case you want to include the assignments for the calculated-fields in tAPMatchingLn that represent the pending matched qty / amount for the pvod that is used on other initial matchings.

These fields are just there for informational-reasons but have no real functionality. So for external, non-UI callers, it is more performing to set this to false
tAPMatchingLnBasedUponPvodinput-outputtemp-tableTemp-table containing the Pvod-data and the APMatchingLn-data: for each entry in this temp-table, an APMatchingLn record will be created
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoiceAPMatching.CreateAPMatchingRun


program code (program8/bapmatching.p)

/* ================================ */
/* Exception handling - Start Block */
/* ================================ */
assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.
MAINADDBLOCK: Do :
    
    /* ================================================================================== */
    /* Validate input in a sub-method: no need to pass the inst-indep temp-table as input */ 
    /* as it is accessible from the sub-method because they are both in the same segment  */
    /* Find the tAPMatching record as we need to make sure it is available                */
    /* ================================================================================== */
    <M-32 run AddAPMatchingLnValidate
       (input-output icAPMatchingTcRowid (bcAPMatchingTcRowid), 
        input-output icDomainCode (bcDomainCode), 
        input-output ilCallGTM (blCallGTM), 
        output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
    if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 then Leave MAINADDBLOCK.
    Find tAPMatching where 
         tAPMatching.tc_Rowid = icAPMatchingTcRowid
         no-lock no-error.
    if not available tAPMatching
    then do :
        assign viLocalReturnStatus = -3
               vcMsgAPMatching     = trim(substitute(#T-17'The system cannot create a matching line because the header cannot be found based on its TC row ID (&1).':255(70301)t-17#,icAPMatchingTcRowid)).
        <M-16 run SetMessage
           (input  vcMsgAPMatching (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-8329':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        Leave MAINADDBLOCK.
    end. /* if not available tAPMatching */
    
    /* ======================================================================================================== */
    /* Make sure the inst-dep class data-item 'ListAccessibleCompanyCodes' that holds the list of company-codes */
    /* that can be accessed by the current user based on the 'entity-securoty' mechnaism of MfgPro.             */
    /* This field can contain a comma-separated list of the CompanyCodes you have acces to the APMathcing.      */
    /* If the value of this parameter is *, then this means you have acces to all companies of the domain.      */
    /* ======================================================================================================== */
    if vcListAccessibleCompanyCodes = ? or 
       vcListAccessibleCompanyCodes = "?":U /* this means it was not yet filled */
    then do : 
         <I-38 {bFcOpenInstance
              &CLASS           = "Session"}>
         <M-39 run GetCompanyListForUserAndDomain
            (input  vcUserLogin (icUserLogin), 
             input  viDomainID (iiDomainID), 
             output vcListAccessibleCompanyCodes (ocCompanyCodeList), 
             output viExternalReturnStatus (oiReturnStatus)) in Session>
         <I-40 {bFcCloseInstance
              &CLASS           = "Session"}>
        if viExternalReturnStatus <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
        if viExternalReturnStatus <  0 then Leave MAINADDBLOCK.
    end. /* if vcListAccessibleCompanyCodes = ? */
    
    /* ======================================================================================== */
    /* Start frequently used queries                                                            */
    /* Start&Open classes - in a different transaction - as it is used in the block to call an  */
    /* instance-less api-method. The classs will be Closed&Stopped after the block              */
    /* This is the most performing way to run an instance-less api-method repetitively          */
    /* ======================================================================================== */
    <I-42 {bFcStartAndOpenInstance
         &ADD-TO-TRANSACTION = "false"
         &CLASS              = "BMfgCosting"}>
    <I-52 {bFcStartAndOpenInstance
         &ADD-TO-TRANSACTION = "false"
         &CLASS              = "PGTM"}>
    
    /* Retrieve pending vouchers for receipt items */
    <M-84 run AddAPMatchingLnNoLC
       (input  icDomainCode (icDomainCode), 
        input  ilCallGTM (ilCallGTM), 
        input  ilFillPendingMatchFields (ilFillPendingMatchFields), 
        output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
    if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.

    /* Retrieve pending vouchers for logistical charges */
    <M-80 run AddAPMatchingLnLC
       (input  icDomainCode (icDomainCode), 
        input  ilCallGTM (ilCallGTM), 
        input  ilFillPendingMatchFields (ilFillPendingMatchFields), 
        output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
    if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.

    /* ======================================== */
    /* Close access to PGTM and BCosting        */
    /* Stop frequently used queries             */
    /* Check for errors in the previous call    */
    /* ======================================== */
    <I-47 {bFcCloseAndStopInstance
         &CLASS           = "BMfgCosting"}>
    assign vlBMfgCostingStart = false.
    <I-49 {bFcCloseAndStopInstance
         &CLASS           = "PGTM"}>
    if viLocalReturnStatus < 0 
    then Leave MAINADDBLOCK.
    
END. /* MAINADDBLOCK */

/* ======================== */
/* Exception handling       */
/* ======================== */
assign oiReturnStatus = viLocalReturnStatus.