project QadFinancials > class BMfgCustomer > 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 BMfgCustomer.ApiReplicateFromFinancials
method BMfgCustomer.UpdateCustomerLanguageSearchName


program code (program/bmfgcustomer.p)

MAIN_BLOCK:
do on error undo, leave MAIN_BLOCK:

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

       if viPMFGProfile10ID = 0 or 
          viPMFGProfile10ID = ?
       then do:
          <I-412 {bFcStartAndOpenInstance
               &CLASS                = "PMFGProfile"}>            
       end.
       else if not valid-handle(vhPMFGProfile10Inst)
       then do:
        <I-92 {bFcOpenInstance
             &CLASS           = "PMFGProfile"}>
       end. 

       <M-85 run DeleteDebtorProfile
          (input  t_scm_mstr.cm_addr (icDebtorCode), 
           input  ? (icDebtorShipTo), 
           input  t_scm_mstr.cm_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(vhPMFGProfile10Inst)
    then do:
       <I-62 {bFcCloseAndStopInstance
            &CLASS           = "PMFGProfile"}> 
    end.

    <ANCESTOR-CODE>
    if oiReturnStatus < 0 then leave MAIN_BLOCK.
    
    /* ===================================================================== *
     * Replicate Customer definition also into ad_mstr table                 *
     * ===================================================================== */
    if viBMfgAddressID = 0 or
       viBMfgAddressID = ?
    then do:   
        <I-5 {bFcStartAndOpenInstance
                &ADD-TO-TRANSACTION = "true"
                &CLASS              = "BMfgAddress"}>
        assign vlIsBMfgAddrStHrBMfgCu = true
               vlIsBMfgAddrOpHrBMfgCu = true.
    end.
    else if not valid-handle(vhBMfgAddressInst)
    then do:
         <I-13 {bFcOpenInstance
                &CLASS           = "BMfgAddress"}>
         assign vlIsBMfgAddrOpHrBMfgCu = true.
    end.                              
    
    <M-23 run ApiReplicateFromFinancialsDebtor
       (input  tDebtor (tDebtorsToUpdate), 
        input  vcReplicateDomainCode (icDomainCode), 
        output viFcReturnSuper (oiReturnStatus)) in BMfgAddress>
    if viFcReturnSuper <> 0 and viLocalReturnStatus = 0 
    then assign viLocalReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    
    /* ===================================================================== *
     * if we are deleting a customer then clenaup the dock                   *
     * ===================================================================== */
    assign vcListCustomerKeys = "":U.
    for each t_scm_mstr where
             t_scm_mstr.tc_status = "D": 

        if vcListCustomerKeys <> ""
        then assign vclistCustomerkeys = vclistCustomerkeys + chr(4).
        assign vcListCustomerKeys = vclistCustomerkeys + t_scm_mstr.cm_domain + chr(2) + t_scm_mstr.cm_addr.
    end. 
    
    if vcListCustomerKeys <> "":U
    then do:
        <M-18 run DeleteDockAddressesForCustomer
           (input  vcListCustomerKeys (iclstCustKeys), 
            output viFcReturnSuper (oiReturnStatus)) in BMfgAddress> 
        if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0
        then do:
            assign vcMessageText = #T-19'Customer cannot be deleted. Cannot delete associated dock addresses.':70(65104)t-19#.
            <M-20 run SetMessage
               (input  vcMessageText (icMessage), 
                input  '' (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '' (icRowid), 
                input  'QadFin-6908':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BMfgCustomer>
            if viLocalReturnStatus < 0 then leave MAIN_BLOCK.
        end.
    end. /* if vcListCustomerKeys <> "":U */
    
    /* ===================================================================== *
     * Replicate Customer definition also into ad_det table                 *
     * ===================================================================== */
    if viBMfgAddressListDetailId = 0 or
       viBMfgAddressListDetailId = ?
    then do:
        <I-9 {bFcStartAndOpenInstance
                &ADD-TO-TRANSACTION = "true"
                &CLASS              = "BMfgAddressListDetail"}>
        assign vlIsBMfgAddrLstStHrBMfgCu = true
               vlIsBMfgAddrLstOpHrBMfgCu = true.
    end.
    else if not valid-handle(vhBMfgAddressListDetailInst)
    then do:
        <I-14 {bFcOpenInstance
                &CLASS           = "BMfgAddressListDetail"}>
        assign vlIsBMfgAddrLstOpHrBMfgCu = true.
    end.
                                  
    <M-24 run ApiReplicateFromFinancialsDebtor
       (input  tDebtor (tDebtorsToUpdate2), 
        input  vcReplicateDomainCode (icDomainCode), 
        output viFcReturnSuper (oiReturnStatus)) in BMfgAddressListDetail>
    if viFcReturnSuper <> 0 and viLocalReturnStatus = 0 
    then assign viLocalReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    
    assign vcReplicateDomainCode = "":U.
end. /* of MAIN_BLOCK */    
    
if not vlIsKeepInstancesOpenBMfgCu
then do:
    <M-91 run CloseExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BMfgCustomer>
    if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
end.

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

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