project QadFinancials > class BMfgSupplier > method AdditionalUpdates

Description

This empty method allows to do additional updates on class temp-tables after records were received (and validated) from outside, using method SetPublicTables.
You can start instances of other business classes to do those updates.


Parameters


oiReturnStatusoutputinteger


Internal usage


QadFinancials
method BMfgSupplier.ApiReplicateFromFinancials
method BMfgSupplier.UpdateSupplierLanguageSearchName


program code (program/bmfgsupplier.p)

MAIN_BLOCK:
do on error undo, leave MAIN_BLOCK:

    assign viLocalReturnStatus = 0
           oiReturnStatus      = 0. 
    
    for each t_svd_mstr where tc_status = "D":U:

       if viPMFGProfileID = 0 or 
          viPMFGProfileID = ?
       then do:
          <I-44 {bFcStartAndOpenInstance
               &CLASS                = "PMFGProfile"}>
       end.
       else if not valid-handle(vhPMFGProfileInst)
       then do:
        <I-30 {bFcOpenInstance
             &CLASS           = "PMFGProfile"}>
       end. 

       <M-57 run DeleteCreditorProfile
          (input  t_svd_mstr.vd_addr (icCreditorCode), 
           input  t_svd_mstr.vd_domain (icCurrentDomain), 
           output viFcReturnSuper (oiReturnStatus)) in PMFGProfile>

       if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
       if viLocalReturnStatus < 0 then leave MAIN_BLOCK.
    end.
    
    if valid-handle(vhPMFGProfileInst)
    then do:
       <I-15 {bFcCloseAndStopInstance
            &CLASS           = "PMFGProfile"}> 
    end.

    <ANCESTOR-CODE>

    assign oiReturnStatus = -98.

    /* Call the MaintainDataCreditor in BMFGAddress to update the ad_mstr in mfgpro */
    if viBMfgAddress7ID = 0 or 
       viBMfgAddress7ID = ?
    then do:
        <I-10 {bFcStartAndOpenInstance
            &ADD-TO-TRANSACTION = "true"
            &CLASS              = "BMfgAddress"}>
        assign vlIsBMfgAddrStHrBMfgSu = true
               vlIsBMfgAddrOpHrBMfgSu = true.
    end. /* if viBMfgAddress7ID = 0 or viBMfgAddress7ID = ? */
    else if not valid-handle(vhBMfgAddress7Inst)
    then do:
        <I-11 {bFcOpenInstance
            &CLASS           = "BMfgAddress"}>
    end. /* Not if viBMfgAddress7ID = 0 or viBMfgAddress7ID = ? */

    <M-23 run ApiReplicateFromFinancialsCreditor
       (input  tCreditor (tCreditorsToUpdate), 
        input  vcDomainCodeForReplication (icDomainCode), 
        output viFcReturnSuper (oiReturnStatus)) in BMfgAddress>
    if viFcReturnSuper <> 0 and viLocalReturnStatus = 0 
    then assign viLocalReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 then leave MAIN_BLOCK.        
        
    
    /* ===================================================================== *
     * Replicate Supplier definition also into ad_det table                  *
     * ===================================================================== */
    if viBMfgAddressListDetail7ID = 0 or 
       viBMfgAddressListDetail7ID = ?
    then do:
        <I-17 {bFcStartAndOpenInstance
             &ADD-TO-TRANSACTION   = "true"
             &CLASS                = "BMfgAddressListDetail"}>
        assign vlIsBMfgAddrLstStHrBMfgSu = true
               vlIsBMfgAddrLstOpHrBMfgSu = true.
    end. /* if viBMfgAddressListDetail7ID = 0 or viBMfgAddressListDetail7ID = ? */
    else if not valid-handle(vhBMfgAddressListDetail7Inst)
    then do:
        <I-18 {bFcOpenInstance
            &CLASS           = "BMfgAddressListDetail"}>
        assign vlIsBMfgAddrLstOpHrBMfgSu = true.
    end. /* Not if viBMfgAddressListDetail7ID = 0 or viBMfgAddressListDetail7ID = ? */

    <M-24 run ApiReplicateFromFinancialsCreditor
       (input  tCreditor (tCreditorsToUpdate2), 
        input  vcDomainCodeForReplication (icDomainCode), 
        output viFcReturnSuper (oiReturnStatus)) in BMfgAddressListDetail>
    if viFcReturnSuper <> 0 and viLocalReturnStatus = 0 
    then assign viLocalReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 then leave MAIN_BLOCK.
        
    assign vcDomainCodeForReplication = '':U.
end. /* of MAIN_BLOCK */    
    
if not vlIsKeepInstancesOpenBMfgSu
then do:
    <M-66 run CloseExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>
    if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
end.

if viLocalReturnStatus < 0
then do:
    <M-63 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>
end.

/* ======================== */
/* Set ReturnStatus = OK    */
/* ======================== */
assign oiReturnStatus = viLocalReturnStatus.