project QadFinancials > class BCInvoiceAPMatching > method CreateCInvoiceAPMatchingGetCInvoiceData

Description

CreateCInvoiceAPMatchingGetCInvoiceData: submethod of CreateCInvoice that fill the class-level data-item vhCInvoiceData that points to the newly created invoice


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoiceAPMatching.CreateCInvoiceAPMatchingAllInOneTran
method BCInvoiceAPMatching.CreateCInvoiceAPMatchingOneInOneTran


program code (program6/bcinvoiceapmatching.p)

/* =================================================================================================== */
/* Method      : CreateCInvoiceAPMatchingGetCInvoiceData                                               */
/* Desc        : Submethod of CreateCInvoiceAPMatching that fill the class-level data-item             */
/*               vhBCInvoiceInstanceData that points to the newly created invoice                      */
/* =================================================================================================== */
    
    
    /* ====================================================================== */
    /* Return in case the callers do not require to get back the invoice data */
    /* ====================================================================== */
    if vlReturnCInvoiceInstanceData <> true
    then Return.
    
    /* ====================== */
    /* Default error-handling */
    /* ====================== */
    assign oiReturnStatus = -98
           viLocalReturn  = 0.
           
    /* =========== */
    /* Start Block */
    /* =========== */
    GETINSTDATABLOCK: DO:
        
        /* =========================================================================== */
        /* Get Instance-info about the SupplierInvoice-instance out of the Transaction */
        /* =========================================================================== */
        <M-76 run GetInstanceDetails
           (input  'BCInvoice':U (icComponentShortName), 
            input  viCompanyId (iiCompanyIdOfInstance), 
            output viBCInvoiceFromBCIAPMID (oiInstanceId), 
            output vhBCInvoiceFromBCIAPMInst (ohInstanceHandle), 
            output viFcReturnSuper (oiReturnStatus)) in Transaction>
        if viFcReturnSuper <> 0 
        then assign viLocalReturn = viFcReturnSuper.
        if viFcReturnSuper < 0 
        then Leave GETINSTDATABLOCK.
        
        /* =================================================================================================================================== */
        /* Get Instance data from Supplier invoice component and store it in the class-level handle vhBCInvoiceInstanceData                    */
        /* The call to GetDBDatasetHandle will return a local dataset with only one invoice (vhBCInvoiceInstanceDataOneInst) and then we add   */
        /* the content of it to the dataset holding all invoices being handled in this class (class-level handle vhBCInvoiceInstanceData)      */
        /* =================================================================================================================================== */
        if viBCInvoiceFromBCIAPMID <> ? and
           viBCInvoiceFromBCIAPMID <> 0
        then do:
            /* Open instance of BCI */
            if not valid-handle(vhBCInvoiceFromBCIAPMInst)
            then do:
                <I-9 {bFcOpenInstance
                     &CLASS           = "BCInvoice"}>
                assign vlBCInvoiceIsOpenedHere = true.
            end. /* if not valid-handle(vhBCInvoiceFromBCIAPMInst) */
            /* BCI:GetDBDatasetHandle will return a local dataset with only one invoice (vhBCInvoiceInstanceDataOneInst) */
            <M-80 run GetDBDatasetHandle
               (output vhBCInvoiceInstanceDataOneInst (ohHandleToTheClassDataset), 
                output viExternalReturn (oiReturnStatus)) in BCInvoice>
            if vlBCInvoiceIsOpenedHere
            then do:
                <I-48 {bFcCloseInstance
                     &CLASS           = "BCInvoice"}>
            end. /*  if vlBCInvoiceIsOpenedHere */
            if viExternalReturn <> 0 
            then assign viLocalReturn = viExternalReturn.
            if viExternalReturn < 0 
            then Leave GETINSTDATABLOCK.
            /* Add the content of vhBCInvoiceInstanceDataOneInst to the dataset holding all invoices being handled in this class (class-level handle vhBCInvoiceInstanceData) */
            /* In case this is the first time we pass here: use the dataset returned from BCInvoice, no need for copy and delete in this case                                 */
            if vhBCInvoiceInstanceData = ? or  
               valid-handle(vhBCInvoiceInstanceData) = false
            then vhBCInvoiceInstanceData = vhBCInvoiceInstanceDataOneInst.
            else do:
                /* append data into the existing dataset and delete the one comming from BCInvoice */
                vhBCInvoiceInstanceData:copy-dataset(vhBCInvoiceInstanceDataOneInst, /* handle to the class dataset that contains tCInvoiceCIAPM and from which to copy */
                                                     true, /* Append-mode */
                                                     false, /* Replace-mode */ 
                                                     false, /* Loose-copy-mode; it relaxes the requirement that the metaschema for the source and target temp-tables be the same */
                                                     "":U, /* pairs-list; comma-separated list of the target and source temp-table pairs to be copied */
                                                     false, /* Current-only: copy only the current record of every table? */
                                                     "":U). /* Name-prefix: optional character expression used as the prefix for naming the target ProDataSet */
                /* Delete the object with the dataset of BCInvoice (vhBCInvoiceInstanceDataCIJE) as we have copied it already and thus no longer need it */
                delete object vhBCInvoiceInstanceDataOneInst. 
            end. /* Not if vhBCInvoiceInstanceData = ? or */
        end. /* if viBCInvoiceFromBCIAPMID <> ? and */
    
    END. /* GETINSTDATABLOCK */
    
    /* ======================= */
    /* Erorr-hanlding - Return */
    /* ======================= */
    assign oiReturnStatus = viLocalReturn.